Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The data set ( Canvas: body.csv ) contains records of CHEST _ DIAM, , CHEST _ DEPTH, ANKLE _ DIAM, WAIST _ GIRTH, WRIST _

The data set (Canvas: body.csv) contains records of CHEST_DIAM, , CHEST_DEPTH,
ANKLE_DIAM, WAIST_GIRTH, WRIST_GIRTH, WRIST_DIAM (all in cm.), AGE (years), WEIGHT
(kg.), HEIGHT (cm.), and GENDER (1=male) for 108 individuals. We will be looking for the best set
of variables to (parsimoniously?) model WEIGHT. Even though 9 explanatory variables only
gives 29=512 possibilities for all possible regressions, well try to be more methodical about it.
a. First, use forward selection to find the best model for WEIGHT. Give the model.
b. Next, use backwards elimination to find the best model for WEIGHT. Give the model. (It may
be the same modelnoteworthy, either way.)
c. Finally, as you did in problem 1, fit all possible models, and find the highest adjusted 2(no
need to report the model)check models with 5,6, and 7 variables with the highest adjusted
2 compared to yours (hint, hint)is there much difference?##Question 2
#Load the olsrr library for variable selection processes
library("olsrr")
#Load the MASS library to iteratively add and remove predictor variables
library(MASS)
#Read the file into the data frame
body = read. csv("body.csv", header =T)
#Attach the 'body' dataframe to make it easier to reference the variables
attach(body)
#Create new variables with a suffix '_sr'(for Step Regression) to keep the original variables for la
chest_diam_sr = chest_diam
chest_depth_sr = chest_depth
Text
ankle_diam_sr = ankle_diam
waist_girth_sr = waist_girth
wrist_girth_sr = wrist_girth
wrist_diam_sr = wrist_diam
age_sr = age
height_sr = height
gender_sr = gender
weight_sr = weight
#Detach the 'body' dataframe to avoid conflicts
detach(body)
#Create a new dataframe 'body_sr' using the modified variables
body_sr = data.frame(chest_diam = chest_diam_sr,
chest_depth = chest_depth_sr,
ankle_diam = ankle_diam_sr,
waist_girth = waist_girth_sr,
wrist_girth = wrist_girth_sr,
wrist_diam = wrist_diam_sr,
STA674-Assignment 1*
age = age_sr,
height = height_sr,
gender = gender_sr,
weight = weight_sr)
#Attach the 'body_sr' dataframe for easier reference
attach(body_sr)
#Perform linear regression using the variables in the 'body_sr' dataframe and plot
body_sr. lm = lm(weight ., data = body_sr)
plot(body_sr.lm)
#Perform backward stepwise regression using AIC for model selection
body_sr.back = ols_step_backward_aic(body_sr.lm)
#Perform forward stepwise regression using AIC for model selection
body_sr.forward = ols_step_forward_aic(body_sr.lm)
#Plot graphs for the backward and forward stepwise regression model
plot(body_sr.back)
plot(body_sr.forward)
#Perform linear regression using the variables in the original 'body' dataframe and summarize
body. lm= lm weight chest_diam + chest_depth + ankle_diam + waist_girth +
wrist_girth + wrist_diam + age + height + gender, data = body )
summary(body. lm)
#Perform backward stepwise regression using AIC and display the ANOVA results
step_backward = stepAIC(body. lm, direction = "backward")
step_backward$anova
#Perform forward stepwise regression using AIC and display the ANOVA results
step_forward = stepAIC(body.lm, direction = "forward")
step_forward$anova
#Detach the 'body_sr' dataframe
detach(body_sr)
STA674-Assignment 1*
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning ASP.NET 2.0 And Databases

Authors: John Kauffman, Bradley Millington

1st Edition

0471781347, 978-0471781349

More Books

Students also viewed these Databases questions

Question

Q.No.1 Explain Large scale map ? Q.No.2 Explain small scale map ?

Answered: 1 week ago