Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help with 5.8.2. I\'m not sure how to code it using R. The data set \"cak

ID: 3170345 • Letter: I

Question

I need help with 5.8.2. I'm not sure how to code it using R.

The data set "cakes" is part of the library "alr4". https://rdrr.io/rforge/alr4/man/cakes.html

My R input is:

> cakes.lm = lm(Y~block+X1 + X2 + I(X1^2) + I(X2^2) + X1:X2 + block:X1 + block:X2 + block:I(X1^2) + block:I(X2^2) + block:(X1:X2), data=cakes)
> summary(cakes.lm)

but my output has two NA's

Call:
lm(formula = Y ~ block + X1 + X2 + I(X1^2) + I(X2^2) + X1:X2 +
block:X1 + block:X2 + block:I(X1^2) + block:I(X2^2) + block:(X1:X2),
data = cakes)

Residuals:
1 2 3 4 5 6 7 8 9 10 11
-6.314e-16 -5.391e-16 -5.786e-16 -5.054e-16 3.233e-01 -4.067e-01 8.333e-02 4.941e-16 6.104e-16 5.039e-16 5.521e-16
12 13 14
-2.933e-01 3.367e-01 -4.333e-02

Coefficients: (2 not defined because of singularities)
Estimate Std. Error t value Pr(>|t|)
(Intercept) -2.195e+03 1.970e+02 -11.146 0.000369 ***
block1 1.980e+01 1.146e+02 0.173 0.871189
X1 2.684e+01 6.176e+00 4.347 0.012187 *
X2 9.781e+00 1.145e+00 8.539 0.001032 **
I(X1^2) -1.725e-01 7.691e-02 -2.243 0.088326 .
I(X2^2) -1.174e-02 1.578e-03 -7.441 0.001742 **
X1:X2 -4.163e-02 8.643e-03 -4.816 0.008549 **
block1:X1 -1.126e+00 6.536e+00 -0.172 0.871623
block1:X2 -1.672e-02 2.445e-02 -0.684 0.531701
block1:I(X1^2) 2.083e-02 9.336e-02 0.223 0.834350
block1:I(X2^2) NA NA NA NA
block1:X1:X2 NA NA NA NA
---
Signif. codes: 0 **0.001 *0.01 0.05 0.1 1

Residual standard error: 0.3457 on 4 degrees of freedom
Multiple R-squared: 0.9833,   Adjusted R-squared: 0.9458
F-statistic: 26.21 on 9 and 4 DF, p-value: 0.003309

5.8 Cake data (Data file: cakes 5.8.1 Fit (5.12) and verify that the significance levels for the quadratic terms and the interaction are all less than 0.005. When fitting polynomials, tests concerning main effects in models that include a quadratic are generally not of much interest. 5.8.2 The cake experiment was carried out in two blocks of seven observations each. It is possible that the response might differ by block. For example, if the blocks Were different days then differences in air temperature or humidity when the cakes were mixed might have some effect on Y We can allow for block effects by adding a factor for block to the mean function and possibly allowing for block by regressor interactions. Add block effects to the mean function fit in Section 5.3.1 and summarize results The blocking is indicated by the variable Block in the data file.

Explanation / Answer

Please note that NA more generally means that the coefficient cannot be estimated. This can happen due to exact collinearity between the variables. But, it can also happen due to not having enough observations to estimate the relevant parameters, so if we run the regression equation as

fit<- lm(Y~X1+X2+I(X1^2)+I(X2^2)+X1:X2, data=cakes)
summary(fit)

summary(fit)

Call:
lm(formula = Y ~ X1 + X2 + I(X1^2) + I(X2^2) + X1:X2, data = cakes)

Residuals:
Min 1Q Median 3Q Max
-0.4912 -0.3080 0.0200 0.2658 0.5454

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -2.204e+03 2.416e+02 -9.125 1.67e-05 ***
X1 2.592e+01 4.659e+00 5.563 0.000533 ***
X2 9.918e+00 1.167e+00 8.502 2.81e-05 ***
I(X1^2) -1.569e-01 3.945e-02 -3.977 0.004079 **
I(X2^2) -1.195e-02 1.578e-03 -7.574 6.46e-05 ***
X1:X2 -4.163e-02 1.072e-02 -3.883 0.004654 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.4288 on 8 degrees of freedom
Multiple R-squared: 0.9487,   Adjusted R-squared: 0.9167
F-statistic: 29.6 on 5 and 8 DF, p-value: 5.864e-05

, here the model is signifcant enough and at the same time is able to explain 92% of the variation in the data

This is also in accordance with the mean function you are trying to fit

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote