R version 2.11.1 (2010-05-31) Copyright (C) 2010 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(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(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 -41.908 -10.319 -1.826 9.914 45.617 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 254.9321 8.1417 31.312 < 2e-16 *** x 0.8150 0.1167 6.982 6.96e-10 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 18.26 on 82 degrees of freedom Multiple R-squared: 0.3728, Adjusted R-squared: 0.3652 F-statistic: 48.75 on 1 and 82 DF, p-value: 6.96e-10 > postscript(file="/var/www/rcomp/tmp/1kd4i1290704201.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/rcomp/tmp/2kd4i1290704201.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 -3.090e-13 -1.233e-14 6.179e-15 1.601e-14 4.087e-14 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 2.549e+02 1.702e-14 1.498e+16 <2e-16 *** x 8.150e-01 2.440e-16 3.340e+15 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 3.816e-14 on 82 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 1 F-statistic: 1.116e+31 on 1 and 82 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/3vm4m1290704201.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 -41.908 -10.319 -1.826 9.914 45.617 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -2.343e-15 8.142e+00 -2.88e-16 1 x 3.951e-17 1.167e-01 3.38e-16 1 Residual standard error: 18.26 on 82 degrees of freedom Multiple R-squared: 2.986e-33, Adjusted R-squared: -0.0122 F-statistic: 2.449e-31 on 1 and 82 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/46wlo1290704201.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 -18.789 -11.472 -4.212 11.286 32.607 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 3.100e+02 1.536e+00 201.9 <2e-16 *** m$residuals -3.118e-16 8.514e-02 -3.66e-15 1 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 14.08 on 82 degrees of freedom Multiple R-squared: 3.181e-30, Adjusted R-squared: -0.0122 F-statistic: 2.609e-28 on 1 and 82 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/5z52r1290704201.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 -23.4657 -4.8990 -0.9446 4.6206 24.2200 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -0.61557 0.98903 -0.622 0.535 Residuals 0.86666 0.05523 15.690 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 9.009 on 81 degrees of freedom (2 observations deleted due to missingness) Multiple R-squared: 0.7524, Adjusted R-squared: 0.7494 F-statistic: 246.2 on 1 and 81 DF, p-value: < 2.2e-16 > abline(m5) > grid() > dev.off() null device 1 > postscript(file="/var/www/rcomp/tmp/6z52r1290704201.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/rcomp/tmp/7sw1c1290704201.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/rcomp/tmp/8sw1c1290704201.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/rcomp/tmp/9sw1c1290704201.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/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/10gxgo1290704201.tab") > try(system("convert tmp/1kd4i1290704201.ps tmp/1kd4i1290704201.png",intern=TRUE)) character(0) > try(system("convert tmp/2kd4i1290704201.ps tmp/2kd4i1290704201.png",intern=TRUE)) character(0) > try(system("convert tmp/3vm4m1290704201.ps tmp/3vm4m1290704201.png",intern=TRUE)) character(0) > try(system("convert tmp/46wlo1290704201.ps tmp/46wlo1290704201.png",intern=TRUE)) character(0) > try(system("convert tmp/5z52r1290704201.ps tmp/5z52r1290704201.png",intern=TRUE)) character(0) > try(system("convert tmp/6z52r1290704201.ps tmp/6z52r1290704201.png",intern=TRUE)) character(0) > try(system("convert tmp/7sw1c1290704201.ps tmp/7sw1c1290704201.png",intern=TRUE)) character(0) > try(system("convert tmp/8sw1c1290704201.ps tmp/8sw1c1290704201.png",intern=TRUE)) character(0) > try(system("convert tmp/9sw1c1290704201.ps tmp/9sw1c1290704201.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.780 0.930 3.678