R version 2.9.0 (2009-04-17) Copyright (C) 2009 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(255,280.2,299.9,339.2,374.2,393.5,389.2,381.7,375.2,369,357.4,352.1,346.5,342.9,340.3,328.3,322.9,314.3,308.9,294,285.6,281.2,280.3,278.8,274.5,270.4,263.4,259.9,258,262.7,284.7,311.3,322.1,327,331.3,333.3,321.4,327,320,314.7,316.7,314.4,321.3,318.2,307.2,301.3,287.5,277.7,274.4) > x <- c(87.28,87.28,87.09,86.92,87.59,90.72,90.69,90.3,89.55,88.94,88.41,87.82,87.07,86.82,86.4,86.02,85.66,85.32,85,84.67,83.94,82.83,81.95,81.19,80.48,78.86,69.47,68.77,70.06,73.95,75.8,77.79,81.57,83.07,84.34,85.1,85.25,84.26,83.63,86.44,85.3,84.1,83.36,82.48,81.58,80.47,79.34,82.13,81.69) > 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.443 -15.289 4.911 14.867 40.816 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -128.3629 58.2459 -2.204 0.0325 * x 5.3025 0.6967 7.610 9.77e-10 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 24.68 on 47 degrees of freedom Multiple R-squared: 0.552, Adjusted R-squared: 0.5425 F-statistic: 57.92 on 1 and 47 DF, p-value: 9.77e-10 > postscript(file="/var/www/html/rcomp/tmp/1fwy91290627442.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/rcomp/tmp/285xc1290627442.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.698e-14 -1.564e-14 2.650e-15 1.118e-14 2.924e-14 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -1.284e+02 4.018e-14 -3.194e+15 <2e-16 *** x 5.303e+00 4.807e-16 1.103e+16 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 1.703e-14 on 47 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 1 F-statistic: 1.217e+32 on 1 and 47 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/rcomp/tmp/30xfx1290627442.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 -79.443 -15.289 4.911 14.867 40.816 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 3.144e-14 5.825e+01 5.40e-16 1 x -4.012e-16 6.967e-01 -5.76e-16 1 Residual standard error: 24.68 on 47 degrees of freedom Multiple R-squared: 3.989e-32, Adjusted R-squared: -0.02128 F-statistic: 1.875e-30 on 1 and 47 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/rcomp/tmp/40xfx1290627442.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 -77.809 -9.883 4.752 18.432 38.582 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 3.141e+02 3.914e+00 80.25 <2e-16 *** m$residuals -8.398e-17 1.619e-01 -5.19e-16 1 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 27.4 on 47 degrees of freedom Multiple R-squared: 1.831e-31, Adjusted R-squared: -0.02128 F-statistic: 8.608e-30 on 1 and 47 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/rcomp/tmp/5bow01290627442.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 -26.9962 -7.3939 -0.1038 4.0330 36.7186 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.18141 1.74315 0.678 0.501 Residuals 0.74784 0.07255 10.308 1.54e-13 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 12.07 on 46 degrees of freedom (2 observations deleted due to missingness) Multiple R-squared: 0.6979, Adjusted R-squared: 0.6913 F-statistic: 106.2 on 1 and 46 DF, p-value: 1.539e-13 > abline(m5) > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/6mxd31290627442.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/rcomp/tmp/7mxd31290627442.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/rcomp/tmp/8woco1290627442.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/rcomp/tmp/9woco1290627442.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/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/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/rcomp/tmp/10sgsx1290627442.tab") > > try(system("convert tmp/1fwy91290627442.ps tmp/1fwy91290627442.png",intern=TRUE)) character(0) > try(system("convert tmp/285xc1290627442.ps tmp/285xc1290627442.png",intern=TRUE)) character(0) > try(system("convert tmp/30xfx1290627442.ps tmp/30xfx1290627442.png",intern=TRUE)) character(0) > try(system("convert tmp/40xfx1290627442.ps tmp/40xfx1290627442.png",intern=TRUE)) character(0) > try(system("convert tmp/5bow01290627442.ps tmp/5bow01290627442.png",intern=TRUE)) character(0) > try(system("convert tmp/6mxd31290627442.ps tmp/6mxd31290627442.png",intern=TRUE)) character(0) > try(system("convert tmp/7mxd31290627442.ps tmp/7mxd31290627442.png",intern=TRUE)) character(0) > try(system("convert tmp/8woco1290627442.ps tmp/8woco1290627442.png",intern=TRUE)) character(0) > try(system("convert tmp/9woco1290627442.ps tmp/9woco1290627442.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.844 1.384 4.219