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. 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(180144,173666,165688,161570,156145,153730,182698,200765,176512,166618,158644,159585,163095,159044,155511,153745,150569,150605,179612,194690,189917,184128,175335,179566,181140,177876,175041,169292,166070,166972,206348,215706,202108,195411,193111,195198,198770,194163,190420,189733,186029,191531,232571,243477,227247,217859,208679,213188,216234,213586,209465,204045,200237,203666,241476,260307,243324,244460,233575,237217,235243,230354,227184,221678,217142,219452,256446,265845,248624,241114,229245,231805,219277,219313,212610,214771,211142,211457,240048,240636,230580,208795,197922,194596) > x <- c(11554.5,13182.1,14800.1,12150.7,14478.2,13253.9,12036.8,12653.2,14035.4,14571.4,15400.9,14283.2,14485.3,14196.3,15559.1,13767.4,14634,14381.1,12509.9,12122.3,13122.3,13908.7,13456.5,12441.6,12953,13057.2,14350.1,13830.2,13755.5,13574.4,12802.6,11737.3,13850.2,15081.8,13653.3,14019.1,13962,13768.7,14747.1,13858.1,13188,13693.1,12970,11392.8,13985.2,14994.7,13584.7,14257.8,13553.4,14007.3,16535.8,14721.4,13664.6,16805.9,13829.4,13735.6,15870.5,15962.4,15744.1,16083.7,14863.9,15533.1,17473.1,15925.5,15573.7,17495,14155.8,14913.9,17250.4,15879.8,17647.8,17749.9,17111.8,16934.8,20280,16238.2,17896.1,18089.3,15660,16162.4,17850.1,18520.4,18524.7,16843.7) > 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 -50771 -19030 -2340 15019 64384 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.179e+05 2.476e+04 4.761 8.17e-06 *** x 5.681e+00 1.666e+00 3.410 0.00101 ** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 27730 on 82 degrees of freedom Multiple R-squared: 0.1242, Adjusted R-squared: 0.1135 F-statistic: 11.63 on 1 and 82 DF, p-value: 0.001009 > postscript(file="/var/www/html/rcomp/tmp/1e2v91229279153.ps",horizontal=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/2wb0w1229279153.ps",horizontal=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.693e-11 -9.919e-12 -3.691e-12 2.004e-12 3.108e-10 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.179e+05 3.218e-11 3.663e+15 <2e-16 *** x 5.681e+00 2.165e-15 2.624e+15 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 3.605e-11 on 82 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 1 F-statistic: 6.883e+30 on 1 and 82 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/3xqql1229279153.ps",horizontal=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 -50771 -19030 -2340 15019 64384 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -9.923e-14 2.476e+04 -4.01e-18 1 x 0.000e+00 1.666e+00 0 1 Residual standard error: 27730 on 82 degrees of freedom Multiple R-squared: 3.241e-36, Adjusted R-squared: -0.0122 F-statistic: 2.657e-34 on 1 and 82 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/4cocz1229279153.ps",horizontal=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 -19082 -6337 -2471 6474 31407 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 2.017e+05 1.139e+03 177 <2e-16 *** m$residuals -3.622e-17 4.159e-02 -8.71e-16 1 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 10440 on 82 degrees of freedom Multiple R-squared: 2.368e-30, Adjusted R-squared: -0.0122 F-statistic: 1.942e-28 on 1 and 82 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/58z7b1229279153.ps",horizontal=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 -29557 -12119 -2583 5387 56578 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -137.75283 1921.94680 -0.072 0.943 Residuals 0.78070 0.06993 11.164 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 17510 on 81 degrees of freedom (2 observations deleted due to missingness) Multiple R-squared: 0.6061, Adjusted R-squared: 0.6012 F-statistic: 124.6 on 1 and 81 DF, p-value: < 2.2e-16 > abline(m5) > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/63h881229279153.ps",horizontal=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/70w091229279153.ps",horizontal=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/81q2z1229279153.ps",horizontal=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/9wrfa1229279153.ps",horizontal=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/10948q1229279153.tab") > > system("convert tmp/1e2v91229279153.ps tmp/1e2v91229279153.png") > system("convert tmp/2wb0w1229279153.ps tmp/2wb0w1229279153.png") > system("convert tmp/3xqql1229279153.ps tmp/3xqql1229279153.png") > system("convert tmp/4cocz1229279153.ps tmp/4cocz1229279153.png") > system("convert tmp/58z7b1229279153.ps tmp/58z7b1229279153.png") > system("convert tmp/63h881229279153.ps tmp/63h881229279153.png") > system("convert tmp/70w091229279153.ps tmp/70w091229279153.png") > system("convert tmp/81q2z1229279153.ps tmp/81q2z1229279153.png") > system("convert tmp/9wrfa1229279153.ps tmp/9wrfa1229279153.png") > > > proc.time() user system elapsed 1.906 1.413 2.621