R version 2.11.1 (2010-05-31) Copyright (C) 2010 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(31.293,30.236,30.160,32.436,30.695,27.525,26.434,25.739,25.204,24.977,24.320,22.680,22.052,21.467,21.383,21.777,21.928,21.814,22.937,23.595,20.830,19.650,19.195,19.644,18.483,18.079,19.178,18.391,18.441,18.584,20.108,20.148,19.394,17.745,17.696,17.032,16.438,15.683,15.594,15.713,15.937,16.171,15.928,16.348,15.579,15.305,15.648,14.954,15.137,15.839) > x <- c(4797.4,4634.8,4424.2,4973.2,4616.7,4466.2,4758.4,3710.2,4189.8,4283.4,3984.8,4194.9,3942,3502.1,3531.6,3560.3,3477.3,3475.9,3954.1,3650.6,4283.1,4384,4460.3,5227.3,5894.8,4958.9,5384.9,5357.5,5027,5526.4,4744.1,4037.6,5363.5,4254.9,5126,5174.5,4329.7,4264.7,4711.9,4505.4,4608.3,4225.6,4623.4,4060.1,4570.6,3940.1,4610.6,4486.9,4029,3934.7) > 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 -5.8067 -4.4956 -0.7666 1.9180 12.2038 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 23.9798128 5.3275981 4.501 4.31e-05 *** x -0.0007536 0.0011888 -0.634 0.529 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 4.822 on 48 degrees of freedom Multiple R-squared: 0.008302, Adjusted R-squared: -0.01236 F-statistic: 0.4018 on 1 and 48 DF, p-value: 0.5292 > postscript(file="/var/www/rcomp/tmp/1cbpk1289926157.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/rcomp/tmp/2cbpk1289926157.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 -1.063e-14 -6.344e-16 1.067e-16 1.050e-15 2.141e-15 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 2.398e+01 2.081e-15 1.153e+16 <2e-16 *** x -7.536e-04 4.643e-19 -1.623e+15 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 1.883e-15 on 48 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 1 F-statistic: 2.635e+30 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/rcomp/tmp/3nlon1289926157.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 -5.8067 -4.4956 -0.7666 1.9180 12.2038 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -1.778e-15 5.328e+00 -3.34e-16 1 x 3.988e-19 1.189e-03 3.35e-16 1 Residual standard error: 4.822 on 48 degrees of freedom Multiple R-squared: 3.495e-33, Adjusted R-squared: -0.02083 F-statistic: 1.678e-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/rcomp/tmp/4gu5q1289926157.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 -1.092758 -0.233718 0.001827 0.311616 0.730030 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 2.063e+01 6.239e-02 330.7 <2e-16 *** m$residuals -5.050e-17 1.321e-02 -3.82e-15 1 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.4412 on 48 degrees of freedom Multiple R-squared: 1.351e-30, Adjusted R-squared: -0.02083 F-statistic: 6.485e-29 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/rcomp/tmp/5jv7n1289926158.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 -2.26887 -0.53675 -0.04386 0.51296 3.65801 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -0.32147 0.14511 -2.215 0.0316 * Residuals 0.93201 0.03078 30.282 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 1.016 on 47 degrees of freedom (2 observations deleted due to missingness) Multiple R-squared: 0.9512, Adjusted R-squared: 0.9502 F-statistic: 917 on 1 and 47 DF, p-value: < 2.2e-16 > abline(m5) > grid() > dev.off() null device 1 > postscript(file="/var/www/rcomp/tmp/6jv7n1289926158.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/rcomp/tmp/7cm781289926158.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/rcomp/tmp/8cm781289926158.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/rcomp/tmp/9cm781289926158.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/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/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/rcomp/tmp/10154k1289926158.tab") > > try(system("convert tmp/1cbpk1289926157.ps tmp/1cbpk1289926157.png",intern=TRUE)) character(0) > try(system("convert tmp/2cbpk1289926157.ps tmp/2cbpk1289926157.png",intern=TRUE)) character(0) > try(system("convert tmp/3nlon1289926157.ps tmp/3nlon1289926157.png",intern=TRUE)) character(0) > try(system("convert tmp/4gu5q1289926157.ps tmp/4gu5q1289926157.png",intern=TRUE)) character(0) > try(system("convert tmp/5jv7n1289926158.ps tmp/5jv7n1289926158.png",intern=TRUE)) character(0) > try(system("convert tmp/6jv7n1289926158.ps tmp/6jv7n1289926158.png",intern=TRUE)) character(0) > try(system("convert tmp/7cm781289926158.ps tmp/7cm781289926158.png",intern=TRUE)) character(0) > try(system("convert tmp/8cm781289926158.ps tmp/8cm781289926158.png",intern=TRUE)) character(0) > try(system("convert tmp/9cm781289926158.ps tmp/9cm781289926158.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.830 1.670 4.468