Answered step by step
Verified Expert Solution
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 CHESTDIAM, CHESTDEPTH,
ANKLEDIAM, WAISTGIRTH, WRISTGIRTH, WRISTDIAM all in cm AGE years WEIGHT
kg HEIGHT cm and GENDER male for individuals. We will be looking for the best set
of variables to parsimoniously model WEIGHT. Even though explanatory variables only
gives 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 fit all possible models, and find the highest adjusted no
need to report the modelcheck models with and variables with the highest adjusted
compared to yours hint hintis there much difference?##Question
#Load the olsrr library for variable selection processes
libraryolsrr
#Load the MASS library to iteratively add and remove predictor variables
libraryMASS
#Read the file into the data frame
body read. csvbodycsv header
#Attach the 'body' dataframe to make it easier to reference the variables
attachbody
#Create new variables with a suffix srfor Step Regression to keep the original variables for la
chestdiamsr chestdiam
chestdepthsr chestdepth
Text
anklediamsr anklediam
waistgirthsr waistgirth
wristgirthsr wristgirth
wristdiamsr wristdiam
agesr age
heightsr height
gendersr gender
weightsr weight
#Detach the 'body' dataframe to avoid conflicts
detachbody
#Create a new dataframe 'bodysr using the modified variables
bodysr data.framechestdiam chestdiamsr
chestdepth chestdepthsr
anklediam anklediamsr
waistgirth waistgirthsr
wristgirth wristgirthsr
wristdiam wristdiamsr
STAAssignment
age agesr
height heightsr
gender gendersr
weight weightsr
#Attach the 'bodysr dataframe for easier reference
attachbodysr
#Perform linear regression using the variables in the 'bodysr dataframe and plot
bodysr lm lmweight data bodysr
plotbodysrlm
#Perform backward stepwise regression using AIC for model selection
bodysrback olsstepbackwardaicbodysrlm
#Perform forward stepwise regression using AIC for model selection
bodysrforward olsstepforwardaicbodysrlm
#Plot graphs for the backward and forward stepwise regression model
plotbodysrback
plotbodysrforward
#Perform linear regression using the variables in the original 'body' dataframe and summarize
body. lm weight chestdiam chestdepth anklediam waistgirth
wristgirth wristdiam age height gender, data body
summarybody lm
#Perform backward stepwise regression using AIC and display the ANOVA results
stepbackward stepAICbody lm direction "backward"
stepbackward$anova
#Perform forward stepwise regression using AIC and display the ANOVA results
stepforward stepAICbody direction "forward"
stepforward$anova
#Detach the 'bodysr dataframe
detachbodysr
STAAssignment
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started