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(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,2443.27,2513.17,2466.92,2502.66,2539.91,2482.60,2626.15,2656.32,2446.66,2467.38,2462.32,2504.58,2579.39,2649.24) > x <- c(3.75,3.81,3.82,3.89,4.05,4.10,4.07,4.26,4.40,4.61,4.63,4.48,4.46,4.45,4.32,4.52,4.21,3.97,4.12,4.50,4.73,5.26,5.20,4.94,4.95,4.52,3.85,3.41,2.95,2.68,2.53,2.44,2.16,2.20,2.10,2.29,2.03,2.05,1.94,1.87,1.89,1.94,1.79,1.71,1.66,1.74,1.83,1.64,1.69,1.78) > 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 -1630.6 -448.1 182.7 475.2 935.4 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1309.38 294.26 4.450 5.10e-05 *** x 557.31 83.23 6.696 2.15e-08 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 709.3 on 48 degrees of freedom Multiple R-squared: 0.483, Adjusted R-squared: 0.4722 F-statistic: 44.84 on 1 and 48 DF, p-value: 2.15e-08 > postscript(file="/var/www/html/rcomp/tmp/13xs81290691377.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/23xs81290691377.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.099e-12 -4.575e-14 6.872e-14 1.875e-13 5.213e-13 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.309e+03 2.021e-13 6.478e+15 <2e-16 *** x 5.573e+02 5.717e-14 9.749e+15 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 4.872e-13 on 48 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 1 F-statistic: 9.504e+31 on 1 and 48 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/3vort1290691377.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 -1630.6 -448.1 182.7 475.2 935.4 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 2.826e-14 2.943e+02 9.61e-17 1 x -1.334e-14 8.323e+01 -1.60e-16 1 Residual standard error: 709.3 on 48 degrees of freedom Multiple R-squared: 2.676e-33, Adjusted R-squared: -0.02083 F-statistic: 1.285e-31 on 1 and 48 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/46g8e1290691377.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 -938.4 -718.3 273.8 620.7 1079.1 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 3.162e+03 9.695e+01 32.61 <2e-16 *** m$residuals -9.833e-17 1.395e-01 -7.05e-16 1 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 685.5 on 48 degrees of freedom Multiple R-squared: 9.168e-33, Adjusted R-squared: -0.02083 F-statistic: 4.401e-31 on 1 and 48 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/5zpqh1290691377.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 -593.17 -82.72 38.04 104.70 315.35 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -4.84223 27.39044 -0.177 0.86 Residuals 0.95885 0.03912 24.512 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 191.7 on 47 degrees of freedom (2 observations deleted due to missingness) Multiple R-squared: 0.9275, Adjusted R-squared: 0.9259 F-statistic: 600.9 on 1 and 47 DF, p-value: < 2.2e-16 > abline(m5) > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/6sy721290691377.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/7sy721290691377.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/82pon1290691377.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/92pon1290691377.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/10ghme1290691377.tab") > > try(system("convert tmp/13xs81290691377.ps tmp/13xs81290691377.png",intern=TRUE)) character(0) > try(system("convert tmp/23xs81290691377.ps tmp/23xs81290691377.png",intern=TRUE)) character(0) > try(system("convert tmp/3vort1290691377.ps tmp/3vort1290691377.png",intern=TRUE)) character(0) > try(system("convert tmp/46g8e1290691377.ps tmp/46g8e1290691377.png",intern=TRUE)) character(0) > try(system("convert tmp/5zpqh1290691377.ps tmp/5zpqh1290691377.png",intern=TRUE)) character(0) > try(system("convert tmp/6sy721290691377.ps tmp/6sy721290691377.png",intern=TRUE)) character(0) > try(system("convert tmp/7sy721290691377.ps tmp/7sy721290691377.png",intern=TRUE)) character(0) > try(system("convert tmp/82pon1290691377.ps tmp/82pon1290691377.png",intern=TRUE)) character(0) > try(system("convert tmp/92pon1290691377.ps tmp/92pon1290691377.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.848 1.385 7.676