R version 2.13.0 (2011-04-13) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-pc-linux-gnu (32-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > y <- c(3035 + ,2932 + ,2852 + ,2830 + ,2850 + ,2881 + ,2934 + ,2959 + ,2952 + ,3019 + ,3019 + ,3036 + ,3100 + ,3178 + ,3184 + ,3312 + ,3335 + ,3352 + ,3358 + ,3277 + ,3352 + ,3313 + ,3352 + ,3358 + ,3251 + ,3223 + ,3239 + ,3272 + ,3397 + ,3374 + ,3400 + ,3410 + ,3463 + ,3482 + ,3546 + ,3546 + ,3633 + ,3661 + ,3684 + ,3698 + ,3757 + ,3660 + ,3701 + ,3774 + ,3697 + ,3721 + ,3703 + ,3585 + ,3490 + ,3460 + ,3431 + ,3294 + ,3233 + ,3282 + ,3127 + ,3189 + ,3263 + ,3251 + ,3203 + ,3242 + ,3248 + ,3057 + ,2987 + ,2952 + ,3011 + ,3020 + ,2975 + ,2999 + ,2987 + ,2974 + ,3022 + ,3053 + ,3066 + ,3125 + ,3239 + ,3127 + ,3117 + ,3131 + ,3130 + ,3130 + ,3128 + ,3131 + ,3206 + ,3330 + ,3390 + ,3353 + ,3271 + ,3236 + ,3087 + ,3137 + ,3143 + ,3135 + ,3115 + ,3035 + ,3000 + ,3006 + ,2980 + ,2995 + ,2979 + ,2902 + ,2865 + ,2884 + ,2962 + ,3010 + ,3010 + ,2973 + ,2999 + ,2953 + ,2904 + ,2878 + ,2863 + ,2891 + ,2927 + ,2980 + ,2997 + ,3001 + ,3014 + ,2987 + ,2914 + ,2917 + ,2967 + ,3027 + ,3040 + ,2986 + ,2967 + ,2995 + ,3018 + ,3114 + ,3170 + ,3170 + ,3142 + ,3228 + ,3202 + ,3194 + ,3099 + ,3058 + ,3076 + ,3180 + ,3166 + ,3168 + ,3186 + ,3187 + ,3207 + ,3194 + ,3093 + ,3025 + ,3047 + ,3073 + ,3011 + ,3008 + ,2989 + ,2965 + ,2952 + ,2941 + ,2975 + ,2945 + ,2943 + ,2871 + ,2871 + ,2943 + ,2871 + ,2943 + ,2871 + ,2871 + ,2943 + ,2871 + ,2943 + ,2871 + ,2871 + ,2943 + ,2871 + ,2943 + ,2871 + ,3060 + ,3067 + ,3092 + ,3067 + ,3092 + ,3092 + ,3067 + ,3092 + ,3067 + ,3092 + ,3092 + ,2792 + ,2716 + ,2730 + ,2727 + ,2680 + ,2634 + ,2678 + ,2721 + ,2664 + ,2694 + ,2608 + ,2575 + ,2592 + ,2622 + ,2660 + ,2562 + ,2684 + ,2632 + ,2659 + ,2658 + ,2700 + ,2650 + ,2610 + ,2644 + ,2607 + ,2611 + ,2670 + ,2683 + ,2727 + ,2779 + ,2770 + ,2723) > x <- c(93.09 + ,94.84 + ,93.53 + ,95.5 + ,94.52 + ,95.33 + ,97.45 + ,98.2 + ,97.7 + ,98.68 + ,97.43 + ,97.8 + ,98.1 + ,96.86 + ,97.72 + ,96.63 + ,95.27 + ,97.66 + ,97.72 + ,99.42 + ,101.59 + ,101.93 + ,102.01 + ,103.13 + ,102.2 + ,99.08 + ,100.52 + ,102.01 + ,101.7 + ,101 + ,103.06 + ,101.45 + ,103.24 + ,102.24 + ,102.71 + ,105.74 + ,106.06 + ,110.89 + ,112.06 + ,111.78 + ,111.88 + ,114.88 + ,116.65 + ,114.53 + ,115.89 + ,115.53 + ,113.3 + ,115.7 + ,115.79 + ,113.71 + ,113.67 + ,108.52 + ,111.05 + ,114.9 + ,113.93 + ,114.96 + ,114.96 + ,115.7 + ,115.72 + ,115.59 + ,115.1 + ,115.27 + ,115.17 + ,115.17 + ,115.27 + ,115.17 + ,115.27 + ,115.17 + ,122.3 + ,122.67 + ,126.65 + ,123.98 + ,122.88 + ,122.36 + ,123.45 + ,121.61 + ,121.33 + ,123.85 + ,123.99 + ,124.04 + ,123.66 + ,124.14 + ,125.13 + ,125.02 + ,125.89 + ,125.12 + ,122.45 + ,121.19 + ,110.8 + ,109.13 + ,115.9 + ,117.63 + ,112.57 + ,112.98 + ,113.83 + ,112.73 + ,109.99 + ,112.3 + ,111.42 + ,112.39 + ,110.1 + ,112.53 + ,114.93 + ,115.05 + ,115.03 + ,114.68 + ,116.63 + ,114.53 + ,115.54 + ,115.84 + ,114.48 + ,116.78 + ,117.85 + ,119.57 + ,118.78 + ,119.1 + ,120.16 + ,113.01 + ,114.02 + ,113.21 + ,111.69 + ,112.1 + ,114.21 + ,107.26 + ,105.12 + ,105.99 + ,108.78 + ,112.4 + ,112.48 + ,117.77 + ,111.39 + ,113.61 + ,113.62 + ,118.59 + ,118.33 + ,117.03 + ,117.75 + ,118.78 + ,118.32 + ,117.26 + ,116.05 + ,117.06 + ,118.15 + ,117.51 + ,118.67 + ,117.94 + ,118.28 + ,117.43 + ,117.36 + ,116.74 + ,116.81 + ,116.46 + ,113.23 + ,107.25 + ,109.37 + ,103.74 + ,102.57 + ,106.68 + ,108.02 + ,108.03 + ,109.91 + ,109.47 + ,110.6 + ,106.99 + ,108.62 + ,108.11 + ,108.36 + ,109.31 + ,110.69 + ,111.36 + ,111.88 + ,114.02 + ,114.85 + ,114.29 + ,112.33 + ,110.08 + ,112.89 + ,115.69 + ,114.55 + ,112.77 + ,112.25 + ,111.89 + ,112.4 + ,115.34 + ,112.22 + ,109.14 + ,110.54 + ,110.36 + ,105.49 + ,103.97 + ,103.94 + ,107.14 + ,103.81 + ,103.95 + ,102.76 + ,101.71 + ,99.79 + ,102.73 + ,105.73 + ,105.88 + ,108.95 + ,111.12 + ,111.36 + ,111.11 + ,114.68 + ,110.16 + ,111.15 + ,108.39 + ,109.76 + ,109.56 + ,109.56 + ,111.45 + ,108.91 + ,112.08 + ,109.91 + ,109.56) > par1 = '0' > par1 <- as.numeric(par1) > library(lattice) > z <- as.data.frame(cbind(x,y)) > m <- lm(y~x) > summary(m) Call: lm(formula = y ~ x) Residuals: Min 1Q Median 3Q Max -476.04 -137.80 -41.14 116.03 697.44 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 2566.581 265.386 9.671 <2e-16 *** x 4.453 2.381 1.870 0.0628 . --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 258.4 on 214 degrees of freedom Multiple R-squared: 0.01609, Adjusted R-squared: 0.01149 F-statistic: 3.499 on 1 and 214 DF, p-value: 0.06278 > postscript(file="/var/wessaorg/rcomp/tmp/1ql791321396704.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(z,main='Scatterplot, lowess, and regression line') > lines(lowess(z),col='red') > abline(m) > grid() > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/2mtc91321396704.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > m2 <- lm(m$fitted.values ~ x) > summary(m2) Call: lm(formula = m$fitted.values ~ x) Residuals: Min 1Q Median 3Q Max -3.246e-13 -1.131e-13 -1.740e-14 8.020e-14 4.472e-12 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 2.567e+03 3.409e-13 7.529e+15 <2e-16 *** x 4.453e+00 3.058e-15 1.456e+15 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 3.319e-13 on 214 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 1 F-statistic: 2.121e+30 on 1 and 214 DF, p-value: < 2.2e-16 > z2 <- as.data.frame(cbind(x,m$fitted.values)) > names(z2) <- list('x','Fitted') > plot(z2,main='Scatterplot, lowess, and regression line') > lines(lowess(z2),col='red') > abline(m2) > grid() > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/37q1k1321396704.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > m3 <- lm(m$residuals ~ x) > summary(m3) Call: lm(formula = m$residuals ~ x) Residuals: Min 1Q Median 3Q Max -476.04 -137.80 -41.14 116.03 697.44 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 2.059e-14 2.654e+02 0 1 x -1.753e-16 2.381e+00 0 1 Residual standard error: 258.4 on 214 degrees of freedom Multiple R-squared: 3.4e-35, Adjusted R-squared: -0.004673 F-statistic: 7.277e-33 on 1 and 214 DF, p-value: 1 > z3 <- as.data.frame(cbind(x,m$residuals)) > names(z3) <- list('x','Residuals') > plot(z3,main='Scatterplot, lowess, and regression line') > lines(lowess(z3),col='red') > abline(m3) > grid() > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/48c1w1321396704.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > m4 <- lm(m$fitted.values ~ m$residuals) > summary(m4) Call: lm(formula = m$fitted.values ~ m$residuals) Residuals: Min 1Q Median 3Q Max -80.798 -18.403 4.807 19.902 68.638 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 3.062e+03 2.248e+00 1362 <2e-16 *** m$residuals 3.321e-17 8.741e-03 0 1 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 33.04 on 214 degrees of freedom Multiple R-squared: 1.416e-28, Adjusted R-squared: -0.004673 F-statistic: 3.031e-26 on 1 and 214 DF, p-value: 1 > z4 <- as.data.frame(cbind(m$residuals,m$fitted.values)) > names(z4) <- list('Residuals','Fitted') > plot(z4,main='Scatterplot, lowess, and regression line') > lines(lowess(z4),col='red') > abline(m4) > grid() > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/5gax81321396704.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > myr <- as.ts(m$residuals) > z5 <- as.data.frame(cbind(lag(myr,1),myr)) > names(z5) <- list('Lagged Residuals','Residuals') > plot(z5,main='Lag plot') > m5 <- lm(z5) > summary(m5) Call: lm(formula = z5) Residuals: Min 1Q Median 3Q Max -284.093 -31.133 4.757 31.535 188.781 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -1.75896 3.94715 -0.446 0.656 Residuals 0.97839 0.01537 63.654 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 57.88 on 213 degrees of freedom (2 observations deleted due to missingness) Multiple R-squared: 0.9501, Adjusted R-squared: 0.9498 F-statistic: 4052 on 1 and 213 DF, p-value: < 2.2e-16 > abline(m5) > grid() > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/6qbbk1321396704.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > hist(m$residuals,main='Residual Histogram',xlab='Residuals') > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/71fc71321396704.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > if (par1 > 0) + { + densityplot(~m$residuals,col='black',main=paste('Density Plot bw = ',par1),bw=par1) + } else { + densityplot(~m$residuals,col='black',main='Density Plot') + } > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/8ueok1321396704.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > acf(m$residuals,main='Residual Autocorrelation Function') > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/90wum1321396704.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > qqnorm(x) > qqline(x) > grid() > dev.off() null device 1 > > #Note: the /var/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/rcomp/createtable") > > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Simple Linear Regression',5,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Statistics',1,TRUE) > a<-table.element(a,'Estimate',1,TRUE) > a<-table.element(a,'S.D.',1,TRUE) > a<-table.element(a,'T-STAT (H0: coeff=0)',1,TRUE) > a<-table.element(a,'P-value (two-sided)',1,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'constant term',header=TRUE) > a<-table.element(a,m$coefficients[[1]]) > sd <- sqrt(vcov(m)[1,1]) > a<-table.element(a,sd) > tstat <- m$coefficients[[1]]/sd > a<-table.element(a,tstat) > pval <- 2*(1-pt(abs(tstat),length(x)-2)) > a<-table.element(a,pval) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'slope',header=TRUE) > a<-table.element(a,m$coefficients[[2]]) > sd <- sqrt(vcov(m)[2,2]) > a<-table.element(a,sd) > tstat <- m$coefficients[[2]]/sd > a<-table.element(a,tstat) > pval <- 2*(1-pt(abs(tstat),length(x)-2)) > a<-table.element(a,pval) > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/wessaorg/rcomp/tmp/10p7vx1321396704.tab") > > try(system("convert tmp/1ql791321396704.ps tmp/1ql791321396704.png",intern=TRUE)) character(0) > try(system("convert tmp/2mtc91321396704.ps tmp/2mtc91321396704.png",intern=TRUE)) character(0) > try(system("convert tmp/37q1k1321396704.ps tmp/37q1k1321396704.png",intern=TRUE)) character(0) > try(system("convert tmp/48c1w1321396704.ps tmp/48c1w1321396704.png",intern=TRUE)) character(0) > try(system("convert tmp/5gax81321396704.ps tmp/5gax81321396704.png",intern=TRUE)) character(0) > try(system("convert tmp/6qbbk1321396704.ps tmp/6qbbk1321396704.png",intern=TRUE)) character(0) > try(system("convert tmp/71fc71321396704.ps tmp/71fc71321396704.png",intern=TRUE)) character(0) > try(system("convert tmp/8ueok1321396704.ps tmp/8ueok1321396704.png",intern=TRUE)) character(0) > try(system("convert tmp/90wum1321396704.ps tmp/90wum1321396704.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.729 0.498 3.308