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(2.55,2.27,2.26,2.57,3.07,2.76,2.51,2.87,3.14,3.11,3.16,2.47,2.57,2.89,2.63,2.38,1.69,1.96,2.19,1.87,1.60,1.63,1.22,1.21,1.49,1.64,1.66,1.77,1.82,1.78,1.28,1.29,1.37,1.12,1.51,2.24,2.94,3.09,3.46,3.64,4.39,4.15,5.21,5.80,5.91,5.39,5.46,4.72,3.14,2.63,2.32,1.93,0.62,0.60,-0.37,-1.10,-1.68,-0.78) > x <- c(-0.5348,-0.5591,-0.5200,-0.5173,-0.5153,-0.5048,-0.4950,-0.4597,-0.4681,-0.4909,-0.4579,-0.4758,-0.4662,-0.4821,-0.4767,-0.4740,-0.5295,-0.5075,-0.5222,-0.5377,-0.5108,-0.5197,-0.5292,-0.5024,-0.5175,-0.5088,-0.5180,-0.5177,-0.5027,-0.5002,-0.4882,-0.4603,-0.4687,-0.5092,-0.4729,-0.4488,-0.5085,-0.5142,-0.5130,-0.4721,-0.5425,-0.5123,-0.4845,-0.4950,-0.5024,-0.5349,-0.5861,-0.6495,-0.6751,-0.7095,-0.6941,-0.6794,-0.6559,-0.6051,-0.5713,-0.5532,-0.5341,-0.5315) > 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 -4.02914 -0.77701 -0.05206 0.68867 3.51042 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 3.199 1.798 1.779 0.0807 . x 1.591 3.398 0.468 0.6415 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 1.56 on 56 degrees of freedom Multiple R-squared: 0.003899, Adjusted R-squared: -0.01389 F-statistic: 0.2192 on 1 and 56 DF, p-value: 0.6415 > postscript(file="/var/www/rcomp/tmp/13g511256675085.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/2wzfd1256675085.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.640e-15 -1.396e-16 3.785e-17 1.846e-16 4.318e-16 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 3.199e+00 3.375e-16 9.477e+15 <2e-16 *** x 1.591e+00 6.378e-16 2.495e+15 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 2.927e-16 on 56 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 1 F-statistic: 6.223e+30 on 1 and 56 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/3ti261256675085.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 -4.02914 -0.77701 -0.05206 0.68867 3.51042 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -7.848e-18 1.798e+00 -4.36e-18 1 x -1.199e-17 3.398e+00 -3.53e-18 1 Residual standard error: 1.56 on 56 degrees of freedom Multiple R-squared: 0, Adjusted R-squared: -0.01786 F-statistic: 0 on 1 and 56 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/49jsk1256675085.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.29236 -0.01411 0.02085 0.05868 0.12245 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 2.362e+00 1.281e-02 184.4 <2e-16 *** m$residuals 2.136e-17 8.361e-03 2.55e-15 1 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.09758 on 56 degrees of freedom Multiple R-squared: 3.884e-29, Adjusted R-squared: -0.01786 F-statistic: 2.175e-27 on 1 and 56 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/5rh971256675085.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 -1.43769 -0.26339 0.06698 0.30352 1.10376 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -0.05757 0.06749 -0.853 0.397 Residuals 0.98277 0.04532 21.684 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.5092 on 55 degrees of freedom (2 observations deleted due to missingness) Multiple R-squared: 0.8953, Adjusted R-squared: 0.8934 F-statistic: 470.2 on 1 and 55 DF, p-value: < 2.2e-16 > abline(m5) > grid() > dev.off() null device 1 > postscript(file="/var/www/rcomp/tmp/6b4y71256675085.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/7n9221256675085.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/8xz701256675085.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/978es1256675085.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/10lfpm1256675085.tab") > > system("convert tmp/13g511256675085.ps tmp/13g511256675085.png") > system("convert tmp/2wzfd1256675085.ps tmp/2wzfd1256675085.png") > system("convert tmp/3ti261256675085.ps tmp/3ti261256675085.png") > system("convert tmp/49jsk1256675085.ps tmp/49jsk1256675085.png") > system("convert tmp/5rh971256675085.ps tmp/5rh971256675085.png") > system("convert tmp/6b4y71256675085.ps tmp/6b4y71256675085.png") > system("convert tmp/7n9221256675085.ps tmp/7n9221256675085.png") > system("convert tmp/8xz701256675085.ps tmp/8xz701256675085.png") > system("convert tmp/978es1256675085.ps tmp/978es1256675085.png") > > > proc.time() user system elapsed 2.090 1.790 3.698