R version 2.8.1 (2008-12-22) Copyright (C) 2008 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(4.611549793,4.611450424,4.609460967,4.613138356,4.618382517,4.62379565,4.623501143,4.625364893,4.627127353,4.631130288,4.631325143,4.630252966,4.628593701,4.631617356,4.632396172,4.632979887,4.637734177,4.636959508,4.64053733,4.643910014,4.643717596,4.646791861,4.648038086,4.64784646,4.647463098,4.649952329,4.650908078,4.653198155,4.658331734,4.656148431,4.659468959,4.657193214,4.656623468,4.660604893,4.66032103,4.660699496,4.665229942,4.672174415,4.676932552,4.680741373,4.688683786,4.694279361,4.695833221,4.702296897,4.706100905,4.711510222,4.708448535,4.71088064,4.712139407,4.710340684,4.711690029,4.71357606,4.716264233,4.710160633,4.711060561,4.709169776,4.705015521,4.704834509,4.706462437,4.704653464) > x <- c(4.615120517,4.613931692,4.610655116,4.61343593,4.620157316,4.626540212,4.628789052,4.630252966,4.633271616,4.639281716,4.640247713,4.641405679,4.639571613,4.639281716,4.639088404,4.639378357,4.643717596,4.643332647,4.648229675,4.651958347,4.651767471,4.65519768,4.65643348,4.653579325,4.651576559,4.654055584,4.655387902,4.6558633,4.661266925,4.661361466,4.665888921,4.664664758,4.664570529,4.668802046,4.667581446,4.668520501,4.673762977,4.683056725,4.685828089,4.689878914,4.69701984,4.704291277,4.7065528,4.71545854,4.720995751,4.726236714,4.720104724,4.721708002,4.719926423,4.713934901,4.711779921,4.712768197,4.716174744,4.710430697,4.712498764,4.711779921,4.709890497,4.709259895,4.712319102,4.709710365) > 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 -0.0073993 -0.0022116 -0.0005848 0.0024459 0.0081221 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.09650 0.06273 1.538 0.129 x 0.97797 0.01343 72.813 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.003595 on 58 degrees of freedom Multiple R-squared: 0.9892, Adjusted R-squared: 0.989 F-statistic: 5302 on 1 and 58 DF, p-value: < 2.2e-16 > postscript(file="/var/www/rcomp/tmp/1xp0n1256749554.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/2dt8d1256749554.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.828e-16 -1.571e-16 -4.716e-17 1.923e-16 4.765e-16 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 9.650e-02 4.038e-15 2.390e+13 <2e-16 *** x 9.780e-01 8.646e-16 1.131e+15 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 2.314e-16 on 58 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 1 F-statistic: 1.279e+30 on 1 and 58 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/3gz9v1256749554.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 -0.0073993 -0.0022116 -0.0005848 0.0024459 0.0081221 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 6.663e-18 6.273e-02 1.06e-16 1 x -1.408e-18 1.343e-02 -1.05e-16 1 Residual standard error: 0.003595 on 58 degrees of freedom Multiple R-squared: 4.785e-34, Adjusted R-squared: -0.01724 F-statistic: 2.775e-32 on 1 and 58 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/4kwr91256749555.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 -0.058193 -0.028403 -0.007034 0.038724 0.054843 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 4.664e+00 4.437e-03 1051 <2e-16 *** m$residuals -1.316e-15 1.255e+00 -1.05e-15 1 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.03437 on 58 degrees of freedom Multiple R-squared: 4.145e-28, Adjusted R-squared: -0.01724 F-statistic: 2.404e-26 on 1 and 58 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/54g671256749555.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 -0.0025750 -0.0009536 -0.0003179 0.0007611 0.0040254 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 6.748e-06 1.979e-04 0.034 0.973 Residuals 9.090e-01 5.570e-02 16.320 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.00152 on 57 degrees of freedom (2 observations deleted due to missingness) Multiple R-squared: 0.8237, Adjusted R-squared: 0.8206 F-statistic: 266.3 on 1 and 57 DF, p-value: < 2.2e-16 > abline(m5) > grid() > dev.off() null device 1 > postscript(file="/var/www/rcomp/tmp/6iw6o1256749555.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/72glo1256749555.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/8nqw91256749555.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/93hcj1256749555.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/10safh1256749555.tab") > > system("convert tmp/1xp0n1256749554.ps tmp/1xp0n1256749554.png") > system("convert tmp/2dt8d1256749554.ps tmp/2dt8d1256749554.png") > system("convert tmp/3gz9v1256749554.ps tmp/3gz9v1256749554.png") > system("convert tmp/4kwr91256749555.ps tmp/4kwr91256749555.png") > system("convert tmp/54g671256749555.ps tmp/54g671256749555.png") > system("convert tmp/6iw6o1256749555.ps tmp/6iw6o1256749555.png") > system("convert tmp/72glo1256749555.ps tmp/72glo1256749555.png") > system("convert tmp/8nqw91256749555.ps tmp/8nqw91256749555.png") > system("convert tmp/93hcj1256749555.ps tmp/93hcj1256749555.png") > > > proc.time() user system elapsed 2.060 1.860 3.986