Using R program (1) Use the comman: data(stackloss) to load the stackloss data,
ID: 3050838 • Letter: U
Question
Using R program (1) Use the comman: data(stackloss) to load the stackloss data, answer the following questions: (a) Fit a multiple regression model to predict stackloss from the other three variables. And summarize the results (b) Construct 95% confidence intervals for the coefficients of all the coefficients in (a), note: in the class I told you the degrees of freedom is (n-p-1), so when you use t distri- bution, do not forget the dof. (c) For the coefficient of airflow, what is the p-value and what is the conclusion?Explanation / Answer
#a)
> data(stackloss)
> s=stackloss
> X1=s[,1]
> X2=s[,2]
> X3=s[,3]
> Y=s[,4]
> reg=lm(Y~X1+X2+X3)
> reg
Call:
lm(formula = Y ~ X1 + X2 + X3)
Coefficients:
(Intercept) X1 X2 X3
-39.9197 0.7156 1.2953 -0.1521
> z=summary(reg)
> z
Call:
lm(formula = Y ~ X1 + X2 + X3)
Residuals:
Min 1Q Median 3Q Max
-7.2377 -1.7117 -0.4551 2.3614 5.6978
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -39.9197 11.8960 -3.356 0.00375 **
X1 0.7156 0.1349 5.307 5.8e-05 ***
X2 1.2953 0.3680 3.520 0.00263 **
X3 -0.1521 0.1563 -0.973 0.34405
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 3.243 on 17 degrees of freedom
Multiple R-squared: 0.9136, Adjusted R-squared: 0.8983
F-statistic: 59.9 on 3 and 17 DF, p-value: 3.016e-09
INTERPRETATION: here dataset contain 91% variation.
> #b)
> confint(reg,'X1',level=0.95)
2.5 % 97.5 %
X1 0.4311143 1.000166
> confint(reg,'X2',level=0.95)
2.5 % 97.5 %
X2 0.5188228 2.071749
> confint(reg,'X3',level=0.95)
2.5 % 97.5 %
X3 -0.4818741 0.1776291
> #c)
> a=z$coefficients
> pvalue=a[,4]
> pvalue[2]
X1
5.799025e-05
INTERPRETATION: P-value for coefficient of airflow is 5.799025e-05 is less than 0.05 hence we conclude that the variable airflow is statistically significant at common level alpha i.e 0.05.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.