R version 2.13.0 (2011-04-13) Copyright (C) 2011 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(1.358,1.361,1.358,1.356,1.355,1.346,1.345,1.346,1.338,1.326,1.321,1.32,1.322,1.323,1.324,1.322,1.321,1.321,1.32,1.31,1.309,1.31,1.308,1.309,1.308,1.313,1.316,1.316,1.317,1.32,1.325,1.327,1.331,1.335,1.335,1.335,1.337,1.338,1.339,1.343,1.349,1.354,1.354,1.355,1.354,1.353,1.352,1.356,1.355,1.355,1.356,1.355,1.355,1.353,1.354,1.352,1.351,1.352,1.352,1.352,1.349,1.349,1.349,1.341,1.341,1.342,1.34,1.339,1.338,1.34,1.344,1.344,1.346,1.35,1.35,1.348,1.348,1.359,1.359,1.361,1.369,1.37,1.372,1.374,1.378,1.378,1.379,1.381,1.382,1.381,1.382,1.381,1.381,1.382,1.361,1.381,1.381,1.384,1.384,1.383,1.382,1.384) > x <- c(1.671,1.672,1.672,1.672,1.669,1.658,1.656,1.656,1.649,1.636,1.628,1.625,1.627,1.627,1.627,1.627,1.625,1.625,1.623,1.615,1.614,1.615,1.613,1.612,1.618,1.623,1.628,1.628,1.628,1.63,1.639,1.636,1.646,1.655,1.662,1.662,1.663,1.666,1.668,1.674,1.682,1.686,1.686,1.687,1.686,1.685,1.678,1.678,1.679,1.678,1.679,1.681,1.68,1.679,1.681,1.668,1.667,1.667,1.659,1.648,1.642,1.641,1.67,1.634,1.633,1.634,1.629,1.624,1.62,1.621,1.627,1.627,1.628,1.635,1.638,1.64,1.641,1.641,1.64,1.641,1.645,1.645,1.644,1.644,1.635,1.634,1.635,1.633,1.631,1.63,1.631,1.63,1.629,1.63,1.634,1.623,1.621,1.62,1.621,1.621,1.621,1.621) > 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.035128 -0.015903 -0.000986 0.007230 0.040504 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.04537 0.15686 6.664 1.47e-09 *** x 0.18403 0.09537 1.930 0.0565 . --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.02119 on 100 degrees of freedom Multiple R-squared: 0.0359, Adjusted R-squared: 0.02626 F-statistic: 3.724 on 1 and 100 DF, p-value: 0.05648 > postscript(file="/var/wessaorg/rcomp/tmp/1ldpr1321549213.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/wessaorg/rcomp/tmp/2qs511321549213.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.212e-16 -4.488e-17 -9.400e-19 3.493e-17 7.445e-16 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.045e+00 7.048e-16 1.483e+15 <2e-16 *** x 1.840e-01 4.285e-16 4.294e+14 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 9.521e-17 on 100 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 1 F-statistic: 1.844e+29 on 1 and 100 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/wessaorg/rcomp/tmp/3avyw1321549213.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 -0.035128 -0.015903 -0.000986 0.007230 0.040504 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -2.290e-17 1.569e-01 0 1 x 1.372e-17 9.537e-02 0 1 Residual standard error: 0.02119 on 100 degrees of freedom Multiple R-squared: 4.798e-34, Adjusted R-squared: -0.01 F-statistic: 4.798e-32 on 1 and 100 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/wessaorg/rcomp/tmp/4um9l1321549213.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.006015 -0.003255 -0.001414 0.004060 0.007787 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.348e+00 4.048e-04 3330 <2e-16 *** m$residuals 3.329e-16 1.930e-02 0 1 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.004089 on 100 degrees of freedom Multiple R-squared: 7.373e-28, Adjusted R-squared: -0.01 F-statistic: 7.373e-26 on 1 and 100 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/wessaorg/rcomp/tmp/5c0fc1321549213.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 -0.0220432 -0.0011644 -0.0000626 0.0014670 0.0216929 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.0003481 0.0004139 0.841 0.402 Residuals 0.9988827 0.0199944 49.958 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.004158 on 99 degrees of freedom (2 observations deleted due to missingness) Multiple R-squared: 0.9618, Adjusted R-squared: 0.9615 F-statistic: 2496 on 1 and 99 DF, p-value: < 2.2e-16 > abline(m5) > grid() > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/6supb1321549213.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/wessaorg/rcomp/tmp/72a6v1321549213.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/wessaorg/rcomp/tmp/8ita41321549213.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/wessaorg/rcomp/tmp/960vx1321549213.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/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/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/wessaorg/rcomp/tmp/10s0z31321549213.tab") > > try(system("convert tmp/1ldpr1321549213.ps tmp/1ldpr1321549213.png",intern=TRUE)) character(0) > try(system("convert tmp/2qs511321549213.ps tmp/2qs511321549213.png",intern=TRUE)) character(0) > try(system("convert tmp/3avyw1321549213.ps tmp/3avyw1321549213.png",intern=TRUE)) character(0) > try(system("convert tmp/4um9l1321549213.ps tmp/4um9l1321549213.png",intern=TRUE)) character(0) > try(system("convert tmp/5c0fc1321549213.ps tmp/5c0fc1321549213.png",intern=TRUE)) character(0) > try(system("convert tmp/6supb1321549213.ps tmp/6supb1321549213.png",intern=TRUE)) character(0) > try(system("convert tmp/72a6v1321549213.ps tmp/72a6v1321549213.png",intern=TRUE)) character(0) > try(system("convert tmp/8ita41321549213.ps tmp/8ita41321549213.png",intern=TRUE)) character(0) > try(system("convert tmp/960vx1321549213.ps tmp/960vx1321549213.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.575 0.432 3.556