1、R Assignment 2Sep 23ContCall:lm(formula = fyx)Residuals: Min 1Q Median 3Q Max -16.343 -6.270 -1.286 5.528 22.403 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 2.0799 1.6316 1.275 0.210 x1 2.0348 0.3571 5.698 1.61e-06 *x2 2.8276 0.2525 11.199 1.92e-13 *-Signif. codes: 0 * 0.001 * 0.01
2、 * 0.05 . 0.1 1 Residual standard error: 9.5 on 37 degrees of freedomMultiple R-squared: 0.8137, Adjusted R-squared: 0.8037 F-statistic: 80.83 on 2 and 37 DF, p-value: 3.14e-14 error=rnorm(T,mean=0,sd=9) y=1+2*x1+3*x2+error fyx=yx1+x2 res=lm(fyx) summary(res)Call:lm(formula = fyx)Residuals: Min 1Q M
3、edian 3Q Max -14.4131 -5.1388 -0.5028 5.2936 25.1226 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 2.6955 1.5279 1.764 0.086 . x1 1.5191 0.3344 4.542 5.74e-05 *x2 2.6684 0.2365 11.285 1.54e-13 *-Signif. codes: 0 * 0.001 * 0.01 * 0.05 . 0.1 1 Residual standard error: 8.896 on 37 degre
4、es of freedomMultiple R-squared: 0.8032, Adjusted R-squared: 0.7926 F-statistic: 75.52 on 2 and 37 DF, p-value: 8.675e-14 error=rnorm(T,mean=0,sd=9) y=1+2*x1+3*x2+error fyx=yx1+x2 res=lm(fyx) summary(res)Call:lm(formula = fyx)Residuals: Min 1Q Median 3Q Max -18.8149 -4.5776 -0.6625 5.8645 14.0127 Co
5、efficients: Estimate Std. Error t value Pr(|t|) (Intercept) 2.4013 1.2897 1.862 0.0706 . x1 2.5685 0.2823 9.099 5.64e-11 *x2 2.7701 0.1996 13.879 3.05e-16 *-Signif. codes: 0 * 0.001 * 0.01 * 0.05 . 0.1 1 Residual standard error: 7.509 on 37 degrees of freedomMultiple R-squared: 0.8843, Adjusted R-sq
6、uared: 0.8781 F-statistic: 141.4 on 2 and 37 DF, p-value: error=rnorm(T,mean=0,sd=9) y=1+2*x1+3*x2+error fyx=yx1+x2 res=lm(fyx) summary(res)Call:lm(formula = fyx)Residuals: Min 1Q Median 3Q Max -16.8775 -6.3727 0.9687 4.9780 15.7572 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 2.901
7、9 1.4250 2.036 0.0489 * x1 2.0697 0.3119 6.636 8.7e-08 *x2 3.0972 0.2205 14.044 2e-16 *-Signif. codes: 0 * 0.001 * 0.01 * 0.05 . 0.1 1 Residual standard error: 8.297 on 37 degrees of freedomMultiple R-squared: 0.8696, Adjusted R-squared: 0.8626 F-statistic: 123.4 on 2 and 37 DF, p-value: error=rnorm
8、(T,mean=0,sd=9) y=1+2*x1+3*x2+error fyx=yx1+x2 res=lm(fyx) summary(res)Call:lm(formula = fyx)Residuals: Min 1Q Median 3Q Max -18.624 -5.443 1.245 4.215 15.054 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 0.2433 1.5313 0.159 0.875 x1 2.0758 0.3351 6.194 3.43e-07 *x2 2.9857 0.2370 12.
9、599 5.93e-15 *-Signif. codes: 0 * 0.001 * 0.01 * 0.05 . 0.1 1 Residual standard error: 8.916 on 37 degrees of freedomMultiple R-squared: 0.845, Adjusted R-squared: 0.8366 F-statistic: 100.9 on 2 and 37 DF, p-value: 1.048e-15 error=rnorm(T,mean=0,sd=9) y=1+2*x1+3*x2+error fyx=yx1+x2 res=lm(fyx) summa
10、ry(res)Call:lm(formula = fyx)Residuals: Min 1Q Median 3Q Max -21.6102 -6.7581 -0.2067 6.6139 21.4020 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 2.4938 1.6552 1.507 0.140 x1 1.8654 0.3623 5.149 8.89e-06 *x2 2.7845 0.2562 10.870 4.49e-13 *-Signif. codes: 0 * 0.001 * 0.01 * 0.05 . 0.
11、1 1 Residual standard error: 9.637 on 37 degrees of freedomMultiple R-squared: 0.8, Adjusted R-squared: 0.7892 F-statistic: 74 on 2 and 37 DF, p-value: 1.172e-13 error=rnorm(T,mean=0,sd=9) y=1+2*x1+3*x2+error fyx=yx1+x2 res=lm(fyx) summary(res)Call:lm(formula = fyx)Residuals: Min 1Q Median 3Q Max -1
12、6.906 -6.483 1.590 5.685 15.206 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 3.5358 1.4448 2.447 0.0193 * x1 1.9119 0.3162 6.046 5.44e-07 *x2 2.9482 0.2236 13.186 1.49e-15 *-Signif. codes: 0 * 0.001 * 0.01 * 0.05 . 0.1 1 Residual standard error: 8.412 on 37 degrees of freedomMultipl
13、e R-squared: 0.8533, Adjusted R-squared: 0.8453 F-statistic: 107.6 on 2 and 37 DF, p-value: 3.811e-16 error=rnorm(T,mean=0,sd=9) y=1+2*x1+3*x2+error fyx=yx1+x2 res=lm(fyx) summary(res)Call:lm(formula = fyx)Residuals: Min 1Q Median 3Q Max -16.4157 -7.8264 -0.4064 8.5649 21.5937 Coefficients: Estimate
14、 Std. Error t value Pr(|t|) (Intercept) 1.6498 1.5899 1.038 0.306 x1 2.0010 0.3480 5.750 1.37e-06 *x2 3.4090 0.2461 13.855 3.22e-16 *-Signif. codes: 0 * 0.001 * 0.01 * 0.05 . 0.1 1 Residual standard error: 9.257 on 37 degrees of freedomMultiple R-squared: 0.8613, Adjusted R-squared: 0.8538 F-statist
15、ic: 114.9 on 2 and 37 DF, p-value: error=rnorm(T,mean=0,sd=9) y=1+2*x1+3*x2+error fyx=yx1+x2 res=lm(fyx) summary(res)Call:lm(formula = fyx)Residuals: Min 1Q Median 3Q Max -17.4926 -4.3796 -0.9567 3.8140 20.7822 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 0.2239 1.5267 0.147 0.884 x
16、1 2.4544 0.3342 7.345 9.88e-09 *x2 3.0090 0.2363 12.735 4.29e-15 *-Signif. codes: 0 * 0.001 * 0.01 * 0.05 . 0.1 1 Residual standard error: 8.89 on 37 degrees of freedomMultiple R-squared: 0.857, Adjusted R-squared: 0.8492 F-statistic: 110.8 on 2 and 37 DF, p-value: 2.378e-16 error=rnorm(T,mean=0,sd=
17、9) y=1+2*x1+3*x2+error fyx=yx1+x2 res=lm(fyx) summary(res)Call:lm(formula = fyx)Residuals: Min 1Q Median 3Q Max -25.568 -7.706 2.529 6.132 20.302 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 2.8579 1.7716 1.613 0.11520 x1 1.4179 0.3877 3.657 0.00079 *x2 2.5870 0.2742 9.436 2.18e-11
18、*-Signif. codes: 0 * 0.001 * 0.01 * 0.05 . 0.1 1 Residual standard error: 10.32 on 37 degrees of freedomMultiple R-squared: 0.7385, Adjusted R-squared: 0.7243 F-statistic: 52.23 on 2 and 37 DF, p-value: 1.677e-11 #we have a time-series of T lengthT=40#generate two variables x1 and x2x1=rnorm(T,mean=1,sd=4)x2=rnorm(T,mean=2,sd=6)fxx=x1x2summary(lm(fxx)error=rnorm(T,mean=0,sd=9)y=1+2*x1+3*x2+errorfyx=yx1+x2res=lm(fyx)summary(res)print(print the estimate of the slope coefficient to x1)z=res$coefficient2zprint(print the estimate of the slope coefficient to x2)z=res$coefficients3z
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1