R version 2.8.0 (2008-10-20) Copyright (C) 2008 The R Foundation for Statistical Computing ISBN 3-900051-07-0 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. Natural language support but running in an English locale 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(829461,837669,854793,850092,848783,846150,828543,830389,848989,841106,854616,832714,839290,840572,869186,856979,872126,868281,862455,881177,886924,886842,916407,890606,900409,920169,922871,920004,945772,937507,941691,958256,963509,970266,972853,982168,999892,1002099,1017611,1029782,1047956,1047689,1060054,1067078,1072366,1081823,1087601,1089905,1116316,1111355,1124250,1140597,1151683,1137532,967532,972994,999207,1007982,1015892,994850,987503,986743,1020674,1024067,1040444,1019081,1027828,1021010,1025563,1044756,1062545,1070425,1100087,1093596,1109143,1113855,1129275,1131996,1144103,1167830,1153194,1175008,1175805,1173456,1187498,1202958,1206229,1249533,1279743,1283496,1282942,1284739,1337169,1314087,1306144,1200391,1265445,1259329,1219342,1227626,1232874,1241046,1244172,1237838,1212801,1234237,1224699,1237432,1248847,1256543,1252434,1265176,1314670,1299329,1216744,1225275,1193478,1207226) > x <- c(143827,145191,146832,148577,149873,151847,153252,154292,155657,156523,156416,156693,160312,160438,160882,161668,164391,168556,169738,170387,171294,172202,172651,172770,178366,180014,181067,182586,184957,186417,188599,189490,190264,191221,191110,190674,195438,196393,197172,198760,200945,203845,204613,205487,206100,206315,206291,207801,211653,211325,211893,212056,214696,217455,218884,219816,219984,219062,218550,218179,222218,222196,223393,223292,226236,228831,228745,229140,229270,229359,230006,228810,232677,232961,234629,235660,240024,243554,244368,244356,245126,246321,246797,246735,251083,251786,252732,255051,259022,261698,263891,265247,262228,263429,264305,266371,273248,275472,278146,279506,283991,286794,288703,289285,288869,286942,285833,284095,289229,289389,290793,291454,294733,293853,294056,293982,293075,292391) > par1 = '0' > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description (don't use hard returns!) > 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 -95842 -29824 -6880 29512 144406 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 3.719e+05 2.356e+04 15.79 <2e-16 *** x 3.130e+00 1.043e-01 30.02 <2e-16 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 50510 on 116 degrees of freedom Multiple R-squared: 0.886, Adjusted R-squared: 0.885 F-statistic: 901.5 on 1 and 116 DF, p-value: < 2.2e-16 > postscript(file="/var/www/html/freestat/rcomp/tmp/1wt0k1292941830.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/www/html/freestat/rcomp/tmp/2wt0k1292941830.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.235e-10 -5.812e-11 -1.188e-11 3.964e-11 1.161e-09 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 3.719e+05 5.780e-11 6.435e+15 <2e-16 *** x 3.130e+00 2.558e-16 1.224e+16 <2e-16 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 1.239e-10 on 116 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 1 F-statistic: 1.497e+32 on 1 and 116 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/www/html/freestat/rcomp/tmp/372zn1292941830.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 -95842 -29824 -6880 29512 144406 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.455e-12 2.356e+04 6.18e-17 1 x -4.354e-18 1.043e-01 -4.18e-17 1 Residual standard error: 50510 on 116 degrees of freedom Multiple R-squared: 1.193e-33, Adjusted R-squared: -0.008621 F-statistic: 1.383e-31 on 1 and 116 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/www/html/freestat/rcomp/tmp/45fof1292941830.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 -243134 -108112 -5012 114340 229229 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.065e+06 1.296e+04 82.19 <2e-16 *** m$residuals 1.103e-16 2.588e-01 4.26e-16 1 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 140800 on 116 degrees of freedom Multiple R-squared: 1.249e-30, Adjusted R-squared: -0.008621 F-statistic: 1.449e-28 on 1 and 116 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/www/html/freestat/rcomp/tmp/55fof1292941830.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 -162999 -7877 3564 11811 73050 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -658.8399 2367.8894 -0.278 0.781 Residuals 0.8726 0.0476 18.332 <2e-16 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 25610 on 115 degrees of freedom (2 observations deleted due to missingness) Multiple R-squared: 0.745, Adjusted R-squared: 0.7428 F-statistic: 336.1 on 1 and 115 DF, p-value: < 2.2e-16 > abline(m5) > grid() > dev.off() null device 1 > postscript(file="/var/www/html/freestat/rcomp/tmp/6blgb1292941830.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/www/html/freestat/rcomp/tmp/7blgb1292941830.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/www/html/freestat/rcomp/tmp/83ufw1292941830.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/www/html/freestat/rcomp/tmp/93ufw1292941830.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/www/html/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/freestat/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/www/html/freestat/rcomp/tmp/10h4d51292941830.tab") > > try(system("convert tmp/1wt0k1292941830.ps tmp/1wt0k1292941830.png",intern=TRUE)) character(0) > try(system("convert tmp/2wt0k1292941830.ps tmp/2wt0k1292941830.png",intern=TRUE)) character(0) > try(system("convert tmp/372zn1292941830.ps tmp/372zn1292941830.png",intern=TRUE)) character(0) > try(system("convert tmp/45fof1292941830.ps tmp/45fof1292941830.png",intern=TRUE)) character(0) > try(system("convert tmp/55fof1292941830.ps tmp/55fof1292941830.png",intern=TRUE)) character(0) > try(system("convert tmp/6blgb1292941830.ps tmp/6blgb1292941830.png",intern=TRUE)) character(0) > try(system("convert tmp/7blgb1292941830.ps tmp/7blgb1292941830.png",intern=TRUE)) character(0) > try(system("convert tmp/83ufw1292941830.ps tmp/83ufw1292941830.png",intern=TRUE)) character(0) > try(system("convert tmp/93ufw1292941830.ps tmp/93ufw1292941830.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.914 2.117 3.191