R version 2.11.1 (2010-05-31) Copyright (C) 2010 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(24,25,17,18,18,16,20,16,18,17,23,30,23,18,15,12,21,15,20,31,27,34,21,31,19,16,20,21,22,17,24,25,26,25,17,32,33,13,32,25,29,22,18,17,20,15,20,33,29,23,26,18,20,11,28,26,22,17,12,14,17,21,19,18,10,29,31,19,9,20,28,19,30,29,26,23,13,21,19,28,23,18,21,20,23,21,21,15,28,19,26,10,16,22,19,31,31,29,19,22,23,15,20,18,23,25,21,24,25,17,13,28,21,25,9,16,19,17,25,20,29,14,22,15,19,20,15,20,18,33,22,16,17,16,21,26,18,18,17,22,30,30,24,21,21,29,31,20,16,22,20,28,38,22,20,17,28,22,31) > x <- c(237.588 + ,164.083 + ,278.261 + ,220.36 + ,253.967 + ,422.31 + ,136.921 + ,143.495 + ,189.785 + ,219.529 + ,217.761 + ,221.754 + ,159.854 + ,209.464 + ,174.283 + ,154.55 + ,153.024 + ,162.49 + ,154.462 + ,249.671 + ,259.473 + ,155.337 + ,151.289 + ,276.614 + ,188.214 + ,181.098 + ,240.898 + ,244.551 + ,250.238 + ,183.129 + ,310.331 + ,281.942 + ,230.343 + ,161.563 + ,392.527 + ,1077.414 + ,248.275 + ,557.386 + ,731.874 + ,301.429 + ,226.36 + ,215.018 + ,157.672 + ,219.118 + ,213.019 + ,390.642 + ,157.124 + ,227.652 + ,239.266 + ,506.343 + ,149.219 + ,213.351 + ,174.517 + ,172.531 + ,320.656 + ,305.011 + ,266.495 + ,361.511 + ,361.019 + ,382.187 + ,196.763 + ,273.212 + ,186.397 + ,294.205 + ,364.685 + ,230.501 + ,217.51 + ,262.297 + ,169.246 + ,260.428 + ,348.187 + ,512.937 + ,164.496 + ,111.187 + ,169.999 + ,240.187 + ,187.158 + ,194.096 + ,265.846 + ,283.319 + ,356.938 + ,240.802 + ,326.662 + ,249.266 + ,277.368 + ,394.618 + ,235.686 + ,227.641 + ,159.593 + ,268.866 + ,206.466 + ,233.064 + ,133.824 + ,486.783 + ,228.859 + ,155.238 + ,2042.451 + ,205.218 + ,373.648 + ,229.151 + ,199.156 + ,234.41 + ,56.519 + ,289.239 + ,199.227 + ,274.513 + ,174.499 + ,217.714 + ,239.717 + ,241.529 + ,155.561 + ,204.107 + ,745.97 + ,241.772 + ,110.267 + ,186.58 + ,227.906 + ,197.518 + ,254.094 + ,173.942 + ,294.42 + ,211.924 + ,262.479 + ,193.495 + ,165.972 + ,237.352 + ,205.814 + ,227.526 + ,250.439 + ,470.849 + ,176.469 + ,298.691 + ,193.922 + ,212.422 + ,203.284 + ,240.56 + ,445.327 + ,248.984 + ,174.44 + ,165.024 + ,249.681 + ,238.312 + ,250.437 + ,174.75 + ,4941.633 + ,138.936 + ,203.181 + ,187.747 + ,270.95 + ,307.688 + ,184.477 + ,230.916 + ,187.286 + ,169.376 + ,182.838 + ,176.081 + ,248.056 + ,235.24 + ,76.347) > 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 -12.4765 -4.1040 -0.6192 3.5293 16.5071 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 2.132e+01 5.541e-01 38.485 <2e-16 *** x 9.063e-04 1.098e-03 0.825 0.410 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 5.729 on 157 degrees of freedom Multiple R-squared: 0.00432, Adjusted R-squared: -0.002022 F-statistic: 0.6812 on 1 and 157 DF, p-value: 0.4104 > postscript(file="/var/www/rcomp/tmp/141zr1289556802.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/rcomp/tmp/241zr1289556802.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 -3.475e-14 -8.388e-16 1.228e-16 1.141e-15 3.327e-15 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 2.132e+01 2.939e-16 7.254e+16 <2e-16 *** x 9.063e-04 5.825e-19 1.556e+15 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 3.039e-15 on 157 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 1 F-statistic: 2.421e+30 on 1 and 157 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/3esyt1289556802.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 -12.4765 -4.1040 -0.6192 3.5293 16.5071 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 8.374e-18 5.541e-01 1.51e-17 1 x -5.233e-20 1.098e-03 -4.77e-17 1 Residual standard error: 5.729 on 157 degrees of freedom Multiple R-squared: 1.53e-34, Adjusted R-squared: -0.006369 F-statistic: 2.401e-32 on 1 and 157 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/47kxe1289556802.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 -0.21056 -0.09595 -0.05524 -0.01717 4.21668 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 2.158e+01 2.993e-02 721.3 <2e-16 *** m$residuals 4.235e-18 5.257e-03 8.06e-16 1 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.3774 on 157 degrees of freedom Multiple R-squared: 9.033e-30, Adjusted R-squared: -0.006369 F-statistic: 1.418e-27 on 1 and 157 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/50beh1289556802.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 -12.9871 -3.8908 -0.6128 3.3355 15.4472 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -0.005562 0.450819 -0.012 0.9902 Residuals 0.164746 0.079663 2.068 0.0403 * --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 5.666 on 156 degrees of freedom (2 observations deleted due to missingness) Multiple R-squared: 0.02668, Adjusted R-squared: 0.02044 F-statistic: 4.277 on 1 and 156 DF, p-value: 0.04029 > abline(m5) > grid() > dev.off() null device 1 > postscript(file="/var/www/rcomp/tmp/60beh1289556802.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/rcomp/tmp/7a2v21289556802.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/rcomp/tmp/8a2v21289556802.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/rcomp/tmp/93bvn1289556802.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/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/10zltw1289556802.tab") > > try(system("convert tmp/141zr1289556802.ps tmp/141zr1289556802.png",intern=TRUE)) character(0) > try(system("convert tmp/241zr1289556802.ps tmp/241zr1289556802.png",intern=TRUE)) character(0) > try(system("convert tmp/3esyt1289556802.ps tmp/3esyt1289556802.png",intern=TRUE)) character(0) > try(system("convert tmp/47kxe1289556802.ps tmp/47kxe1289556802.png",intern=TRUE)) character(0) > try(system("convert tmp/50beh1289556802.ps tmp/50beh1289556802.png",intern=TRUE)) character(0) > try(system("convert tmp/60beh1289556802.ps tmp/60beh1289556802.png",intern=TRUE)) character(0) > try(system("convert tmp/7a2v21289556802.ps tmp/7a2v21289556802.png",intern=TRUE)) character(0) > try(system("convert tmp/8a2v21289556802.ps tmp/8a2v21289556802.png",intern=TRUE)) character(0) > try(system("convert tmp/93bvn1289556802.ps tmp/93bvn1289556802.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.950 1.690 4.613