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(99.9,98.6,107.2,95.7,93.7,106.7,86.7,95.3,99.3,101.8,96,91.7,95.3,96.6,107.2,108,98.4,103.1,81.1,96.6,103.7,106.6,97.6,87.6,99.4,98.5,105.2,104.6,97.5,108.9,86.8,88.9,110.3,114.8,94.6,92,93.8,93.8,107.6,101,95.4,96.5,89.2,87.1,110.5,110.8,104.2,88.9,89.8,90,93.9,91.3,87.8,99.7,73.5,79.2,96.9,95.2,95.6,89.7) > x <- c(98.8,100.5,110.4,96.4,101.9,106.2,81,94.7,101,109.4,102.3,90.7,96.2,96.1,106,103.1,102,104.7,86,92.1,106.9,112.6,101.7,92,97.4,97,105.4,102.7,98.1,104.5,87.4,89.9,109.8,111.7,98.6,96.9,95.1,97,112.7,102.9,97.4,111.4,87.4,96.8,114.1,110.3,103.9,101.6,94.6,95.9,104.7,102.8,98.1,113.9,80.9,95.7,113.2,105.9,108.8,102.3) > 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 -13.784 -3.387 1.176 3.580 9.089 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 16.33832 8.96028 1.823 0.0734 . x 0.80089 0.08875 9.024 1.21e-12 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 5.4 on 58 degrees of freedom Multiple R-squared: 0.5841, Adjusted R-squared: 0.5769 F-statistic: 81.44 on 1 and 58 DF, p-value: 1.208e-12 > postscript(file="/var/www/html/rcomp/tmp/1p7gz1258377427.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/265zj1258377427.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 -1.301e-13 -1.458e-15 1.973e-15 5.975e-15 1.011e-14 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.634e+01 3.011e-14 5.427e+14 <2e-16 *** x 8.009e-01 2.982e-16 2.686e+15 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 1.814e-14 on 58 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 1 F-statistic: 7.213e+30 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/rcomp/tmp/3j1pb1258377427.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 -13.784 -3.387 1.176 3.580 9.089 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -1.240e-15 8.960e+00 -1.38e-16 1 x 1.460e-17 8.875e-02 1.64e-16 1 Residual standard error: 5.4 on 58 degrees of freedom Multiple R-squared: 3.427e-33, Adjusted R-squared: -0.01724 F-statistic: 1.987e-31 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/rcomp/tmp/4o88s1258377427.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 -15.8243 -3.5907 0.7942 4.2180 10.7654 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 9.695e+01 8.261e-01 117.4 <2e-16 *** m$residuals -2.376e-16 1.556e-01 -1.53e-15 1 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 6.399 on 58 degrees of freedom Multiple R-squared: 8.504e-31, Adjusted R-squared: -0.01724 F-statistic: 4.932e-29 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/rcomp/tmp/57dzn1258377427.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 -11.136115 -3.196977 0.007273 2.679851 8.846909 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -0.1526 0.6004 -0.254 0.8 Residuals 0.5334 0.1147 4.652 2e-05 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 4.61 on 57 degrees of freedom (2 observations deleted due to missingness) Multiple R-squared: 0.2752, Adjusted R-squared: 0.2625 F-statistic: 21.64 on 1 and 57 DF, p-value: 2.001e-05 > abline(m5) > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/6b9j61258377427.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/7lvi81258377427.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/86wr01258377427.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/9qif91258377427.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/10qs991258377427.tab") > > system("convert tmp/1p7gz1258377427.ps tmp/1p7gz1258377427.png") > system("convert tmp/265zj1258377427.ps tmp/265zj1258377427.png") > system("convert tmp/3j1pb1258377427.ps tmp/3j1pb1258377427.png") > system("convert tmp/4o88s1258377427.ps tmp/4o88s1258377427.png") > system("convert tmp/57dzn1258377427.ps tmp/57dzn1258377427.png") > system("convert tmp/6b9j61258377427.ps tmp/6b9j61258377427.png") > system("convert tmp/7lvi81258377427.ps tmp/7lvi81258377427.png") > system("convert tmp/86wr01258377427.ps tmp/86wr01258377427.png") > system("convert tmp/9qif91258377427.ps tmp/9qif91258377427.png") > > > proc.time() user system elapsed 1.842 1.372 2.369