R version 2.9.0 (2009-04-17) Copyright (C) 2009 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. 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(9113,9140,9309,9395,10027,10202,10003,9745,9966,10035,9999,9943,10258,10926,10807,10992,11034,10801,10161,10191,10451,10380,10251,10522,10801,10731,10161,9728,9882,9839,9917,10356,10857,10424,10721,10669,10565,10289,10646,10858,10282,10377,10443,10561,10668,10818,10865,10636,10409,10460,10579,10664,10711,11374,11345,11456,11966,12580,13006,13815,14579,14960,14904,16028,17079,15155,16049,15841,15159,14956,15645,15318,15595,16355,15925,16175,15900,15711,15594,15693,16438,17048,17699,17733,19439,20148,20112,18607,18409,18388,19187,17983,18449,19589,19135,19604,20877,23639,22830,21760,21879,21712,21321,21396,22000,22642,24272,24933,25219,25745,26433,27546,30774,32456,30124,30250,31288,31072) > 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 -3754.8 -1696.2 -743.4 1624.7 8437.5 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -1.144e+04 1.200e+03 -9.538 2.87e-16 *** x 1.207e-01 5.310e-03 22.727 < 2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 2572 on 116 degrees of freedom Multiple R-squared: 0.8166, Adjusted R-squared: 0.815 F-statistic: 516.5 on 1 and 116 DF, p-value: < 2.2e-16 > postscript(file="/var/www/html/rcomp/tmp/1wl6y1292942520.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/rcomp/tmp/2wl6y1292942520.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 -2.838e-11 -4.065e-13 7.862e-13 1.346e-12 2.764e-12 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -1.144e+04 1.750e-12 -6.538e+15 <2e-16 *** x 1.207e-01 7.747e-18 1.558e+16 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 3.753e-12 on 116 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 1 F-statistic: 2.427e+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/rcomp/tmp/3pu5j1292942520.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 -3754.8 -1696.2 -743.4 1624.7 8437.5 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.256e-13 1.200e+03 1.05e-16 1 x 0.000e+00 5.310e-03 0 1 Residual standard error: 2572 on 116 degrees of freedom Multiple R-squared: 8.658e-33, Adjusted R-squared: -0.008621 F-statistic: 1.004e-30 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/rcomp/tmp/4il541292942520.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 -9373.8 -4168.2 -193.2 4408.2 8837.7 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.529e+04 4.997e+02 30.59 <2e-16 *** m$residuals 5.909e-16 1.959e-01 3.02e-15 1 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 5428 on 116 degrees of freedom Multiple R-squared: 2.391e-31, Adjusted R-squared: -0.008621 F-statistic: 2.774e-29 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/rcomp/tmp/5aum71292942520.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 -2257.35 -349.83 -46.98 399.23 2858.81 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 33.47452 69.36145 0.483 0.63 Residuals 0.98428 0.02805 35.089 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 750 on 115 degrees of freedom (2 observations deleted due to missingness) Multiple R-squared: 0.9146, Adjusted R-squared: 0.9138 F-statistic: 1231 on 1 and 115 DF, p-value: < 2.2e-16 > abline(m5) > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/6aum71292942520.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/rcomp/tmp/7lm3s1292942520.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/rcomp/tmp/8lm3s1292942520.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/rcomp/tmp/9lm3s1292942520.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/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/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/rcomp/tmp/10an041292942520.tab") > > try(system("convert tmp/1wl6y1292942520.ps tmp/1wl6y1292942520.png",intern=TRUE)) character(0) > try(system("convert tmp/2wl6y1292942520.ps tmp/2wl6y1292942520.png",intern=TRUE)) character(0) > try(system("convert tmp/3pu5j1292942520.ps tmp/3pu5j1292942520.png",intern=TRUE)) character(0) > try(system("convert tmp/4il541292942520.ps tmp/4il541292942520.png",intern=TRUE)) character(0) > try(system("convert tmp/5aum71292942520.ps tmp/5aum71292942520.png",intern=TRUE)) character(0) > try(system("convert tmp/6aum71292942520.ps tmp/6aum71292942520.png",intern=TRUE)) character(0) > try(system("convert tmp/7lm3s1292942520.ps tmp/7lm3s1292942520.png",intern=TRUE)) character(0) > try(system("convert tmp/8lm3s1292942520.ps tmp/8lm3s1292942520.png",intern=TRUE)) character(0) > try(system("convert tmp/9lm3s1292942520.ps tmp/9lm3s1292942520.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.894 1.460 23.526