Need it in 40 hours. Staistics HW using R programming language (spencer_m)
STATISTICS 462 – Summer 2016 Homework 5
DUE Monday, July 25th
Unless otherwise stated, you can use R for any of the calculations, but make sure you include your code. Your code should not be a copy of anyone else’s! Any code you turn in should be well organized and commented so the grader can understand your answers.
All programming questions should be submitted to the dropbox on ANGEL for this assignment as a .pdf file using the naming convention HWNum_FirstInitialLastName.pdf. For example, John Doe would submit a file titled HW1_JDoe.pdf for the first assignment. Your answer to programming questions should include both code and a description of your result. I recommend using R-markdown for writing up your answers. A template for writing up an assignment in R-markdown can be found on ANGEL. R-markdown files can be compiled directly within R-Studio. Alternatively, answers may be saved in a word document or LaTeX, and converted into a .pdf file.
Non-coding questions can either be written and submitted in the same file as your coding questions using LaTeX typesetting (see https://latex-project.org/intro.html) or they may be handwritten and turned in separately during class.
1. Consider the following multiple regression model
Yi = β0 + β1Xi1 + β2Xi2 + β3Xi3 + β4Xi4 + β5Xi5 + �i, where �i iid∼ N(0,σ2)
State the number of degrees of freedom that are associated with each of the following sequential sums of squares when constructing partial F tests.
(a) SSR(X1|X2)
(b) SSR(X2|X1,X3)
(c) SSR(X1,X2|X3,X4)
(d) SSR(X1,X2,X3|X4,X5)
2. For the multiple regression model in question 1, what is the form of the F-statistic for each of the following tests? In each case, you may assume the full model contains all 5 predictors.
(a) H0 : β5 = 0
(b) H0 : β2 = β4 = 0
(c) H0 : β1 = β2 = β3 = β4 = β5 = 0
3. Using R, read in the dataset “brandPreference.txt”. The data refers to a small-scale experimental study of the relation between degree of brand liking (Y ), moisture content (X1), and sweetness (X2) of the product.
(a) Calculate the ANOVA table that decomposes the regression sum of squares into the sequential sums of squares associated with X1, and with X2 given X1.
(b) Test whether X2 can be dropped from the regression model given that X1 is retained using a partial F test at level α = 0.01. State the alternatives, decision rule, and conclusion. Calculate p-value for this test.
(c) Calculate R2Y 1, R 2 Y2 , R212, R
2 Y 1|2, R
2 Y 2|1, R
2 Y 2|13 and R
2. Explain what each coefficient measures and interpret your results.
4. A person’s muscle mass is expected to decrease with age. To explore this relationship in women, a nutritionist randomly selected 16 women from each 10-year age group, over the age range of 40 - 79. Using R, read in the dataset “muscleMass.txt” The variables include X = age and Y =measure of muscle mass.
(a) Fit the following regression model
Yi = β0 + β1Xi + β11X 2 i �i
Plot the fitted regression function over a scatterplot of the data. Does the quadratic regression function appear to be a good fit? Calculate the R2 for this model.
(b) Test the fit of the full model at level α = 0.05. State the alternatives, decision rule, and conclusion.
(c) Estimate the mean muscle mass for women who are 48 years-old. Construct a 95% confidence interval for this estimate.
(d) Predict the muscle mass for a woman whose age is 48 years-old. Construct a 95% prediction interval for this estimate. Interpret the interval.
(e) Test whether the quadratic term can be dropped from the regression model at level α = 0.05. State the alternatives, decision rule, and conclusion.
5. Load the “brandPreference.txt” data used in quesiton 3.
(a) Fit the following regression model
Yi = β0 + β1Xi1 + β2Xi2 + β3Xi1Xi2 + �i
Give the estimated regression coefficients for this data.
(b) Interpret the parameter estimates for this model.
(c) Test whether the interaction term can be dropped from the model at level α = 0.05. State the alternatives, decision rule, and conclusion.