R version 2.8.0 (2008-10-20) 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(103.63,103.64,103.66,103.77,103.88,103.91,103.91,103.92,104.05,104.23,104.30,104.31,104.31,104.34,104.55,104.65,104.73,104.75,104.75,104.76,104.94,105.29,105.38,105.43,105.43,105.42,105.52,105.69,105.72,105.74,105.74,105.74,105.95,106.17,106.34,106.37,106.37,106.36,106.44,106.29,106.23,106.23,106.23,106.23,106.34,106.44,106.44,106.48,106.50,106.57,106.40,106.37,106.25,106.21,106.21,106.24,106.19,106.08,106.13,106.09) > x <- c(100.30,98.50,95.10,93.10,92.20,89.00,86.40,84.50,82.70,80.80,81.80,81.80,82.90,83.80,86.20,86.10,86.20,88.80,89.60,87.80,88.30,88.60,91.00,91.50,95.40,98.70,99.90,98.60,100.30,100.20,100.40,101.40,103.00,109.10,111.40,114.10,121.80,127.60,129.90,128.00,123.50,124.00,127.40,127.60,128.40,131.40,135.10,134.00,144.50,147.30,150.90,148.70,141.40,138.90,139.80,145.60,147.90,148.50,151.10,157.50) > 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 -1.46587 -0.30151 0.04795 0.39805 0.88447 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.018e+02 3.609e-01 282.22 < 2e-16 *** x 3.240e-02 3.184e-03 10.18 1.61e-14 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.5846 on 58 degrees of freedom Multiple R-squared: 0.641, Adjusted R-squared: 0.6348 F-statistic: 103.6 on 1 and 58 DF, p-value: 1.614e-14 > postscript(file="/var/www/html/freestat/rcomp/tmp/1iv2o1256316677.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/html/freestat/rcomp/tmp/2c3p41256316677.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 -8.654e-15 -4.005e-15 -8.971e-17 1.911e-15 7.638e-14 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.018e+02 6.698e-15 1.521e+16 <2e-16 *** x 3.240e-02 5.910e-17 5.483e+14 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 1.085e-14 on 58 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 1 F-statistic: 3.006e+29 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/html/freestat/rcomp/tmp/3vgod1256316677.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 -1.46587 -0.30151 0.04795 0.39805 0.88447 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -1.535e-17 3.609e-01 -4.25e-17 1 x 1.571e-19 3.184e-03 4.93e-17 1 Residual standard error: 0.5846 on 58 degrees of freedom Multiple R-squared: 6.115e-34, Adjusted R-squared: -0.01724 F-statistic: 3.547e-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/html/freestat/rcomp/tmp/4pzbl1256316677.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.9733 -0.7092 -0.3398 0.6298 1.5119 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.054e+02 1.009e-01 1045 <2e-16 *** m$residuals -6.589e-15 1.755e-01 -3.76e-14 1 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.7812 on 58 degrees of freedom Multiple R-squared: 2.853e-28, Adjusted R-squared: -0.01724 F-statistic: 1.655e-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/html/freestat/rcomp/tmp/5t3jc1256316677.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.31295 -0.06416 0.01268 0.07007 0.34380 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.01120 0.01637 0.684 0.497 Residuals 0.93679 0.02878 32.547 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.1257 on 57 degrees of freedom (2 observations deleted due to missingness) Multiple R-squared: 0.9489, Adjusted R-squared: 0.948 F-statistic: 1059 on 1 and 57 DF, p-value: < 2.2e-16 > abline(m5) > grid() > dev.off() null device 1 > postscript(file="/var/www/html/freestat/rcomp/tmp/6698d1256316677.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/html/freestat/rcomp/tmp/7m0wt1256316677.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/html/freestat/rcomp/tmp/8aos81256316677.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/html/freestat/rcomp/tmp/9i2i51256316677.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/html/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/freestat/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/html/freestat/rcomp/tmp/10g78u1256316677.tab") > > system("convert tmp/1iv2o1256316677.ps tmp/1iv2o1256316677.png") > system("convert tmp/2c3p41256316677.ps tmp/2c3p41256316677.png") > system("convert tmp/3vgod1256316677.ps tmp/3vgod1256316677.png") > system("convert tmp/4pzbl1256316677.ps tmp/4pzbl1256316677.png") > system("convert tmp/5t3jc1256316677.ps tmp/5t3jc1256316677.png") > system("convert tmp/6698d1256316677.ps tmp/6698d1256316677.png") > system("convert tmp/7m0wt1256316677.ps tmp/7m0wt1256316677.png") > system("convert tmp/8aos81256316677.ps tmp/8aos81256316677.png") > system("convert tmp/9i2i51256316677.ps tmp/9i2i51256316677.png") > > > proc.time() user system elapsed 2.814 2.118 3.229