R version 2.7.0 (2008-04-22) 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(95.5,98.7,115.9,110.4,109.5,92.3,102.1,112.8,110.2,98.9,119,104.3,98.8,109.4,170.3,118,116.9,111.7,116.8,116.1,114.8,110.8,122.8,104.7,86,127.2,126.1,114.6,127.8,105.2,113.1,161,126.9,117.7,144.9,119.4,107.1,142.8,126.2,126.9,179.2,105.3,114.8,125.4,113.2,134.4,150,100.9,101.8,137.7,138.7,135.4,153.8,119.5,123.3,166.4,137.5,142.2,167,112.3,120.6,154.9,153.4,156.2,175.8,131.7,130.1,161.1,128.2,140.3,174.9,111.8,136.6) > x <- c(92.3,95.5,92.5,89.6,84.3,76.3,80.7,96.3,81,82.9,90.3,74.8,70.1,86.7,86.4,89.9,88.1,78.8,81.1,85.4,82.6,80.3,81.2,68,67.4,91.3,94.9,82.8,88.6,73.1,76.7,93.2,84.9,83.8,93.5,91.9,69.6,87,90.2,82.7,91.4,74.6,76.1,87.1,78.4,81.3,99.3,71,73.2,95.6,84,90.8,93.6,80.9,84.4,97.3,83.5,88.8,100.7,69.4,74.6,96.6,96.6,93.1,91.8,85.7,79.1,91.3,84.2,85.8,94.6,77.1,76.5) > 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 -44.943 -9.203 -1.083 11.896 42.411 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -16.0076 20.7430 -0.772 0.443 x 1.6717 0.2433 6.871 2.02e-09 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 17.06 on 71 degrees of freedom Multiple R-squared: 0.3994, Adjusted R-squared: 0.3909 F-statistic: 47.22 on 1 and 71 DF, p-value: 2.020e-09 > postscript(file="/var/www/html/rcomp/tmp/1oip31226600320.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/23sr01226600320.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.009e-13 -3.885e-15 8.755e-16 5.524e-15 1.538e-14 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -1.601e+01 1.680e-14 -9.528e+14 <2e-16 *** x 1.672e+00 1.971e-16 8.484e+15 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 1.382e-14 on 71 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 1 F-statistic: 7.197e+31 on 1 and 71 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/3hj4h1226600320.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 -44.943 -9.203 -1.083 11.896 42.411 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 6.584e-15 2.074e+01 3.17e-16 1 x -8.620e-17 2.433e-01 -3.54e-16 1 Residual standard error: 17.06 on 71 degrees of freedom Multiple R-squared: 4.375e-33, Adjusted R-squared: -0.01408 F-statistic: 3.107e-31 on 1 and 71 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/4qz6a1226600320.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 -29.19579 -9.63651 0.05954 10.92581 26.47292 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.259e+02 1.628e+00 77.31 <2e-16 *** m$residuals 1.977e-16 9.678e-02 2.04e-15 1 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 13.91 on 71 degrees of freedom Multiple R-squared: 4.116e-31, Adjusted R-squared: -0.01408 F-statistic: 2.922e-29 on 1 and 71 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/5wv8p1226600320.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 -33.489 -7.647 -1.939 6.613 48.827 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.7295 1.7652 0.413 0.680691 Residuals 0.3936 0.1058 3.720 0.000398 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 14.98 on 70 degrees of freedom (2 observations deleted due to missingness) Multiple R-squared: 0.1651, Adjusted R-squared: 0.1531 F-statistic: 13.84 on 1 and 70 DF, p-value: 0.0003983 > abline(m5) > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/6ofq61226600320.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/7sn5p1226600320.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/8g88g1226600320.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/9ssvz1226600320.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/10ugyo1226600320.tab") > > system("convert tmp/1oip31226600320.ps tmp/1oip31226600320.png") > system("convert tmp/23sr01226600320.ps tmp/23sr01226600320.png") > system("convert tmp/3hj4h1226600320.ps tmp/3hj4h1226600320.png") > system("convert tmp/4qz6a1226600320.ps tmp/4qz6a1226600320.png") > system("convert tmp/5wv8p1226600320.ps tmp/5wv8p1226600320.png") > system("convert tmp/6ofq61226600320.ps tmp/6ofq61226600320.png") > system("convert tmp/7sn5p1226600320.ps tmp/7sn5p1226600320.png") > system("convert tmp/8g88g1226600320.ps tmp/8g88g1226600320.png") > system("convert tmp/9ssvz1226600320.ps tmp/9ssvz1226600320.png") > > > proc.time() user system elapsed 3.880 2.451 4.217