R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i686-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(9.769,9.321,9.939,9.336,10.195,9.464,10.010,10.213,9.563,9.890,9.305,9.391,9.928,8.686,9.843,9.627,10.074,9.503,10.119,10.000,9.313,9.866,9.172,9.241,9.659,8.904,9.755,9.080,9.435,8.971,10.063,9.793,9.454,9.759,8.820,9.403,9.676,8.642,9.402,9.610,9.294,9.448,10.319,9.548,9.801,9.596,8.923,9.746,9.829,9.125,9.782,9.441,9.162,9.915,10.444,10.209,9.985,9.842,9.429,10.132,9.849,9.172,10.313,9.819,9.955,10.048,10.082,10.541,10.208,10.233,9.439,9.963,10.158,9.225,10.474,9.757,10.490,10.281,10.444,10.640,10.695,10.786,9.832,9.747,10.411,9.511,10.402,9.701,10.540,10.112,10.915,11.183,10.384,10.834,9.886,10.216,10.943,9.867,10.203,10.837,10.573,10.647,11.502,10.656,10.866,10.835,9.945,10.331,10.718,9.462,10.579,10.633,10.346,10.757,11.207,11.013,11.015,10.765,10.042,10.661) > x <- c(1579,2146,2462,3695,4831,5134,6250,5760,6249,2917,1741,2359,1511,2059,2635,2867,4403,5720,4502,5749,5627,2846,1762,2429,1169,2154,2249,2687,4359,5382,4459,6398,4596,3024,1887,2070,1351,2218,2461,3028,4784,4975,4607,6249,4809,3157,1910,2228,1594,2467,2222,3607,4685,4962,5770,5480,5000,3228,1993,2288,1580,2111,2192,3601,4665,4876,5813,5589,5331,3075,2002,2306,1507,1992,2487,3490,4647,5594,5611,5788,6204,3013,1931,2549,1504,2090,2702,2939,4500,6208,6415,5657,5964,3163,1997,2422,1.376,2.202,2.683,3.303,5.202,5.231,4.880,7.998,4.977,3.531,2.025,2.205,1.442,2.238,2.179,3.218,5.139,4.990,4.914,6.084,5.672,3.548,1.793,2.086) > par1 = '0' > par1 <- '0' > #'GNU S' R Code compiled by R2WASP v. 1.2.291 () > #Author: root > #To cite this work: Wessa P., (2012), Linear Regression Graphical Model Validation (v1.0.7) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_linear_regression.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > # > 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 -1.36472 -0.39812 -0.06532 0.44582 1.38508 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.012e+01 9.293e-02 108.870 <2e-16 *** x -4.980e-05 2.636e-05 -1.889 0.0613 . --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.5845 on 118 degrees of freedom Multiple R-squared: 0.02935, Adjusted R-squared: 0.02113 F-statistic: 3.568 on 1 and 118 DF, p-value: 0.06134 > postscript(file="/var/fisher/rcomp/tmp/12up21353803533.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/fisher/rcomp/tmp/2g85g1353803533.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.097e-15 -5.497e-16 7.458e-17 4.015e-16 1.029e-15 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.012e+01 8.691e-17 1.164e+17 <2e-16 *** x -4.980e-05 2.465e-20 -2.020e+15 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 5.467e-16 on 118 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 1 F-statistic: 4.08e+30 on 1 and 118 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/fisher/rcomp/tmp/3f5hy1353803533.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 -1.36472 -0.39812 -0.06532 0.44582 1.38508 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -4.884e-18 9.293e-02 0 1 x -4.743e-22 2.636e-05 0 1 Residual standard error: 0.5845 on 118 degrees of freedom Multiple R-squared: 1.299e-34, Adjusted R-squared: -0.008475 F-statistic: 1.533e-32 on 1 and 118 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/fisher/rcomp/tmp/4sg6b1353803533.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 -0.17572 -0.09080 0.02038 0.06506 0.14365 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 9.973e+00 9.279e-03 1075 <2e-16 *** m$residuals 7.645e-17 1.601e-02 0 1 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.1017 on 118 degrees of freedom Multiple R-squared: 3.131e-28, Adjusted R-squared: -0.008475 F-statistic: 3.695e-26 on 1 and 118 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/fisher/rcomp/tmp/5s50n1353803533.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 -1.2810 -0.4181 0.0368 0.3936 1.1386 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.004353 0.047865 0.091 0.928 Residuals 0.456774 0.082534 5.534 1.94e-07 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.5221 on 117 degrees of freedom (2 observations deleted due to missingness) Multiple R-squared: 0.2075, Adjusted R-squared: 0.2007 F-statistic: 30.63 on 1 and 117 DF, p-value: 1.94e-07 > abline(m5) > grid() > dev.off() null device 1 > postscript(file="/var/fisher/rcomp/tmp/64c5j1353803533.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/fisher/rcomp/tmp/7w7o11353803533.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/fisher/rcomp/tmp/82zgz1353803533.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/fisher/rcomp/tmp/907nb1353803533.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/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/fisher/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/fisher/rcomp/tmp/107ajc1353803533.tab") > > try(system("convert tmp/12up21353803533.ps tmp/12up21353803533.png",intern=TRUE)) character(0) > try(system("convert tmp/2g85g1353803533.ps tmp/2g85g1353803533.png",intern=TRUE)) character(0) > try(system("convert tmp/3f5hy1353803533.ps tmp/3f5hy1353803533.png",intern=TRUE)) character(0) > try(system("convert tmp/4sg6b1353803533.ps tmp/4sg6b1353803533.png",intern=TRUE)) character(0) > try(system("convert tmp/5s50n1353803533.ps tmp/5s50n1353803533.png",intern=TRUE)) character(0) > try(system("convert tmp/64c5j1353803533.ps tmp/64c5j1353803533.png",intern=TRUE)) character(0) > try(system("convert tmp/7w7o11353803533.ps tmp/7w7o11353803533.png",intern=TRUE)) character(0) > try(system("convert tmp/82zgz1353803533.ps tmp/82zgz1353803533.png",intern=TRUE)) character(0) > try(system("convert tmp/907nb1353803533.ps tmp/907nb1353803533.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 4.878 1.115 5.990