RAssignment 2Sep 23Cont.docx
《RAssignment 2Sep 23Cont.docx》由会员分享,可在线阅读,更多相关《RAssignment 2Sep 23Cont.docx(8页珍藏版)》请在冰豆网上搜索。
![RAssignment 2Sep 23Cont.docx](https://file1.bdocx.com/fileroot1/2023-2/5/b8cf3b0e-4884-4ffa-9992-23d1e6f603d4/b8cf3b0e-4884-4ffa-9992-23d1e6f603d41.gif)
RAssignment2Sep23Cont
Call:
lm(formula=fyx)
Residuals:
Min1QMedian3QMax
-16.343-6.270-1.2865.52822.403
Coefficients:
EstimateStd.ErrortvaluePr(>|t|)
(Intercept)2.07991.63161.2750.210
x12.03480.35715.6981.61e-06***
x22.82760.252511.1991.92e-13***
---
Signif.codes:
0‘***’0.001‘**’0.01‘*’0.05‘.’0.1‘’1
Residualstandarderror:
9.5on37degreesoffreedom
MultipleR-squared:
0.8137,AdjustedR-squared:
0.8037
F-statistic:
80.83on2and37DF,p-value:
3.14e-14
>error=rnorm(T,mean=0,sd=9)
>y=1+2*x1+3*x2+error
>fyx=y~x1+x2
>res=lm(fyx)
>summary(res)
Call:
lm(formula=fyx)
Residuals:
Min1QMedian3QMax
-14.4131-5.1388-0.50285.293625.1226
Coefficients:
EstimateStd.ErrortvaluePr(>|t|)
(Intercept)2.69551.52791.7640.086.
x11.51910.33444.5425.74e-05***
x22.66840.236511.2851.54e-13***
---
Signif.codes:
0‘***’0.001‘**’0.01‘*’0.05‘.’0.1‘’1
Residualstandarderror:
8.896on37degreesoffreedom
MultipleR-squared:
0.8032,AdjustedR-squared:
0.7926
F-statistic:
75.52on2and37DF,p-value:
8.675e-14
>error=rnorm(T,mean=0,sd=9)
>y=1+2*x1+3*x2+error
>fyx=y~x1+x2
>res=lm(fyx)
>summary(res)
Call:
lm(formula=fyx)
Residuals:
Min1QMedian3QMax
-18.8149-4.5776-0.66255.864514.0127
Coefficients:
EstimateStd.ErrortvaluePr(>|t|)
(Intercept)2.40131.28971.8620.0706.
x12.56850.28239.0995.64e-11***
x22.77010.199613.8793.05e-16***
---
Signif.codes:
0‘***’0.001‘**’0.01‘*’0.05‘.’0.1‘’1
Residualstandarderror:
7.509on37degreesoffreedom
MultipleR-squared:
0.8843,AdjustedR-squared:
0.8781
F-statistic:
141.4on2and37DF,p-value:
<2.2e-16
>error=rnorm(T,mean=0,sd=9)
>y=1+2*x1+3*x2+error
>fyx=y~x1+x2
>res=lm(fyx)
>summary(res)
Call:
lm(formula=fyx)
Residuals:
Min1QMedian3QMax
-16.8775-6.37270.96874.978015.7572
Coefficients:
EstimateStd.ErrortvaluePr(>|t|)
(Intercept)2.90191.42502.0360.0489*
x12.06970.31196.6368.7e-08***
x23.09720.220514.044<2e-16***
---
Signif.codes:
0‘***’0.001‘**’0.01‘*’0.05‘.’0.1‘’1
Residualstandarderror:
8.297on37degreesoffreedom
MultipleR-squared:
0.8696,AdjustedR-squared:
0.8626
F-statistic:
123.4on2and37DF,p-value:
<2.2e-16
>error=rnorm(T,mean=0,sd=9)
>y=1+2*x1+3*x2+error
>fyx=y~x1+x2
>res=lm(fyx)
>summary(res)
Call:
lm(formula=fyx)
Residuals:
Min1QMedian3QMax
-18.624-5.4431.2454.21515.054
Coefficients:
EstimateStd.ErrortvaluePr(>|t|)
(Intercept)0.24331.53130.1590.875
x12.07580.33516.1943.43e-07***
x22.98570.237012.5995.93e-15***
---
Signif.codes:
0‘***’0.001‘**’0.01‘*’0.05‘.’0.1‘’1
Residualstandarderror:
8.916on37degreesoffreedom
MultipleR-squared:
0.845,AdjustedR-squared:
0.8366
F-statistic:
100.9on2and37DF,p-value:
1.048e-15
>error=rnorm(T,mean=0,sd=9)
>y=1+2*x1+3*x2+error
>fyx=y~x1+x2
>res=lm(fyx)
>summary(res)
Call:
lm(formula=fyx)
Residuals:
Min1QMedian3QMax
-21.6102-6.7581-0.20676.613921.4020
Coefficients:
EstimateStd.ErrortvaluePr(>|t|)
(Intercept)2.49381.65521.5070.140
x11.86540.36235.1498.89e-06***
x22.78450.256210.8704.49e-13***
---
Signif.codes:
0‘***’0.001‘**’0.01‘*’0.05‘.’0.1‘’1
Residualstandarderror:
9.637on37degreesoffreedom
MultipleR-squared:
0.8,AdjustedR-squared:
0.7892
F-statistic:
74on2and37DF,p-value:
1.172e-13
>error=rnorm(T,mean=0,sd=9)
>y=1+2*x1+3*x2+error
>fyx=y~x1+x2
>res=lm(fyx)
>summary(res)
Call:
lm(formula=fyx)
Residuals:
Min1QMedian3QMax
-16.906-6.4831.5905.68515.206
Coefficients:
EstimateStd.ErrortvaluePr(>|t|)
(Intercept)3.53581.44482.4470.0193*
x11.91190.31626.0465.44e-07***
x22.94820.223613.1861.49e-15***
---
Signif.codes:
0‘***’0.001‘**’0.01‘*’0.05‘.’0.1‘’1
Residualstandarderror:
8.412on37degreesoffreedom
MultipleR-squared:
0.8533,AdjustedR-squared:
0.8453
F-statistic:
107.6on2and37DF,p-value:
3.811e-16
>error=rnorm(T,mean=0,sd=9)
>y=1+2*x1+3*x2+error
>fyx=y~x1+x2
>res=lm(fyx)
>summary(res)
Call:
lm(formula=fyx)
Residuals:
Min1QMedian3QMax
-16.4157-7.8264-0.40648.564921.5937
Coefficients:
EstimateStd.ErrortvaluePr(>|t|)
(Intercept)1.64981.58991.0380.306
x12.00100.34805.7501.37e-06***
x23.40900.246113.8553.22e-16***
---
Signif.codes:
0‘***’0.001‘**’0.01‘*’0.05‘.’0.1‘’1
Residualstandarderror:
9.257on37degreesoffreedom
MultipleR-squared:
0.8613,AdjustedR-squared:
0.8538
F-statistic:
114.9on2and37DF,p-value:
<2.2e-16
>error=rnorm(T,mean=0,sd=9)
>y=1+2*x1+3*x2+error
>fyx=y~x1+x2
>res=lm(fyx)
>summary(res)
Call:
lm(formula=fyx)
Residuals:
Min1QMedian3QMax
-17.4926-4.3796-0.95673.814020.7822
Coefficients:
EstimateStd.ErrortvaluePr(>|t|)
(Intercept)0.22391.52670.1470.884
x12.45440.33427.3459.88e-09***
x23.00900.236312.7354.29e-15***
---
Signif.codes:
0‘***’0.001‘**’0.01‘*’0.05‘.’0.1‘’1
Residualstandarderror:
8.89on37degreesoffreedom
MultipleR-squared:
0.857,AdjustedR-squared:
0.8492
F-statistic:
110.8on2and37DF,p-value:
2.378e-16
>error=rnorm(T,mean=0,sd=9)
>y=1+2*x1+3*x2+error
>fyx=y~x1+x2
>res=lm(fyx)
>summary(res)
Call:
lm(formula=fyx)
Residuals:
Min1QMedian3QMax
-25.568-7.7062.5296.13220.302
Coefficients:
EstimateStd.ErrortvaluePr(>|t|)
(Intercept)2.85791.77161.6130.11520
x11.41790.38773.6570.00079***
x22.58700.27429.4362.18e-11***
---
Signif.codes:
0‘***’0.001‘**’0.01‘*’0.05‘.’0.1‘’1
Residualstandarderror:
10.32on37degreesoffreedom
MultipleR-squared:
0.7385,AdjustedR-squared:
0.7243
F-statistic:
52.23on2and37DF,p-value:
1.677e-11
#wehaveatime-seriesofTlength
T=40
#generatetwovariablesx1andx2
x1=rnorm(T,mean=1,sd=4)
x2=rnorm(T,mean=2,sd=6)
fxx=x1~x2
summary(lm(fxx))
error=rnorm(T,mean=0,sd=9)
y=1+2*x1+3*x2+error
fyx=y~x1+x2
res=lm(fyx)
summary(res)
print('printtheestimateoftheslopecoefficienttox1')
z=res$coefficient[2]
z
print('printtheestimateoftheslopecoefficienttox2')
z=res$coefficients[3]
z