R version 2.13.0 (2011-04-13) Copyright (C) 2011 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(1235,1080,845,1522,1047,1979,1822,1253,1297,946,1713,1024,1147,1092,1152,1336,2131,1550,1884,2041,845,1483,1055,1545,729,1792,1175,1593,785,744,1356,1262,1250,1020,840,1515,1045,1972,1820,1248,1290,944,1713,1022,1143,1089,1149,1327,2128,1143,1880,2034,844,1879,1050,1541,724,1782,1170,1586,749,740,1352) > x <- c(127,115,127,150,156,182,156,132,137,113,137,117,137,153,117,126,170,182,162,184,143,159,108,175,108,179,111,187,111,115,194,168,125,114,126,149,155,181,155,130,136,112,135,114,136,152,116,125,169,181,160,183,142,158,107,174,107,178,110,186,110,114,193) > 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 -567.61 -217.61 45.25 196.68 542.53 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -176.977 192.968 -0.917 0.363 x 10.429 1.317 7.918 6.09e-11 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 283.1 on 61 degrees of freedom Multiple R-squared: 0.5068, Adjusted R-squared: 0.4988 F-statistic: 62.69 on 1 and 61 DF, p-value: 6.092e-11 > postscript(file="/var/wessaorg/rcomp/tmp/1zvo21321792131.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/wessaorg/rcomp/tmp/2g7e11321792131.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 -4.360e-13 -3.836e-14 -1.301e-14 4.193e-14 4.147e-13 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -1.770e+02 7.302e-14 -2.424e+15 <2e-16 *** x 1.043e+01 4.984e-16 2.092e+16 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 1.071e-13 on 61 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 1 F-statistic: 4.379e+32 on 1 and 61 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/wessaorg/rcomp/tmp/3ltns1321792131.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 -567.61 -217.61 45.25 196.68 542.53 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -5.001e-15 1.930e+02 0 1 x -1.198e-17 1.317e+00 0 1 Residual standard error: 283.1 on 61 degrees of freedom Multiple R-squared: 6.225e-35, Adjusted R-squared: -0.01639 F-statistic: 3.797e-33 on 1 and 61 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/wessaorg/rcomp/tmp/4y7hd1321792131.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 -385.70 -286.62 -72.84 255.67 521.60 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.325e+03 3.616e+01 36.63 <2e-16 *** m$residuals -5.377e-17 1.298e-01 0.00 1 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 287 on 61 degrees of freedom Multiple R-squared: 3.704e-31, Adjusted R-squared: -0.01639 F-statistic: 2.26e-29 on 1 and 61 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/wessaorg/rcomp/tmp/54lvu1321792131.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 -528.89 -225.17 47.23 206.17 557.38 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -0.86735 36.15215 -0.024 0.981 Residuals -0.06979 0.13195 -0.529 0.599 Residual standard error: 284.5 on 60 degrees of freedom (2 observations deleted due to missingness) Multiple R-squared: 0.00464, Adjusted R-squared: -0.01195 F-statistic: 0.2797 on 1 and 60 DF, p-value: 0.5988 > abline(m5) > grid() > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/6ixj51321792131.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/wessaorg/rcomp/tmp/78web1321792131.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/wessaorg/rcomp/tmp/8aoi91321792131.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/wessaorg/rcomp/tmp/9k6c01321792131.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/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/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/wessaorg/rcomp/tmp/10dq2z1321792131.tab") > > try(system("convert tmp/1zvo21321792131.ps tmp/1zvo21321792131.png",intern=TRUE)) character(0) > try(system("convert tmp/2g7e11321792131.ps tmp/2g7e11321792131.png",intern=TRUE)) character(0) > try(system("convert tmp/3ltns1321792131.ps tmp/3ltns1321792131.png",intern=TRUE)) character(0) > try(system("convert tmp/4y7hd1321792131.ps tmp/4y7hd1321792131.png",intern=TRUE)) character(0) > try(system("convert tmp/54lvu1321792131.ps tmp/54lvu1321792131.png",intern=TRUE)) character(0) > try(system("convert tmp/6ixj51321792131.ps tmp/6ixj51321792131.png",intern=TRUE)) character(0) > try(system("convert tmp/78web1321792131.ps tmp/78web1321792131.png",intern=TRUE)) character(0) > try(system("convert tmp/8aoi91321792131.ps tmp/8aoi91321792131.png",intern=TRUE)) character(0) > try(system("convert tmp/9k6c01321792131.ps tmp/9k6c01321792131.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.375 0.577 3.010