Escrito por estudiantes que aprobaron Inmediatamente disponible después del pago Leer en línea o como PDF ¿Documento equivocado? Cámbialo gratis 4,6 TrustPilot
logo-home
Examen

Homework 8 - HW8

Puntuación
-
Vendido
-
Páginas
25
Grado
A+
Subido en
15-10-2024
Escrito en
2024/2025

Exam of 25 pages for the course Intro to Analytics Modeling at Intro to Analytics Modeling (Homework 8 - HW8)

Institución
Intro To Analytics Modeling
Grado
Intro to Analytics Modeling

Vista previa del contenido

10/15/24, 9:27 Homew ork 8 -
AM HW8




ISYE 6501: Homework 8
2023-03-07

Question 11.1, Part 1: Stepwise Regression
Using the crime data set uscrime.txt from Questions 8.2, 9.1, and 10.1, build a
regression model using: 1. Stepwise regression

We begin by retrieving and preparing our data as we did in previous weeks. As part of our
data preparation, we take the following steps:
• identify and remove outliers,
• replace them using a K-means imputation method, and
• scale data before and after imputation.
# Url address
url <- "http://www.statsci.org/data/general/uscrime.txt"

# Destination File location
destfile <- "C:/Users/arvin/Downloads/uscrime.txt"

# Script to download and save file
download.file(url, destfile)

# Convert file to table
cdf <- read.table("C:/Users/arvin/Downloads/uscrime.txt", header = TRUE)

# Preview the data
head(cdf)

## M So Ed Po1 Po2 LF M.F NW U1 U2 Wealth Ineq
Pop
Prob
## 1 15.1 1 9.1 5.8 5.6 95.0 30.1 0.108 3940 26.1
0.510 33 4.1
0.084602
## 2 14.3 0 11.3 10.3 9.5 101.2 10.2 0.096 5570 19.4
0.583 13 3.6
0.029599
## 3 14.2 1 8.9 4.5 4.4 96.9 21.9 0.094 3180 25.0
0.533 18 3.3
0.083401
## 4 13.6 0 12.1 14.9 14.1 99.4 8.0 0.102 6730 16.7
0.577 157 3.9
0.015801
## 5 14.1 0 12.1 10.9 10.1 98.5 3.0 0.091 5780 17.4
0.591 18 2.0
0.041399
## 6 12.1 0 11.0 11.8 11.5 96.4 4.4 0.084 6890 12.6
0.547 25 2.9
0.034201
## Time Crime
## 1 26.2011 791
## 2 25.2999 1635




about:blan 1/
k 25

,10/15/24, 9:27 Homew ork 8 -
AM HW8




## 3 578
24.3006
## 4 1969
29.9012
## 5 1234
21.2998
## 6 682
20.9995

# Outliers
cdf_out <- boxplot.stats(cdf$Crime)$out

# Indices of outliers
cdfout_ind <- which(cdf$Crime %in% c(cdf_out))

# copy df
cdf_copy <- cdf

# Replace outliers with NA prior to imputation
cdf_copy$Crime[cdfout_ind] <- NA

# Split response from predictors
cdf_x <- cdf_copy[, -16]
cdf_y <- cdf_copy[, 16]

# Scale data for Kmeans
cdf_xs <- scale(cdf_x)

# K-means to Elbow plot to determine ideal k for
imputation # later
set.seed(77)
tot_withinss <- map_dbl(2:10, function(k) {
km_mod <- kmeans(cdf_xs, centers = k, nstart =
25) km_mod$tot.withinss
})

# Elbow point appears to be k = 3
wss <- data.frame(k = 2:10, tot_withinss = tot_withinss)
ggplot(wss, aes(k, tot_withinss)) + geom_line() +
geom_point()




about:blan 2/
k 25

, 10/15/24, 9:27 Homew ork 8 -
AM HW8




about:blan 3/
k 25

Escuela, estudio y materia

Institución
Intro to Analytics Modeling
Grado
Intro to Analytics Modeling

Información del documento

Subido en
15 de octubre de 2024
Número de páginas
25
Escrito en
2024/2025
Tipo
Examen
Contiene
Preguntas y respuestas

Temas

$13.99
Accede al documento completo:

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Conoce al vendedor
Seller avatar
EXAMSHAVEN1

Conoce al vendedor

Seller avatar
EXAMSHAVEN1 Stanford University
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
2
Miembro desde
1 año
Número de seguidores
0
Documentos
924
Última venta
11 meses hace
A+ GRADE FOR NURSING EXAMS

Success is the sum of small efforts - repeated day in and day out. I am here to help in the precise way possible. Day in day out I will be updating you \\\'all with the latest exams not only in nursing but also in other areas. Don\\\'t forget to check out my store and recommend it to a friend. I will be uploading LATEST TESTBANKS TOO.

0.0

0 reseñas

5
0
4
0
3
0
2
0
1
0

Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes