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

pls solve this question by r. thsnks Recall the hw problem (hw Ject14_1) where y

ID: 3269502 • Letter: P

Question


pls solve this question by r. thsnks

Recall the hw problem (hw Ject14_1) where you showed that adding useless predictors to a regression model can increase R2. This time, suppose the true/pop fit is y Ii.e., no x at all), and so a possible sample from the population could be the following: set.seed(123) n=20 # Use this line to make sure we all get the same answes. 1 + rnorm(n,0,1) a) In the old hw, there was one useful predictor (x1), and 4 useless predictors (x2x3.x4,x5). Here, revise that code to have data on 10 useless predictors( and no useful predictors), fit the model y = alpha + betal x1 + + beta10 x10. performs the test of model utility, and perform t-tests on each of the 10 coefficients to see if your code. By R they are zero. Just show b) According to the F-test of model uilit, are any of the prediclors useful at alpba-0.1 c) According to the t-tests, are any of the predict the moral of this exercise. ors useful at alpha 0.1? See the solns to make sure you un derstand

Explanation / Answer

> set.seed(123)
> n=20
> y=1+rnorm(n,0,1)
> ###We choose 10 rangomly predictors
> x1=rnorm(n,0,1)
> x2=rnorm(n,0,1)
> x3=rnorm(n,0,1)
> x4=rnorm(n,0,1)
> x5=rnorm(n,0,1)
> x6=rnorm(n,0,1)
> x7=rnorm(n,0,1)
> x8=rnorm(n,0,1)
> x9=rnorm(n,0,1)
> x10=rnorm(n,0,1)
> ### So we fit regression equation
> fit1=lm(y~x1)
> R_square1=summary(fit1)$r.squared
> R_square1
[1] 0.008413069
> fit2=lm(y~x1+x2)
> R_square2=summary(fit2)$r.squared
> R_square2
[1] 0.02204381
> fit3=lm(y~x1+x2+x3)
> R_square3=summary(fit3)$r.squared
> R_square3
[1] 0.03842204
> fit4=lm(y~x1+x2+x3+x4)
> R_square4=summary(fit4)$r.squared
> R_square4
[1] 0.1022701
> fit5=lm(y~x1+x2+x3+x4+x5)
> R_square5=summary(fit5)$r.squared
> R_square5
[1] 0.1863389
> fit6=lm(y~x1+x2+x3+x4+x5+x6)
> R_square6=summary(fit6)$r.squared
> R_square6
[1] 0.3194028
> fit7=lm(y~x1+x2+x3+x4+x5+x6+x7)
> R_square7=summary(fit7)$r.squared

> R_square7

[1] 0.3486947

> fit8=lm(y~x1+x2+x3+x4+x5+x6+x7+x8)
> R_square8=summary(fit8)$r.squared
> R_square8
[1] 0.3498146
> fit9=lm(y~x1+x2+x3+x4+x5+x6+x7+x8+x9)
> R_square9=summary(fit9)$r.squared
> R_square9
[1] 0.5104792
> fit10=lm(y~x1+x2+x3+x4+x5+x6+x7+x8+x9+x10)
> R_square10=summary(fit10)$r.squared
> R_square10
[1] 0.5211558
>
> # We can see if we add predictors in the model then R square will be increases and goes to 1.
>
> ##A)calculating t-test in R we use summary coammand to calculate t-test.

> fit10=lm(y~x1+x2+x3+x4+x5+x6+x7+x8+x9+x10)
> summary(fit10)

Call:
lm(formula = y ~ x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 +
x10)

Residuals:
Min 1Q Median 3Q Max
-0.9593 -0.4995 -0.1429 0.5494 1.2171

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.61129 0.32620 4.940 0.000803 ***
x1 -0.02495 0.35914 -0.069 0.946130
x2 -0.54044 0.36886 -1.465 0.176913
x3 -0.07725 0.28908 -0.267 0.795325
x4 -0.57244 0.38093 -1.503 0.167161
x5 0.50868 0.36808 1.382 0.200307
x6 0.31289 0.23943 1.307 0.223669
x7 -0.17878 0.24418 -0.732 0.482694
x8 0.24248 0.28487 0.851 0.416735
x9 0.57515 0.32490 1.770 0.110464
x10 -0.13060 0.29155 -0.448 0.664770
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.9779 on 9 degrees of freedom
Multiple R-squared: 0.5212, Adjusted R-squared: -0.01089
F-statistic: 0.9795 on 10 and 9 DF, p-value: 0.517

> ##B)F-test we do usong anova command.
> fit10=lm(y~x1+x2+x3+x4+x5+x6+x7+x8+x9+x10)
> anova(fit10)
Analysis of Variance Table

Response: y
Df Sum Sq Mean Sq F value Pr(>F)
x1 1 0.1512 0.15123 0.1581 0.7002
x2 1 0.2450 0.24502 0.2562 0.6249
x3 1 0.2944 0.29441 0.3078 0.5925
x4 1 1.1477 1.14770 1.2000 0.3018
x5 1 1.5112 1.51118 1.5801 0.2404
x6 1 2.3919 2.39189 2.5010 0.1482
x7 1 0.5265 0.52654 0.5505 0.4770
x8 1 0.0201 0.02013 0.0210 0.8878
x9 1 2.8880 2.88802 3.0197 0.1163
x10 1 0.1919 0.19192 0.2007 0.6648
Residuals 9 8.6075 0.95638   

C)we can see according to t-test aswll as f-test there is no any predictor is usefull for prediction .

Becuse we all the p-values of T-test table as well as f-test table are greter than 0.05.

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Best of Luck :)