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(684.28 + ,722.57 + ,695.96 + ,688.13 + ,720.76 + ,737.26 + ,736.9 + ,727.38 + ,728.83 + ,715.58 + ,735.93 + ,758.69 + ,758.69 + ,740.99 + ,719.44 + ,721.24 + ,737.38 + ,756.52 + ,745.32 + ,733.76 + ,738.46 + ,736.65 + ,737.5 + ,725.22 + ,722.45 + ,720.44 + ,733.6 + ,662.93 + ,763.87 + ,746.67 + ,712.59 + ,655.02 + ,660.2 + ,633.59 + ,627.08 + ,635.63 + ,668.87 + ,656.7 + ,631.9 + ,610.83 + ,632.98 + ,631.06 + ,644.3 + ,647.55 + ,655.14 + ,674.4 + ,676.21 + ,670.43 + ,683.43 + ,703.42 + ,708.48 + ,714.5 + ,706.19 + ,694.15 + ,658.15 + ,648.4 + ,630.82 + ,634.19 + ,658.15 + ,636.11 + ,640.33 + ,601.8 + ,611.07 + ,634.31 + ,625.76 + ,596.86 + ,604.09 + ,587.11 + ,583.13 + ,579.16 + ,551.47 + ,541.83 + ,569.53 + ,564.71 + ,572.06 + ,578.56 + ,595.78 + ,567.84 + ,534.25 + ,519.08 + ,531.96 + ,551.83 + ,560.62 + ,579.52 + ,593.13 + ,626.72 + ,715.1 + ,832.38 + ,837.2 + ,879.46 + ,881.99 + ,1044.9 + ,924.73 + ,987.95 + ,966.15 + ,1016.72 + ,1107.27 + ,1296.67 + ,1379.75 + ,1543.03 + ,1570.12 + ,1538.81 + ,1484.63 + ,1451.27 + ,1414.91 + ,1456.93 + ,1319.19 + ,1267.89 + ,1349.77 + ,1240.2 + ,1189.51 + ,1117.87 + ,1080.06 + ,1054.77 + ,1019.47 + ,1049.96 + ,1060.79 + ,1070.42 + ,1075.24 + ,1080.06 + ,1074.04 + ,1062 + ,1064.4 + ,1071.63 + ,1057.18 + ,898.24 + ,895.83 + ,951.22 + ,936.77 + ,901.85 + ,888.61 + ,870.55 + ,887.41 + ,596.02 + ,586.39 + ,596.02 + ,721 + ,777.51 + ,723.48 + ,680.64 + ,613.45 + ,558.18 + ,641.49 + ,652.19 + ,619.37 + ,655.83 + ,667.93 + ,667.7 + ,663.07 + ,633.89 + ,595.28 + ,568.94 + ,572.72 + ,535.26 + ,508.04 + ,512.94 + ,495.22 + ,469.37 + ,469.37 + ,429.69 + ,468.13 + ,470.06 + ,464.93 + ,450.74 + ,423.51 + ,454.84 + ,497.77 + ,465.45 + ,542.31 + ,606.03 + ,609.58 + ,645.79 + ,719.63 + ,779.41 + ,773.5 + ,806.82 + ,876.1 + ,824.64 + ,881.7 + ,878.41 + ,904.18 + ,892.34 + ,887.13 + ,867.85 + ,839.28 + ,826.06 + ,751.11 + ,789.25 + ,732.98 + ,622.07 + ,600.95 + ,590.53 + ,584.39 + ,525.31 + ,573.83 + ,597.67 + ,743.54 + ,701.36 + ,671.43 + ,751.65 + ,738.33 + ,681.61 + ,616.97 + ,632.94 + ,677.73 + ,730.96 + ,719.66 + ,764.21 + ,805 + ,829.35 + ,826.26 + ,765.93 + ,801.91 + ,769.16 + ,739.89 + ,688.07 + ,636.11 + ,631.72 + ,625.92 + ,627.82 + ,606.13 + ,595.3 + ,583.14 + ,500.19 + ,462.89 + ,417.47 + ,472.27 + ,474.81 + ,489.07 + ,493.14 + ,626.64 + ,680.43 + ,620.3 + ,676.74 + ,690.03 + ,631.04 + ,623.26 + ,619.83 + ,631.74 + ,648.77 + ,724.21 + ,727.09 + ,767.31 + ,801.42 + ,817.72 + ,764.33 + ,746.93 + ,717.29 + ,695.9 + ,688.38 + ,663.53 + ,688.39 + ,716.14 + ,733.28 + ,688.23 + ,760.63 + ,716.77 + ,683.81 + ,630.79 + ,617.91 + ,524.19 + ,441.98 + ,466.09 + ,501.44 + ,599.55 + ,621.99 + ,607.57 + ,614.56 + ,619.09 + ,603.14 + ,569.12 + ,575.72 + ,642.41 + ,748.18 + ,768.39 + ,763.16 + ,800.63 + ,778.49 + ,733.7 + ,740.17 + ,678.33 + ,697.09 + ,678.54 + ,670.87 + ,674.52 + ,664.39 + ,646.52 + ,661.25 + ,729.36 + ,721.52 + ,708.75 + ,706.12 + ,676.93 + ,708.15 + ,717.64 + ,714.35 + ,703.6 + ,718.96 + ,736.03 + ,717.96 + ,730.77 + ,734.66 + ,728.58 + ,729.18 + ,717.13 + ,684.6 + ,692.06 + ,668.84 + ,647.4 + ,622.57 + ,593.69 + ,583.24 + ,639.17 + ,709.73 + ,698.75 + ,697.7 + ,732.25 + ,714.49 + ,704.85 + ,717.56 + ,704.91 + ,690.74 + ,790.34 + ,790.69 + ,893.66 + ,875.62 + ,914.02 + ,940.37 + ,989.08 + ,987.73 + ,936.34 + ,914.11 + ,943.08 + ,1080.64 + ,1102.71 + ,1097.26 + ,1157.37 + ,1154.25 + ,1136 + ,1133.42 + ,1062.44 + ,1041.1 + ,1047.97 + ,941.71 + ,896.79 + ,734.91 + ,646.17 + ,666.39 + ,625.45 + ,586.26 + ,617.15 + ,686.86 + ,761.34 + ,741.73 + ,763.62 + ,822.57 + ,867.58 + ,944.85 + ,953.95 + ,970.08 + ,1003.22 + ,972.81 + ,1003.86 + ,991.83 + ,919.13 + ,919.52 + ,916.17 + ,936.18 + ,960.65) > x <- c(553.12 + ,568.15 + ,552.75 + ,510.65 + ,524.93 + ,532.95 + ,540.84 + ,540.22 + ,553.75 + ,529.69 + ,525.93 + ,527.31 + ,527.31 + ,512.03 + ,502.76 + ,496.62 + ,492.23 + ,495.12 + ,469.93 + ,492.36 + ,497.87 + ,480.21 + ,462.29 + ,456.03 + ,456.22 + ,460.41 + ,466.59 + ,441.37 + ,455.31 + ,426.96 + ,419.7 + ,419.7 + ,416.44 + ,404.04 + ,388.63 + ,397.65 + ,390.38 + ,378.1 + ,384.87 + ,419.19 + ,427.96 + ,413.81 + ,408.04 + ,410.3 + ,405.66 + ,400.9 + ,387 + ,388.25 + ,390 + ,416.44 + ,436.11 + ,428.79 + ,424.16 + ,409.12 + ,392.01 + ,388.37 + ,373.97 + ,358.93 + ,371.96 + ,353.92 + ,364.95 + ,340.52 + ,353.67 + ,361.19 + ,364.7 + ,359.43 + ,371.21 + ,385.24 + ,389.63 + ,433.23 + ,407.79 + ,400.9 + ,385.87 + ,406.67 + ,406.04 + ,418.19 + ,429.22 + ,420.95 + ,402.78 + ,391.01 + ,416.94 + ,397.14 + ,406.67 + ,419.44 + ,422.2 + ,435.98 + ,470.81 + ,504.51 + ,497.25 + ,508.52 + ,522.43 + ,551.62 + ,537.59 + ,559.76 + ,558.26 + ,563.27 + ,558.01 + ,563.27 + ,564.15 + ,582.81 + ,592.96 + ,602.73 + ,581.06 + ,595.47 + ,605.36 + ,615.39 + ,602.48 + ,565.65 + ,565.65 + ,566.9 + ,558.63 + ,547.48 + ,543.72 + ,517.42 + ,526.31 + ,512.4 + ,496.12 + ,503.63 + ,501.13 + ,499.88 + ,501.13 + ,494.86 + ,488.6 + ,482.34 + ,447.26 + ,440.99 + ,418.44 + ,418.44 + ,412.18 + ,394.64 + ,334.5 + ,328.24 + ,319.47 + ,323.23 + ,328.24 + ,365.82 + ,371.88 + ,340.6 + ,337.48 + ,337.22 + ,313.96 + ,308.39 + ,307.57 + ,295.4 + ,297.04 + ,341.89 + ,341.18 + ,352.12 + ,367.36 + ,364.88 + ,363.09 + ,351.25 + ,349.29 + ,335.47 + ,320.1 + ,310.7 + ,312.39 + ,309.68 + ,309.67 + ,328.92 + ,337.01 + ,327.79 + ,324.38 + ,313.93 + ,310.83 + ,316.62 + ,325.5 + ,320.03 + ,320.1 + ,338.13 + ,379.25 + ,376.82 + ,398.37 + ,394.46 + ,411.95 + ,425.91 + ,444.48 + ,433.45 + ,446.07 + ,426.04 + ,447.06 + ,467.94 + ,516.73 + ,520.27 + ,516.49 + ,519.41 + ,537.66 + ,547.44 + ,507.04 + ,495.99 + ,436.58 + ,453.11 + ,456.77 + ,450.38 + ,439.18 + ,416.56 + ,440.06 + ,447.61 + ,420.32 + ,417.67 + ,404.38 + ,416.41 + ,419.48 + ,417.72 + ,408.62 + ,442.94 + ,425.82 + ,451.19 + ,467.49 + ,478.76 + ,478.56 + ,427.63 + ,448.81 + ,435.41 + ,434.67 + ,413.62 + ,399.02 + ,406.64 + ,384.83 + ,379.81 + ,355.7 + ,348.24 + ,308.83 + ,296.93 + ,280.11 + ,286.85 + ,294.93 + ,294.77 + ,299.37 + ,287.1 + ,297.46 + ,298.88 + ,288.74 + ,288.32 + ,286.32 + ,254.34 + ,247.09 + ,247.29 + ,255.49 + ,267.26 + ,276.44 + ,260.07 + ,267.1 + ,273.81 + ,290.37 + ,293.98 + ,302.36 + ,289.92 + ,283.27 + ,279.87 + ,267.66 + ,286.88 + ,309.69 + ,323.95 + ,315.36 + ,327.52 + ,325.69 + ,326.92 + ,328.26 + ,348.94 + ,340.53 + ,330.29 + ,335.91 + ,376.13 + ,444.11 + ,516.35 + ,529.16 + ,525.07 + ,519.78 + ,548.84 + ,539.68 + ,534.99 + ,584.34 + ,664.34 + ,691.81 + ,689.34 + ,725.81 + ,734.89 + ,681.58 + ,685.72 + ,633.01 + ,680.28 + ,684.95 + ,653.47 + ,647.28 + ,602.73 + ,589.76 + ,588.41 + ,613.51 + ,611.93 + ,587.69 + ,554.63 + ,533.09 + ,560.59 + ,553.05 + ,528.97 + ,500.93 + ,508.86 + ,537.86 + ,547.3 + ,556.94 + ,549.33 + ,545.18 + ,543.69 + ,543.49 + ,553.32 + ,563.57 + ,531.87 + ,517.85 + ,500.83 + ,481.51 + ,479.73 + ,496.6 + ,520.76 + ,528.71 + ,515.46 + ,522 + ,515.63 + ,522.87 + ,534.29 + ,521.83 + ,524.66 + ,640.02 + ,644.21 + ,715.51 + ,706.96 + ,724.75 + ,742.55 + ,788.25 + ,787.58 + ,761.64 + ,732.83 + ,765.24 + ,807.45 + ,828.19 + ,817.45 + ,840.86 + ,843.77 + ,835.3 + ,823.97 + ,781.49 + ,778.46 + ,793.63 + ,717.57 + ,656.35 + ,510.28 + ,450.98 + ,477.83 + ,464.59 + ,449.72 + ,460.47 + ,516.6 + ,599.31 + ,609.15 + ,609.3 + ,655.49 + ,690.91 + ,743.59 + ,756.8 + ,780.4 + ,842.74 + ,818.72 + ,847.84 + ,817.97 + ,763.94 + ,762.81 + ,777.29 + ,786.94 + ,766.28) > par20 = '' > par19 = '' > par18 = '' > par17 = '' > par16 = '' > par15 = '' > par14 = '' > par13 = '' > par12 = '' > par11 = '' > par10 = '' > par9 = '' > par8 = '' > par7 = '' > par6 = '' > par5 = '' > par4 = '' > par3 = '' > par2 = '' > 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 -248.99 -99.88 -38.25 58.47 720.45 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 347.73869 30.24105 11.50 <2e-16 *** x 0.84648 0.06107 13.86 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 163.2 on 367 degrees of freedom Multiple R-squared: 0.3436, Adjusted R-squared: 0.3418 F-statistic: 192.1 on 1 and 367 DF, p-value: < 2.2e-16 > postscript(file="/var/wessaorg/rcomp/tmp/1fx3k1321397859.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/2g1fs1321397859.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 -6.316e-13 -2.809e-14 -5.400e-16 2.898e-14 1.388e-13 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 3.477e+02 9.336e-15 3.725e+16 <2e-16 *** x 8.465e-01 1.885e-17 4.490e+16 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 5.038e-14 on 367 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 1 F-statistic: 2.016e+33 on 1 and 367 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/348rd1321397859.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 -248.99 -99.88 -38.25 58.47 720.45 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -3.826e-15 3.024e+01 0 1 x 6.975e-18 6.107e-02 0 1 Residual standard error: 163.2 on 367 degrees of freedom Multiple R-squared: 2.092e-35, Adjusted R-squared: -0.002725 F-statistic: 7.676e-33 on 1 and 367 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/4lkoq1321397859.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 -193.13 -87.43 -21.05 60.99 315.39 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 7.500e+02 6.147e+00 122 <2e-16 *** m$residuals 2.510e-17 3.777e-02 0 1 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 118.1 on 367 degrees of freedom Multiple R-squared: 4.042e-32, Adjusted R-squared: -0.002725 F-statistic: 1.483e-29 on 1 and 367 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/5bqai1321397859.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 -286.117 -18.792 -1.375 16.291 193.984 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.26384 2.12215 0.124 0.901 Residuals 0.96762 0.01302 74.302 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 40.71 on 366 degrees of freedom (2 observations deleted due to missingness) Multiple R-squared: 0.9378, Adjusted R-squared: 0.9377 F-statistic: 5521 on 1 and 366 DF, p-value: < 2.2e-16 > abline(m5) > grid() > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/6ofao1321397859.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/7oxc31321397859.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/8d4ht1321397859.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/92kei1321397859.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/10mtbq1321397859.tab") > > try(system("convert tmp/1fx3k1321397859.ps tmp/1fx3k1321397859.png",intern=TRUE)) character(0) > try(system("convert tmp/2g1fs1321397859.ps tmp/2g1fs1321397859.png",intern=TRUE)) character(0) > try(system("convert tmp/348rd1321397859.ps tmp/348rd1321397859.png",intern=TRUE)) character(0) > try(system("convert tmp/4lkoq1321397859.ps tmp/4lkoq1321397859.png",intern=TRUE)) character(0) > try(system("convert tmp/5bqai1321397859.ps tmp/5bqai1321397859.png",intern=TRUE)) character(0) > try(system("convert tmp/6ofao1321397859.ps tmp/6ofao1321397859.png",intern=TRUE)) character(0) > try(system("convert tmp/7oxc31321397859.ps tmp/7oxc31321397859.png",intern=TRUE)) character(0) > try(system("convert tmp/8d4ht1321397859.ps tmp/8d4ht1321397859.png",intern=TRUE)) character(0) > try(system("convert tmp/92kei1321397859.ps tmp/92kei1321397859.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.866 0.529 3.441