R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i686-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(56,56,54,89,40,25,92,18,63,44,33,84,88,55,60,66,154,53,119,41,61,58,75,33,40,92,100,112,73,40,45,60,62,75,31,77,34,46,99,17,66,30,76,146,67,56,107,58,34,61,119,42,66,89,44,66,24,259,17,64,41,68,168,43,132,105,71,112,94,82,70,57,53,103,121,62,52,52,32,62,45,46,63,75,88,46,53,37,90,63,78,25,45,46,41,144,82,91,71,63,53,62,63,32,39,62,117,34,92,93,54,144,14,61,109,38,73,75,50,61,55,77,75,72,50,32,53,42,71,10,35,65,25,66,41,86,16,42,19,19,45,65,35,95,49,37,64,38,34,32,65,52,62,65,83,95,29,18,33,247,139,29,118,110,67,42,65,94,64,81,95,67,63,83,45,30,70,32,83,31,67,66,10,70,103,5,20,5,36,34,48,40,43,31,42,46,33,18,55,35,59,19,66,60,36,25,47,54,53,40,40,39,14,45,36,28,44,30,22,17,31,55,54,21,14,81,35,43,46,30,23,38,54,20,53,45,39,20,24,31,35,151,52,30,31,29,57,40,44,25,77,35,11,63,44,19,13,42,38,29,20,27,20,19,37,26,42,49,30,49,67,28,19,49,27,30,22,12,31,20,20,39,29,16,27,21,19,35,14) > x <- c(210907 + ,120982 + ,176508 + ,179321 + ,123185 + ,52746 + ,385534 + ,33170 + ,101645 + ,149061 + ,165446 + ,237213 + ,173326 + ,133131 + ,258873 + ,180083 + ,324799 + ,230964 + ,236785 + ,135473 + ,202925 + ,215147 + ,344297 + ,153935 + ,132943 + ,174724 + ,174415 + ,225548 + ,223632 + ,124817 + ,221698 + ,210767 + ,170266 + ,260561 + ,84853 + ,294424 + ,101011 + ,215641 + ,325107 + ,7176 + ,167542 + ,106408 + ,96560 + ,265769 + ,269651 + ,149112 + ,175824 + ,152871 + ,111665 + ,116408 + ,362301 + ,78800 + ,183167 + ,277965 + ,150629 + ,168809 + ,24188 + ,329267 + ,65029 + ,101097 + ,218946 + ,244052 + ,341570 + ,103597 + ,233328 + ,256462 + ,206161 + ,311473 + ,235800 + ,177939 + ,207176 + ,196553 + ,174184 + ,143246 + ,187559 + ,187681 + ,119016 + ,182192 + ,73566 + ,194979 + ,167488 + ,143756 + ,275541 + ,243199 + ,182999 + ,135649 + ,152299 + ,120221 + ,346485 + ,145790 + ,193339 + ,80953 + ,122774 + ,130585 + ,112611 + ,286468 + ,241066 + ,148446 + ,204713 + ,182079 + ,140344 + ,220516 + ,243060 + ,162765 + ,182613 + ,232138 + ,265318 + ,85574 + ,310839 + ,225060 + ,232317 + ,144966 + ,43287 + ,155754 + ,164709 + ,201940 + ,235454 + ,220801 + ,99466 + ,92661 + ,133328 + ,61361 + ,125930 + ,100750 + ,224549 + ,82316 + ,102010 + ,101523 + ,243511 + ,22938 + ,41566 + ,152474 + ,61857 + ,99923 + ,132487 + ,317394 + ,21054 + ,209641 + ,22648 + ,31414 + ,46698 + ,131698 + ,91735 + ,244749 + ,184510 + ,79863 + ,128423 + ,97839 + ,38214 + ,151101 + ,272458 + ,172494 + ,108043 + ,328107 + ,250579 + ,351067 + ,158015 + ,98866 + ,85439 + ,229242 + ,351619 + ,84207 + ,120445 + ,324598 + ,131069 + ,204271 + ,165543 + ,141722 + ,116048 + ,250047 + ,299775 + ,195838 + ,173260 + ,254488 + ,104389 + ,136084 + ,199476 + ,92499 + ,224330 + ,135781 + ,74408 + ,81240 + ,14688 + ,181633 + ,271856 + ,7199 + ,46660 + ,17547 + ,133368 + ,95227 + ,152601 + ,98146 + ,79619 + ,59194 + ,139942 + ,118612 + ,72880 + ,65475 + ,99643 + ,71965 + ,77272 + ,49289 + ,135131 + ,108446 + ,89746 + ,44296 + ,77648 + ,181528 + ,134019 + ,124064 + ,92630 + ,121848 + ,52915 + ,81872 + ,58981 + ,53515 + ,60812 + ,56375 + ,65490 + ,80949 + ,76302 + ,104011 + ,98104 + ,67989 + ,30989 + ,135458 + ,73504 + ,63123 + ,61254 + ,74914 + ,31774 + ,81437 + ,87186 + ,50090 + ,65745 + ,56653 + ,158399 + ,46455 + ,73624 + ,38395 + ,91899 + ,139526 + ,52164 + ,51567 + ,70551 + ,84856 + ,102538 + ,86678 + ,85709 + ,34662 + ,150580 + ,99611 + ,19349 + ,99373 + ,86230 + ,30837 + ,31706 + ,89806 + ,62088 + ,40151 + ,27634 + ,76990 + ,37460 + ,54157 + ,49862 + ,84337 + ,64175 + ,59382 + ,119308 + ,76702 + ,103425 + ,70344 + ,43410 + ,104838 + ,62215 + ,69304 + ,53117 + ,19764 + ,86680 + ,84105 + ,77945 + ,89113 + ,91005 + ,40248 + ,64187 + ,50857 + ,56613 + ,62792 + ,72535) > 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 -45.834 -12.006 -4.405 8.542 165.282 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.420e+01 2.724e+00 5.214 3.54e-07 *** x 2.945e-04 1.695e-05 17.374 < 2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 23.69 on 287 degrees of freedom Multiple R-squared: 0.5126, Adjusted R-squared: 0.5109 F-statistic: 301.8 on 1 and 287 DF, p-value: < 2.2e-16 > postscript(file="/var/fisher/rcomp/tmp/1e5o71354452934.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/fisher/rcomp/tmp/2bqe91354452934.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 -1.631e-14 -2.287e-15 -1.787e-16 1.771e-15 2.027e-14 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.420e+01 4.840e-16 2.934e+16 <2e-16 *** x 2.945e-04 3.012e-21 9.777e+16 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 4.209e-15 on 287 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 1 F-statistic: 9.56e+33 on 1 and 287 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/fisher/rcomp/tmp/3zo291354452934.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 -45.834 -12.006 -4.405 8.542 165.282 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 3.922e-16 2.724e+00 0 1 x -1.434e-21 1.695e-05 0 1 Residual standard error: 23.69 on 287 degrees of freedom Multiple R-squared: 1.745e-34, Adjusted R-squared: -0.003484 F-statistic: 5.009e-32 on 1 and 287 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/fisher/rcomp/tmp/4w8ya1354452934.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 -38.555 -18.605 -5.038 14.570 72.875 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 5.487e+01 1.429e+00 38.4 <2e-16 *** m$residuals 4.560e-17 6.054e-02 0.0 1 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 24.29 on 287 degrees of freedom Multiple R-squared: 1.938e-32, Adjusted R-squared: -0.003484 F-statistic: 5.561e-30 on 1 and 287 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/fisher/rcomp/tmp/5u3z51354452934.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 -46.504 -11.781 -4.463 8.599 165.455 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.06773 1.39542 0.049 0.961 Residuals 0.03769 0.05910 0.638 0.524 Residual standard error: 23.68 on 286 degrees of freedom (2 observations deleted due to missingness) Multiple R-squared: 0.00142, Adjusted R-squared: -0.002072 F-statistic: 0.4067 on 1 and 286 DF, p-value: 0.5242 > abline(m5) > grid() > dev.off() null device 1 > postscript(file="/var/fisher/rcomp/tmp/61uyg1354452934.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/fisher/rcomp/tmp/771qk1354452935.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/fisher/rcomp/tmp/8mt2d1354452935.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/fisher/rcomp/tmp/9owcn1354452935.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/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/fisher/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/fisher/rcomp/tmp/10cbg11354452935.tab") > > try(system("convert tmp/1e5o71354452934.ps tmp/1e5o71354452934.png",intern=TRUE)) character(0) > try(system("convert tmp/2bqe91354452934.ps tmp/2bqe91354452934.png",intern=TRUE)) character(0) > try(system("convert tmp/3zo291354452934.ps tmp/3zo291354452934.png",intern=TRUE)) character(0) > try(system("convert tmp/4w8ya1354452934.ps tmp/4w8ya1354452934.png",intern=TRUE)) character(0) > try(system("convert tmp/5u3z51354452934.ps tmp/5u3z51354452934.png",intern=TRUE)) character(0) > try(system("convert tmp/61uyg1354452934.ps tmp/61uyg1354452934.png",intern=TRUE)) character(0) > try(system("convert tmp/771qk1354452935.ps tmp/771qk1354452935.png",intern=TRUE)) character(0) > try(system("convert tmp/8mt2d1354452935.ps tmp/8mt2d1354452935.png",intern=TRUE)) character(0) > try(system("convert tmp/9owcn1354452935.ps tmp/9owcn1354452935.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 5.266 1.180 6.443