R version 2.12.1 (2010-12-16) Copyright (C) 2010 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-pc-linux-gnu (32-bit) 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(80,111,122,131,192,188,216,238,173,160,93,67,60,32,126,131,134,162,230,232,200,143,85,66,54,81,100,126,204,218,227,220,220,120,110,67,81,52,106,156,187,204,204,196,204,124,53,77,77,50,105,125,165,194,263,225,263,140,127,86,71,95,95,133,178,160,250,251,250,173,103,21,29,39,71,148,144,199,206,224,206,152,88,35,23,92,117,120,173,202,217,256,217,143,95,77,76,100,108,132,195,198,204,212,204,129,73,77,80,64,109,138,185,198,237,223,237,146,102,77,70,86,98,141,195,205,191,226,191,147,100,74,56,77,80,120,186,196,229,229,229,176,104,61,72,99,113,140,174,209,205,229,215,136,113,57,55,66,125,149,176,230,238,245,238,124,111,72,63,78,100,149,166,201,214,231,214,151,97,68,81,55,99,146,170,218,218,207,218,178,105,67,47,55,73,124,185,213,278,205,278,171,125,92,96,92,118,185,183,215,207,214,207,142,102,66,87,90,90,133,205,201,220,210,220,136,95,52,40,60,100,169,184,202,226,239,226,149,121,50) > x <- c(61,81,87,87,136,147,168,185,137,125,64,45,35,-4,88,85,95,128,186,182,151,106,60,44,30,54,72,88,153,168,181,180,149,84,85,42,54,30,96,110,141,159,164,155,135,93,28,56,56,22,76,83,121,151,208,179,139,99,103,57,44,70,58,91,126,146,199,194,145,131,74,-3,7,10,34,94,105,151,162,175,128,115,62,11,-7,64,80,77,127,158,173,206,147,103,73,52,52,68,77,94,147,160,166,167,155,104,44,53,56,36,76,99,142,150,190,176,175,112,73,52,48,61,68,97,146,160,155,175,163,117,82,55,32,48,53,82,139,150,184,185,138,147,77,32,48,72,76,94,133,164,174,187,149,102,86,35,31,28,75,102,133,178,190,190,147,83,83,46,40,50,61,102,117,158,170,190,155,117,68,40,56,28,66,103,122,166,176,164,160,139,75,44,22,32,42,86,140,163,222,166,183,140,98,69,75,63,81,126,139,171,170,173,144,105,75,41,68,53,61,87,155,159,180,175,138,105,73,26,12,35,64,115,138,138,182,191,155,113,98,29) > 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 -31.861 -6.002 -2.068 2.659 79.365 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 20.2933 1.7593 11.54 <2e-16 *** x 1.1751 0.0148 79.38 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 12.15 on 238 degrees of freedom Multiple R-squared: 0.9636, Adjusted R-squared: 0.9635 F-statistic: 6301 on 1 and 238 DF, p-value: < 2.2e-16 > postscript(file="/var/www/rcomp/tmp/1zvyf1321548082.ps",horizontal=F,onefile=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/2ujdu1321548082.ps",horizontal=F,onefile=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.199e-13 -3.903e-15 9.330e-16 5.858e-15 4.042e-14 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 2.029e+01 1.630e-15 1.245e+16 <2e-16 *** x 1.175e+00 1.371e-17 8.568e+16 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 1.126e-14 on 238 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 1 F-statistic: 7.342e+33 on 1 and 238 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/3yfkl1321548082.ps",horizontal=F,onefile=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 -31.861 -6.002 -2.068 2.659 79.365 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -1.662e-16 1.759e+00 0 1 x 2.858e-19 1.480e-02 0 1 Residual standard error: 12.15 on 238 degrees of freedom Multiple R-squared: 2.466e-34, Adjusted R-squared: -0.004202 F-statistic: 5.87e-32 on 1 and 238 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/4e6em1321548082.ps",horizontal=F,onefile=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 -133.224 -52.435 -5.136 55.382 135.878 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.453e+02 4.037e+00 35.99 <2e-16 *** m$residuals -6.353e-17 3.335e-01 0.00 1 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 62.53 on 238 degrees of freedom Multiple R-squared: 1.415e-31, Adjusted R-squared: -0.004202 F-statistic: 3.367e-29 on 1 and 238 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/57jy71321548082.ps",horizontal=F,onefile=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 -31.635 -6.165 -2.172 2.742 79.153 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.05063 0.78586 0.064 0.949 Residuals -0.02869 0.06481 -0.443 0.658 Residual standard error: 12.15 on 237 degrees of freedom (2 observations deleted due to missingness) Multiple R-squared: 0.0008258, Adjusted R-squared: -0.00339 F-statistic: 0.1959 on 1 and 237 DF, p-value: 0.6585 > abline(m5) > grid() > dev.off() null device 1 > postscript(file="/var/www/rcomp/tmp/622hb1321548082.ps",horizontal=F,onefile=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/7gmjf1321548082.ps",horizontal=F,onefile=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/8oc0n1321548082.ps",horizontal=F,onefile=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/97y321321548082.ps",horizontal=F,onefile=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/10igwg1321548082.tab") > > try(system("convert tmp/1zvyf1321548082.ps tmp/1zvyf1321548082.png",intern=TRUE)) character(0) > try(system("convert tmp/2ujdu1321548082.ps tmp/2ujdu1321548082.png",intern=TRUE)) character(0) > try(system("convert tmp/3yfkl1321548082.ps tmp/3yfkl1321548082.png",intern=TRUE)) character(0) > try(system("convert tmp/4e6em1321548082.ps tmp/4e6em1321548082.png",intern=TRUE)) character(0) > try(system("convert tmp/57jy71321548082.ps tmp/57jy71321548082.png",intern=TRUE)) character(0) > try(system("convert tmp/622hb1321548082.ps tmp/622hb1321548082.png",intern=TRUE)) character(0) > try(system("convert tmp/7gmjf1321548082.ps tmp/7gmjf1321548082.png",intern=TRUE)) character(0) > try(system("convert tmp/8oc0n1321548082.ps tmp/8oc0n1321548082.png",intern=TRUE)) character(0) > try(system("convert tmp/97y321321548082.ps tmp/97y321321548082.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.020 0.536 3.804