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(2756.76,2849.27,2921.44,2981.85,3080.58,3106.22,3119.31,3061.26,3097.31,3161.69,3257.16,3277.01,3295.32,3363.99,3494.17,3667.03,3813.06,3917.96,3895.51,3801.06,3570.12,3701.61,3862.27,3970.10,4138.52,4199.75,4290.89,4443.91,4502.64,4356.98,4591.27,4696.96,4621.40,4562.84,4202.52,4296.49,4435.23,4105.18,4116.68,3844.49,3720.98,3674.40,3857.62,3801.06,3504.37,3032.60,3047.03,2962.34,2197.82,2014.45,1862.83,1905.41,1810.99,1670.07,1864.44,2052.02,2029.60,2070.83,2293.41) > x <- c(3016.70,3052.40,3099.60,3103.30,3119.80,3093.70,3164.90,3311.50,3410.60,3392.60,3338.20,3285.10,3294.80,3611.20,3611.30,3521.00,3519.30,3438.30,3534.90,3705.80,3807.60,3663.00,3604.50,3563.80,3511.40,3546.50,3525.40,3529.90,3591.60,3668.30,3728.80,3853.60,3897.70,3640.70,3495.50,3495.10,3268.00,3479.10,3417.80,3521.30,3487.10,3529.90,3544.30,3710.80,3641.90,3447.10,3386.80,3438.50,3364.30,3462.70,3291.90,3550.00,3611.00,3708.60,3771.10,4042.70,3988.40,3851.20,3876.70) > 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 -1753.7 -364.6 93.2 649.2 1245.8 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 2724.0442 1711.2043 1.592 0.117 x 0.1887 0.4864 0.388 0.700 Residual standard error: 854 on 57 degrees of freedom Multiple R-squared: 0.002633, Adjusted R-squared: -0.01486 F-statistic: 0.1505 on 1 and 57 DF, p-value: 0.6995 > postscript(file="/var/www/html/rcomp/tmp/1pzv01258154493.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/2ijlf1258154493.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.534e-12 -6.861e-14 4.684e-14 2.001e-13 4.986e-13 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 2.724e+03 1.040e-12 2.620e+15 <2e-16 *** x 1.887e-01 2.956e-16 6.383e+14 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 5.19e-13 on 57 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 1 F-statistic: 4.075e+29 on 1 and 57 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/360fl1258154493.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 -1753.7 -364.6 93.2 649.2 1245.8 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -2.960e-14 1.711e+03 -1.73e-17 1 x 0.000e+00 4.864e-01 0 1 Residual standard error: 854 on 57 degrees of freedom Multiple R-squared: 2.018e-34, Adjusted R-squared: -0.01754 F-statistic: 1.15e-32 on 1 and 57 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/4n6641258154493.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 -93.231 -22.856 1.973 24.614 100.347 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 3.386e+03 5.712e+00 592.8 <2e-16 *** m$residuals 9.037e-17 6.806e-03 1.33e-14 1 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 43.88 on 57 degrees of freedom Multiple R-squared: 1.884e-30, Adjusted R-squared: -0.01754 F-statistic: 1.074e-28 on 1 and 57 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/5ckig1258154493.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 -744.17 -84.64 39.10 126.61 243.14 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -10.58000 24.22254 -0.437 0.664 Residuals 0.98970 0.02909 34.024 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 184.4 on 56 degrees of freedom (2 observations deleted due to missingness) Multiple R-squared: 0.9539, Adjusted R-squared: 0.953 F-statistic: 1158 on 1 and 56 DF, p-value: < 2.2e-16 > abline(m5) > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/6uent1258154493.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/7l7mc1258154493.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/8xbr91258154493.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/9u9t51258154493.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/10j8wp1258154493.tab") > > system("convert tmp/1pzv01258154493.ps tmp/1pzv01258154493.png") > system("convert tmp/2ijlf1258154493.ps tmp/2ijlf1258154493.png") > system("convert tmp/360fl1258154493.ps tmp/360fl1258154493.png") > system("convert tmp/4n6641258154493.ps tmp/4n6641258154493.png") > system("convert tmp/5ckig1258154493.ps tmp/5ckig1258154493.png") > system("convert tmp/6uent1258154493.ps tmp/6uent1258154493.png") > system("convert tmp/7l7mc1258154493.ps tmp/7l7mc1258154493.png") > system("convert tmp/8xbr91258154493.ps tmp/8xbr91258154493.png") > system("convert tmp/9u9t51258154493.ps tmp/9u9t51258154493.png") > > > proc.time() user system elapsed 1.824 1.361 2.281