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(10,20,40,67,38,61,29,0,30,39,70,65,5,30,50,90,45,75,76,15,10,60,67,60,80,70,70,87,27,65,56,82,30,38,56,70,80,71,50,31,40,71,71,10,20,40,55,80,80,72,60,29,70,60,63,70,38,40,80,24,40,47,70,75,60,65,91,68,90,20,61,13,80,40,70,39,93,10,25,56,18,60,74,35,71,100,64,50,40,35,60,70,55,65,30,25,80,26,78,10,70,65,80,60,74,49,70,66,65,40,40,20,90,48,25,35,40,77,70,82,80,52,71,70,50,80,72,80,91,18,70,76,65,35,62,76,50,68,80,90,79,30,60,100) > x <- c(43,30,30,54,30,16,42,0,30,44,70,30,5,30,62,91,41,73,60,20,4,60,62,60,76,65,60,88,16,65,35,70,21,60,100,65,80,65,60,31,55,74,32,10,20,40,55,70,80,50,55,29,70,50,60,60,27,38,70,15,40,37,10,75,60,55,91,29,50,10,57,45,70,38,70,40,61,15,25,54,36,50,68,14,68,100,74,59,50,60,60,70,45,60,21,0,65,33,70,20,60,65,60,53,71,32,70,60,60,50,25,20,80,53,39,53,39,70,60,77,80,50,69,70,36,30,57,80,91,8,60,63,60,18,39,41,50,65,80,68,58,30,60,100) > 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 -40.7016 -6.6491 -0.0174 5.9792 48.3771 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 13.28080 2.87120 4.626 8.33e-06 *** x 0.83421 0.05174 16.123 < 2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 13.83 on 142 degrees of freedom Multiple R-squared: 0.6467, Adjusted R-squared: 0.6442 F-statistic: 260 on 1 and 142 DF, p-value: < 2.2e-16 > postscript(file="/var/www/html/rcomp/tmp/11dfq1289843704.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/21dfq1289843704.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 -1.694e-14 -5.845e-15 -3.597e-15 -2.957e-15 2.907e-13 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.328e+01 6.710e-15 1.979e+15 <2e-16 *** x 8.342e-01 1.209e-16 6.899e+15 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 3.232e-14 on 142 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 1 F-statistic: 4.759e+31 on 1 and 142 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/31dfq1289843704.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 -40.7016 -6.6491 -0.0174 5.9792 48.3771 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 3.715e-15 2.871e+00 1.29e-15 1 x -7.310e-17 5.174e-02 -1.41e-15 1 Residual standard error: 13.83 on 142 degrees of freedom Multiple R-squared: 1.427e-32, Adjusted R-squared: -0.007042 F-statistic: 2.027e-30 on 1 and 142 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/4cnet1289843704.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 -42.400 -15.079 3.482 12.449 41.021 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 5.568e+01 1.559e+00 35.71 <2e-16 *** m$residuals -7.114e-16 1.135e-01 -6.27e-15 1 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 18.71 on 142 degrees of freedom Multiple R-squared: 9.778e-31, Adjusted R-squared: -0.007042 F-statistic: 1.388e-28 on 1 and 142 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/55eee1289843704.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 -38.121 -6.675 -0.652 6.113 47.691 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.27709 1.11487 0.249 0.8041 Residuals 0.14324 0.08091 1.770 0.0788 . --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 13.33 on 141 degrees of freedom (2 observations deleted due to missingness) Multiple R-squared: 0.02175, Adjusted R-squared: 0.01481 F-statistic: 3.134 on 1 and 141 DF, p-value: 0.07882 > abline(m5) > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/6fnvh1289843704.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/7fnvh1289843704.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/8qeck1289843704.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/9qeck1289843704.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/1046ab1289843704.tab") > > try(system("convert tmp/11dfq1289843704.ps tmp/11dfq1289843704.png",intern=TRUE)) character(0) > try(system("convert tmp/21dfq1289843704.ps tmp/21dfq1289843704.png",intern=TRUE)) character(0) > try(system("convert tmp/31dfq1289843704.ps tmp/31dfq1289843704.png",intern=TRUE)) character(0) > try(system("convert tmp/4cnet1289843704.ps tmp/4cnet1289843704.png",intern=TRUE)) character(0) > try(system("convert tmp/55eee1289843704.ps tmp/55eee1289843704.png",intern=TRUE)) character(0) > try(system("convert tmp/6fnvh1289843704.ps tmp/6fnvh1289843704.png",intern=TRUE)) character(0) > try(system("convert tmp/7fnvh1289843704.ps tmp/7fnvh1289843704.png",intern=TRUE)) character(0) > try(system("convert tmp/8qeck1289843704.ps tmp/8qeck1289843704.png",intern=TRUE)) character(0) > try(system("convert tmp/9qeck1289843704.ps tmp/9qeck1289843704.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.880 1.415 2.700