The Book of R (Question 20.2) Please answer using R code. Continue using the survey data...

90.2K

Verified Solution

Question

Statistics

The Book of R (Question 20.2) Please answer using R code.

Continue using the survey data frame from the package MASS forthe next few exercises.

  1. The survey data set has a variable named Exer , a factor with k= 3 levels describing the amount of physical exercise time eachstudent gets: none, some, or frequent. Obtain a count of the numberof students in each category and produce side-by-side boxplots ofstudent height split by exercise.
  2. Assuming independence of the observations and normality asusual, fit a linear regression model with height as the responsevariable and exercise as the explanatory variable (dummy coding).What’s the default reference level of the predictor? Produce amodel summary.
  3. Draw a conclusion based on the fitted model from (b)—does itappear that exercise frequency has any impact on mean height? Whatis the nature of the estimated effect?
  4. Predict the mean heights of one individual in each of the threeexercise categories, accompanied by 95 percent predictionintervals.
  5. Do you arrive at the same result and interpretation for theheight-by-exercise model if you construct an ANOVA table using aov?
  6. Is there any change to the outcome of (e) if you alter themodel so that the reference level of the exercise variable is“none”? Would you expect there to be?

Now, turn back to the ready-to-usemtcars data set. One of the variables in this data frame is qsec ,described as the time in seconds it takes to race a quarter mile;another is gear , the number of forward gears (cars in this dataset have either 3, 4, or 5 gears).

  1. Using the vectors straight from the data frame, fit a simplelinear regression model with qsec as the response variable and gearas the explanatory variable and interpret the model summary.
  2. Explicitly convert gear to a factor vector and refit the model.Compare the model summary with that from (g). What do youfind?
  3. Explain, with the aid of a relevant plot in the same style asthe right image of Figure 20-6 why you think there is a differencebetween the two models (g) and (h).

Answer & Explanation Solved by verified expert
4.3 Ratings (648 Votes)
libraryMASS a libraryplyr countsurveyvarsExerExer freq1 Freq 1152 None 243 Some 98 parmfrowc13 attachsurvey s1surveywhichExerFreq s2surveywhichExerNone s3surveywhichExerSome boxplots1HeightxlabFreq boxplots2HeightxlabNone boxplots3HeightxlabSome b linmodellmHeightExer summarylinmodelCalllmformula Height ExerResidualsMin 1Q Median 3Q Max24607 6397 1607 6103 25393CoefficientsEstimate Std Error t value PrtIntercept 1746067 09396 185836 2e16 ExerNone 55787 23489 2375 001847 ExerSome 42098    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students