hw2sol

.pdf

School

University of Illinois, Urbana Champaign *

*We aren’t endorsed by this school

Course

508

Subject

Statistics

Date

Feb 20, 2024

Type

pdf

Pages

6

Uploaded by MegaRose12943

Report
STAT 425 Assignment 2 Due Wednesday, September 6, 11:59 pm. Submit through Canvas. Name: SOLUTIONS Netid: (insert) Submit your computational work both as an R markdown (*.Rmd) document and as a pdf knitted from the Rmd file, along with any files needed to run the code. Embed your answers to each problem in the document below after the question statement. If you have hand-written work, please scan or take pictures of it and include in a pdf file, ideally combined with your pdf output file from R Markdown, but you can also upload them as a seperate file. Be sure to show your work. Problem 1 (10 pts) Least squares predictions This problem uses the cheddar data from the ‘faraway’ library in R. Make sure you have the faraway package installed. (a) (2 pts) Using the cheddar data, fit a least squares linear regression model for predicting taste from Lactic . Show the analysis of variance (anova) table for the model. State the null hypothesis being tested by the “F value” and p-value “Pr(>F)” in the table. What do you conclude, at significance level α = 0 . 05 ? Answer: library (faraway) mod1 <- lm (taste ~ Lactic, data= cheddar) anova (mod1) ## Analysis of Variance Table ## ## Response: taste ## Df Sum Sq Mean Sq F value Pr(>F) ## Lactic 1 3800.4 3800.4 27.55 1.405e-05 *** ## Residuals 28 3862.5 137.9 ## --- ## Signif. codes: 0 ' *** ' 0.001 ' ** ' 0.01 ' * ' 0.05 ' . ' 0.1 ' ' 1 1
The F value is a test of H 0 : the coefficient of Lactic equals zero. The pvalue < 0.05 so we reject H 0 . (b) (2 pts) Compute a 95% confidence interval for the coefficient of Lactic based on the fitted model, assuming normal errors with mean zero and constant error variance. Answer: Method 1: Here is the model summary: summary (mod1) ## ## Call: ## lm(formula = taste ~ Lactic, data = cheddar) ## ## Residuals: ## Min 1Q Median 3Q Max ## -19.9439 -8.6839 -0.1095 8.9998 27.4245 ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) ## (Intercept) -29.859 10.582 -2.822 0.00869 ** ## Lactic 37.720 7.186 5.249 1.41e-05 *** ## --- ## Signif. codes: 0 ' *** ' 0.001 ' ** ' 0.01 ' * ' 0.05 ' . ' 0.1 ' ' 1 ## ## Residual standard error: 11.75 on 28 degrees of freedom ## Multiple R-squared: 0.4959, Adjusted R-squared: 0.4779 ## F-statistic: 27.55 on 1 and 28 DF, p-value: 1.405e-05 Using the Lactic coefficient estimate and standard error, and the residual degrees of freedom from the summary we compute: tmult <- qt ( 0.975 , 28 ) cat ( "CI:" , 37.720 + c ( - 1 , 1 ) * tmult * 7.186 ) ## CI: 23.00015 52.43985 Method 2: confint (mod1)[ "Lactic" ,] ## 2.5 % 97.5 % ## 22.99928 52.44061 2
(c) (2 pts) Compute an estimate of the expected taste score for cheese with a Lactic score of 1.8. Answer: Fitted model coefficients: mod1 <- lm (taste ~ Lactic, data= cheddar) coef (mod1) ## (Intercept) Lactic ## -29.85883 37.71995 Expected response estimate - Method 1: - 29.86 + 37.72 * 1.8 ## [1] 38.036 Expected response estimate - Method 2 predict (mod1, newdata= data.frame ( Lactic = 1.8 )) ## 1 ## 38.03707 (d) (2 pts) Assuming independent normal errors with mean zero and constant error variance, compute a 95% confidence interval for the expected taste score for cheese with a Lactic score of 1.8. Answer: predict (mod1, newdata= data.frame ( Lactic= 1.8 ), se= TRUE , interval= "confidence" , level= 0.95 ) $ fit ## fit lwr upr ## 1 38.03707 31.17655 44.8976 The 95% confidence interval for expected taste score is (31.2, 44.9). (e) (2 pts) A new cheese sample is sent to the taste testers. It has Lactic = 1.8. Under the same assumptions as in Part (d), compute a 90% prediction interval for the taste score for the new cheese sample. Answer: predict (mod1, newdata= data.frame ( Lactic= 1.8 ), se= TRUE , interval= "prediction" , level= 0.90 ) $ fit ## fit lwr upr ## 1 38.03707 17.26076 58.81339 3
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help