R version 2.12.0 (2010-10-15) Copyright (C) 2010 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(3111,3995,5245,5588,10681,10516,7496,9935,10249,6271,3616,3724,2886,3318,4166,6401,9209,9820,7470,8207,9564,5309,3385,3706,2733,3045,3449,5542,10072,9418,7516,7840,10081,4956,3641,3970,2931,3170,3889,4850,8037,12370,6712,7297,10613,5184,3506,3810,2692,3073,3713,4555,7807,10869,9682,7704,9826,5456,3677,3431,2765,3483,3445,6081,8767,9407,6551,12480,9530,5960,3252,3717,2642,2989,3607,5366,8898,9435,7328,8594,11349,5797,3621,3851) > x <- c(332,369,384,373,378,426,423,397,422,409,430,412,470,491,504,484,474,508,492,452,457,457,471,451,493,514,522,490,484,506,501,462,465,454,464,427,460,473,465,422,415,413,420,363,376,380,384,346,389,407,393,346,348,353,364,305,307,312,312,286,324,336,327,302,299,311,315,264,278,278,287,279,324,354,354,360,363,385,412,370,389,395,417,404) > 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 -3702.5 -2558.5 -704.6 2436.4 6212.7 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 7025.899 1848.026 3.802 0.000275 *** x -2.103 4.579 -0.459 0.647260 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 2852 on 82 degrees of freedom Multiple R-squared: 0.002566, Adjusted R-squared: -0.009598 F-statistic: 0.2109 on 1 and 82 DF, p-value: 0.6473 > postscript(file="/var/www/rcomp/tmp/1mpya1292687700.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/rcomp/tmp/2wgxd1292687700.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 -8.027e-13 -2.341e-13 -2.476e-14 2.278e-13 1.452e-12 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 7.026e+03 2.780e-13 2.527e+16 <2e-16 *** x -2.103e+00 6.890e-16 -3.053e+15 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 4.291e-13 on 82 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 1 F-statistic: 9.318e+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/rcomp/tmp/37pxy1292687700.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 -3702.5 -2558.5 -704.6 2436.4 6212.7 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -1.063e-13 1.848e+03 0 1 x 8.022e-17 4.579e+00 0 1 Residual standard error: 2852 on 82 degrees of freedom Multiple R-squared: 1.05e-34, Adjusted R-squared: -0.0122 F-statistic: 8.607e-33 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/rcomp/tmp/47pxy1292687700.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 -261.244 -126.115 3.756 105.760 281.375 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 6.189e+03 1.578e+01 392.2 <2e-16 *** m$residuals 2.078e-17 5.601e-03 0.0 1 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 144.6 on 82 degrees of freedom Multiple R-squared: 1.929e-29, Adjusted R-squared: -0.0122 F-statistic: 1.581e-27 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/rcomp/tmp/5ize11292687700.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 -3813.2 -1682.0 -647.9 1534.1 5870.4 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 21.16156 242.59796 0.087 0.93 Residuals 0.62800 0.08593 7.309 1.7e-10 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 2210 on 81 degrees of freedom (2 observations deleted due to missingness) Multiple R-squared: 0.3974, Adjusted R-squared: 0.3899 F-statistic: 53.41 on 1 and 81 DF, p-value: 1.701e-10 > abline(m5) > grid() > dev.off() null device 1 > postscript(file="/var/www/rcomp/tmp/6yt2s1292687700.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/rcomp/tmp/7yt2s1292687700.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/rcomp/tmp/8lhup1292687700.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/rcomp/tmp/9lhup1292687700.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/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/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/rcomp/tmp/10zrax1292687700.tab") > > try(system("convert tmp/1mpya1292687700.ps tmp/1mpya1292687700.png",intern=TRUE)) character(0) > try(system("convert tmp/2wgxd1292687700.ps tmp/2wgxd1292687700.png",intern=TRUE)) character(0) > try(system("convert tmp/37pxy1292687700.ps tmp/37pxy1292687700.png",intern=TRUE)) character(0) > try(system("convert tmp/47pxy1292687700.ps tmp/47pxy1292687700.png",intern=TRUE)) character(0) > try(system("convert tmp/5ize11292687700.ps tmp/5ize11292687700.png",intern=TRUE)) character(0) > try(system("convert tmp/6yt2s1292687700.ps tmp/6yt2s1292687700.png",intern=TRUE)) character(0) > try(system("convert tmp/7yt2s1292687700.ps tmp/7yt2s1292687700.png",intern=TRUE)) character(0) > try(system("convert tmp/8lhup1292687700.ps tmp/8lhup1292687700.png",intern=TRUE)) character(0) > try(system("convert tmp/9lhup1292687700.ps tmp/9lhup1292687700.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.350 1.170 3.621