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(65.03 + ,61.94 + ,62.68 + ,69.8 + ,70.81 + ,70.9 + ,74.52 + ,73.18 + ,64.33 + ,59.44 + ,59.36 + ,62.16 + ,54.37 + ,59.11 + ,60.55 + ,64.04 + ,63.75 + ,67.29 + ,73.73 + ,72.39 + ,78.86 + ,85.16 + ,94.71 + ,91.29 + ,92.56 + ,94.84 + ,105.12 + ,111.67 + ,125.45 + ,133.69 + ,134.08 + ,117 + ,103.88 + ,77.6 + ,57.55 + ,42.78 + ,41.43 + ,39.15 + ,47.48 + ,49.7 + ,58.79 + ,69.59 + ,64.27 + ,71 + ,69.27 + ,75.47 + ,77.97 + ,74.61 + ,79.55 + ,77.3 + ,81.1 + ,84.65 + ,74.22 + ,75.4 + ,76.03 + ,76.67 + ,75.01 + ,81.96 + ,84.25 + ,89.25 + ,91.55 + ,88.92 + ,90.3 + ,88.8 + ,88.03 + ,89.13 + ,91.11 + ,91.94 + ,91.45 + ,91.54 + ,91.02 + ,91.38 + ,91.06 + ,88.86 + ,89.11 + ,88.15 + ,86.19 + ,87.35 + ,86 + ,89.34 + ,92 + ,89.68 + ,90.77 + ,91.08 + ,90.67 + ,89.03 + ,87.69 + ,86.94 + ,86.75 + ,86.9 + ,85.58 + ,85.4 + ,84.32 + ,85.13 + ,86.03 + ,86.2 + ,91.42 + ,93.57 + ,98.9 + ,99.48 + ,97.88 + ,97.94 + ,90.08 + ,99.63 + ,102.2 + ,101.28 + ,104.42 + ,105.15 + ,105.02 + ,104.76 + ,103.33 + ,101.16 + ,101.19 + ,97.18 + ,97.98 + ,101.42 + ,101.07 + ,102.33 + ,102.33 + ,104 + ,105.6 + ,105.4 + ,104.77 + ,104.79 + ,104.31 + ,106.46 + ,102.86 + ,107.94 + ,108.1 + ,108.35 + ,108.47 + ,108.83 + ,112.79 + ,110.46 + ,106.25 + ,106.53 + ,107.95 + ,109.66 + ,107.16 + ,108.15 + ,111.16 + ,112.19 + ,112.35 + ,112.2 + ,111.9 + ,112.76 + ,112.53 + ,113.5 + ,109.96 + ,113.89 + ,111.05 + ,109.16 + ,101 + ,97.18 + ,102.19 + ,103.88 + ,99.35 + ,99.77 + ,99.65 + ,97.69 + ,96.91 + ,100.93 + ,99.06 + ,99.49 + ,97.83 + ,99.59 + ,101.14 + ,100.53 + ,100.59 + ,100.59 + ,102.8 + ,101.56 + ,100.29 + ,100.51 + ,100.22 + ,100.22 + ,99.01 + ,99.09 + ,100.74 + ,99.29 + ,96.9 + ,97.3 + ,99.37 + ,94.81 + ,93.01 + ,93.26 + ,93.26 + ,94.16 + ,95.41 + ,91.16 + ,91.16 + ,90.61 + ,92.89 + ,94.77 + ,96.25 + ,94.94 + ,94.94 + ,94.94 + ,96.89 + ,96.65 + ,96.2 + ,96.2 + ,95.15 + ,97.43 + ,98.05 + ,97.24 + ,97.24 + ,95.93 + ,97.5 + ,98.4 + ,99.87 + ,99.28 + ,99.2 + ,99.59 + ,97.4 + ,95.2 + ,97.06 + ,95.7 + ,94.89 + ,93.79 + ,86.68 + ,86.88 + ,86.88 + ,79.3 + ,80.66 + ,83.75 + ,85.38 + ,87.27 + ,86.65 + ,87.74 + ,87.58 + ,82.26 + ,82.26 + ,85.44 + ,85.9 + ,85.08 + ,85.37 + ,85.37 + ,88.9 + ,88.84 + ,86.63 + ,89.08 + ,86.45 + ,86.45 + ,86.02 + ,89.53 + ,89.19 + ,87.24 + ,87.91 + ,90.21 + ,89 + ,89.28 + ,87.96 + ,85.28 + ,86.89 + ,86.39 + ,85.92 + ,79.85 + ,80.58 + ,84.45 + ,81.67 + ,82.82 + ,79.2 + ,85.97 + ,77.61 + ,75.67 + ,79.16 + ,79.68 + ,82.98 + ,85.6 + ,86.41 + ,85.57 + ,84.77 + ,86.8 + ,86.48 + ,88.34 + ,88.21 + ,86.11 + ,87.4 + ,87.4 + ,91.59 + ,93.17 + ,90.2 + ,93.96 + ,93.2 + ,86.21) > x <- c(55.57 + ,56.5 + ,53.83 + ,52.29 + ,50.97 + ,51.18 + ,51.5 + ,53.8 + ,50.7 + ,49.05 + ,48.44 + ,53.77 + ,54.67 + ,53.96 + ,54.03 + ,50.52 + ,48.83 + ,53.93 + ,62.2 + ,58.23 + ,60.93 + ,63.06 + ,61.77 + ,64.48 + ,69.38 + ,71 + ,77.89 + ,71.43 + ,69.15 + ,69.88 + ,69.64 + ,67.18 + ,61.18 + ,50.14 + ,42.2 + ,44.8 + ,49.04 + ,45.56 + ,42.63 + ,49.2 + ,57.43 + ,54.11 + ,58.65 + ,58.6 + ,60.15 + ,65.36 + ,68.83 + ,73.61 + ,72 + ,74.46 + ,81.22 + ,81.41 + ,80.62 + ,81.43 + ,80.84 + ,82.4 + ,91.32 + ,103.89 + ,132.32 + ,142.13 + ,142.2 + ,143.78 + ,145.2 + ,141.22 + ,140.6 + ,143.25 + ,147.25 + ,147.97 + ,144.06 + ,141.44 + ,141.44 + ,145.44 + ,148.94 + ,152.94 + ,156.94 + ,161.94 + ,161.83 + ,166.83 + ,169.39 + ,164.75 + ,168.44 + ,151.23 + ,172.22 + ,176.22 + ,171.86 + ,167.86 + ,174.51 + ,175.29 + ,180.58 + ,187.58 + ,189.97 + ,186.05 + ,190.02 + ,197.02 + ,204.02 + ,197.02 + ,197.02 + ,187.94 + ,186.56 + ,181.28 + ,191.34 + ,196.52 + ,185.54 + ,195.87 + ,204.45 + ,208.2 + ,215.15 + ,214.5 + ,207.04 + ,205.99 + ,200.98 + ,204.94 + ,197.94 + ,190.94 + ,185.12 + ,192.12 + ,199.12 + ,198.96 + ,205.96 + ,201.87 + ,208.82 + ,204.49 + ,197.99 + ,194.88 + ,193.67 + ,200.23 + ,201.27 + ,195.55 + ,195.55 + ,201.06 + ,208.06 + ,208.06 + ,202.97 + ,204.58 + ,199.73 + ,197.35 + ,196.04 + ,195.52 + ,196.45 + ,189.82 + ,183.17 + ,186.67 + ,186.67 + ,188 + ,181.84 + ,174.89 + ,172.82 + ,178.78 + ,192.55 + ,175.91 + ,179.21 + ,173.19 + ,165.36 + ,153.8 + ,145.4 + ,151.4 + ,150.3 + ,144.3 + ,145.15 + ,151.15 + ,155.04 + ,159.86 + ,155.65 + ,155.61 + ,153.89 + ,153.88 + ,156.03 + ,151.03 + ,151.03 + ,153.5 + ,158.67 + ,156.33 + ,160.97 + ,164.24 + ,161.63 + ,155.63 + ,148.63 + ,145.05 + ,151.05 + ,150.03 + ,150.95 + ,155.55 + ,151.96 + ,145.96 + ,145.18 + ,148.73 + ,154.73 + ,161.22 + ,164.55 + ,165.22 + ,162 + ,160.91 + ,162.14 + ,159.79 + ,155.73 + ,159.79 + ,161.5 + ,159 + ,155.4 + ,136.2 + ,116.58 + ,111.58 + ,106.59 + ,110.35 + ,106.35 + ,101.46 + ,97.95 + ,101.95 + ,101.29 + ,99.33 + ,99.14 + ,97.09 + ,101.09 + ,103.85 + ,102.81 + ,102.08 + ,115.78 + ,105.59 + ,107.17 + ,104.42 + ,105.01 + ,101.48 + ,99.01 + ,97.26 + ,99.16 + ,97.79 + ,100.72 + ,105.03 + ,104.62 + ,108.43 + ,107.55 + ,106.76 + ,106.61 + ,105.14 + ,104.62 + ,102.59 + ,103.92 + ,104.77 + ,104.91 + ,105.88 + ,103.85 + ,106.08 + ,106.08 + ,106.3 + ,106.24 + ,110.02 + ,112.45 + ,110.3 + ,110.72 + ,111.56 + ,113.39 + ,110.62 + ,109.08 + ,104.08 + ,103.81 + ,101.27 + ,97.64 + ,99.99 + ,98.43 + ,99.39 + ,98.33 + ,100.97 + ,99.31 + ,105.28 + ,97.75 + ,100.92 + ,102.75 + ,102.25 + ,101.48 + ,103.34 + ,103.47 + ,100.51 + ,101.56 + ,101.94 + ,100.36 + ,100.18 + ,99.72 + ,96.86 + ,97.1 + ,97.94 + ,99.68 + ,100.32 + ,104.32 + ,104.37 + ,102.29 + ,100.91) > par1 = '0' > 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 -35.139 -4.835 -0.001 4.292 55.079 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 65.3731 1.7954 36.41 <2e-16 *** x 0.1957 0.0130 15.06 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 10.62 on 284 degrees of freedom Multiple R-squared: 0.4439, Adjusted R-squared: 0.442 F-statistic: 226.7 on 1 and 284 DF, p-value: < 2.2e-16 > postscript(file="/var/wessaorg/rcomp/tmp/1zzd41321397437.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/2wd1n1321397437.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 -2.082e-14 -3.596e-15 3.940e-17 3.367e-15 2.112e-14 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 6.537e+01 7.531e-16 8.681e+16 <2e-16 *** x 1.957e-01 5.451e-18 3.590e+16 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 4.455e-15 on 284 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 1 F-statistic: 1.289e+33 on 1 and 284 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/30rlq1321397437.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 -35.139 -4.835 -0.001 4.292 55.079 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.641e-16 1.795e+00 0 1 x 1.868e-19 1.300e-02 0 1 Residual standard error: 10.62 on 284 degrees of freedom Multiple R-squared: 2.418e-34, Adjusted R-squared: -0.003521 F-statistic: 6.868e-32 on 1 and 284 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/4ohmp1321397437.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 -17.068 -5.891 -2.591 7.472 16.777 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 9.070e+01 5.611e-01 161.6 <2e-16 *** m$residuals 5.937e-18 5.302e-02 0.0 1 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 9.489 on 284 degrees of freedom Multiple R-squared: 2.851e-30, Adjusted R-squared: -0.003521 F-statistic: 8.096e-28 on 1 and 284 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/5q1j81321397437.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 -22.2633 -1.3959 0.1883 1.6989 16.4964 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.04291 0.23079 0.186 0.853 Residuals 0.92843 0.02177 42.648 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 3.896 on 283 degrees of freedom (2 observations deleted due to missingness) Multiple R-squared: 0.8654, Adjusted R-squared: 0.8649 F-statistic: 1819 on 1 and 283 DF, p-value: < 2.2e-16 > abline(m5) > grid() > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/6s7211321397437.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/71mcl1321397437.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/8y4cx1321397437.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/94q201321397437.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/1033n41321397437.tab") > > try(system("convert tmp/1zzd41321397437.ps tmp/1zzd41321397437.png",intern=TRUE)) character(0) > try(system("convert tmp/2wd1n1321397437.ps tmp/2wd1n1321397437.png",intern=TRUE)) character(0) > try(system("convert tmp/30rlq1321397437.ps tmp/30rlq1321397437.png",intern=TRUE)) character(0) > try(system("convert tmp/4ohmp1321397437.ps tmp/4ohmp1321397437.png",intern=TRUE)) character(0) > try(system("convert tmp/5q1j81321397437.ps tmp/5q1j81321397437.png",intern=TRUE)) character(0) > try(system("convert tmp/6s7211321397437.ps tmp/6s7211321397437.png",intern=TRUE)) character(0) > try(system("convert tmp/71mcl1321397437.ps tmp/71mcl1321397437.png",intern=TRUE)) character(0) > try(system("convert tmp/8y4cx1321397437.ps tmp/8y4cx1321397437.png",intern=TRUE)) character(0) > try(system("convert tmp/94q201321397437.ps tmp/94q201321397437.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.658 0.436 3.139