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(330,331.6,351.2,389.4,410.9,442.8,462.8,466.9,461.7,439.2,430.3,416.1,402.5,397.3,403.3,395.9,387.8,378.6,377.1,370.4,362,350.3,348.2,344.6,343.5,342.8,347.6,346.6,349.5,342.1,342,342.8,339.3,348.2,333.7,334.7,354,367.7,363.3,358.4,353.1,343.1,344.6,344.4,333.9,331.7,324.3,321.2,322.4,321.7,320.5,312.8,309.7,315.6,309.7,304.6,302.5,301.5,298.8,291.3,293.6,294.6,285.9,297.6,301.1,293.8,297.7,292.9,292.1,287.2,288.2,283.8,299.9,292.4,293.3,300.8,293.7,293.1,294.4,292.1,291.9,282.5,277.9,287.5,289.2,285.6,293.2,290.8,283.1,275,287.8,287.8,287.4,284,277.8,277.6,304.9,294,300.9,324,332.9,341.6,333.4,348.2,344.7,344.7,329.3,323.5,323.2,317.4,330.1,329.2,334.9,315.8,315.4,319.6,317.3,313.8,315.8,311.3) > x <- c(94.45,113.44,157.33,147.38,171.89,171.95,132.71,126.02,121.18,115.45,110.48,117.85,117.63,124.65,109.59,111.27,99.78,98.21,99.2,97.97,89.55,87.91,93.34,94.42,93.2,90.29,91.46,89.98,88.35,88.41,82.44,79.89,75.69,75.66,84.5,96.73,87.48,82.39,83.48,79.31,78.16,72.77,72.45,68.46,67.62,68.76,70.07,68.55,65.3,58.96,59.17,62.37,66.28,55.62,55.23,55.85,56.75,50.89,53.88,52.95,55.08,53.61,58.78,61.85,55.91,53.32,46.41,44.57,50,50,53.36,46.23,50.45,49.07,45.85,48.45,49.96,46.53,50.51,47.58,48.05,46.84,47.67,49.16,55.54,55.82,58.22,56.19,57.77,63.19,54.76,55.74,62.54,61.39,69.6,79.23,80,93.68,107.63,100.18,97.3,90.45,80.64,80.58,75.82,85.59,89.35,89.42,104.73,95.32,89.27,90.44,86.97,79.98,81.22,87.35,83.64,82.22,94.4,102.18) > 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 -79.151 -13.784 1.209 13.582 77.833 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 228.04637 7.35497 31.01 <2e-16 *** x 1.28586 0.08792 14.62 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 25.55 on 118 degrees of freedom Multiple R-squared: 0.6445, Adjusted R-squared: 0.6415 F-statistic: 213.9 on 1 and 118 DF, p-value: < 2.2e-16 > postscript(file="/var/wessaorg/rcomp/tmp/1jof71321539876.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/2guq81321539876.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 -3.032e-14 -1.222e-14 -3.423e-15 1.299e-14 6.665e-14 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 2.280e+02 4.762e-15 4.789e+16 <2e-16 *** x 1.286e+00 5.692e-17 2.259e+16 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 1.654e-14 on 118 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 1 F-statistic: 5.103e+32 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/wessaorg/rcomp/tmp/35cxd1321539876.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 -79.151 -13.784 1.209 13.582 77.833 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -4.622e-16 7.355e+00 0 1 x 1.658e-17 8.792e-02 0 1 Residual standard error: 25.55 on 118 degrees of freedom Multiple R-squared: 8.445e-33, Adjusted R-squared: -0.008475 F-statistic: 9.965e-31 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/wessaorg/rcomp/tmp/40bq41321539876.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 -44.707 -30.212 0.337 18.114 119.086 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 3.301e+02 3.140e+00 105.1 <2e-16 *** m$residuals 1.315e-17 1.239e-01 0.0 1 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 34.4 on 118 degrees of freedom Multiple R-squared: 5.207e-30, Adjusted R-squared: -0.008475 F-statistic: 6.144e-28 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/wessaorg/rcomp/tmp/5kmvg1321539876.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 -43.132 -6.555 -0.729 5.542 69.664 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -0.17878 1.28715 -0.139 0.89 Residuals 0.84699 0.05137 16.487 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 14.04 on 117 degrees of freedom (2 observations deleted due to missingness) Multiple R-squared: 0.6991, Adjusted R-squared: 0.6965 F-statistic: 271.8 on 1 and 117 DF, p-value: < 2.2e-16 > abline(m5) > grid() > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/63w2b1321539876.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/7g4u51321539876.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/8e87x1321539877.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/9xm4d1321539877.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/10hvln1321539877.tab") > > try(system("convert tmp/1jof71321539876.ps tmp/1jof71321539876.png",intern=TRUE)) character(0) > try(system("convert tmp/2guq81321539876.ps tmp/2guq81321539876.png",intern=TRUE)) character(0) > try(system("convert tmp/35cxd1321539876.ps tmp/35cxd1321539876.png",intern=TRUE)) character(0) > try(system("convert tmp/40bq41321539876.ps tmp/40bq41321539876.png",intern=TRUE)) character(0) > try(system("convert tmp/5kmvg1321539876.ps tmp/5kmvg1321539876.png",intern=TRUE)) character(0) > try(system("convert tmp/63w2b1321539876.ps tmp/63w2b1321539876.png",intern=TRUE)) character(0) > try(system("convert tmp/7g4u51321539876.ps tmp/7g4u51321539876.png",intern=TRUE)) character(0) > try(system("convert tmp/8e87x1321539877.ps tmp/8e87x1321539877.png",intern=TRUE)) character(0) > try(system("convert tmp/9xm4d1321539877.ps tmp/9xm4d1321539877.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.605 0.422 3.100