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(162.961 + ,143.843 + ,330.045 + ,185.511 + ,408.589 + ,202.001 + ,127.147 + ,111.288 + ,152.99 + ,153.358 + ,200.304 + ,148.122 + ,201.677 + ,224.896 + ,171.75 + ,204.718 + ,238.903 + ,157.166 + ,212.108 + ,83.178 + ,407.225 + ,126.735 + ,348.082 + ,148.947 + ,182.881 + ,256.367 + ,152.64 + ,171.875 + ,185.806 + ,168.03 + ,152.631 + ,359.107 + ,211.763 + ,177.074 + ,189.696 + ,170.66 + ,272.506 + ,305.783 + ,253.422 + ,207.372 + ,173.177 + ,150.88 + ,129.589 + ,281.863 + ,169.353 + ,232.379 + ,237.947 + ,116.108 + ,264.094 + ,134.779 + ,502.513 + ,196.733 + ,139.64 + ,197.299 + ,150.072 + ,192.42 + ,196.311 + ,254.363 + ,501.749 + ,264.359 + ,200.927 + ,255.593 + ,165.519 + ,108.677 + ,223.899 + ,117.261 + ,163.407 + ,100.313 + ,542.167 + ,253.128 + ,231.782 + ,179.355 + ,246.221 + ,296.323 + ,386.414 + ,173.679 + ,219.625 + ,491.827 + ,219.237 + ,204.517 + ,358.472 + ,49.678 + ,320.58 + ,364.879 + ,202.591 + ,193.035 + ,190.105 + ,413.4 + ,227.963 + ,228.062 + ,142.047 + ,280.549 + ,280.57 + ,87.968 + ,681.944 + ,157.17 + ,189.206 + ,184.88 + ,143.002 + ,210.046 + ,690.992 + ,208.427 + ,168.628 + ,170.154 + ,163.336 + ,146.779 + ,397.704 + ,59.616 + ,202.325 + ,255.614 + ,389.883 + ,130.712 + ,253.638 + ,253.327 + ,431.801 + ,185.353 + ,104.058 + ,67.982 + ,186.906 + ,192.535 + ,157.478 + ,133.281 + ,162.382 + ,258.44 + ,116.406 + ,231.911 + ,221.136 + ,47.923 + ,218.922 + ,115.151 + ,237.187 + ,336.088 + ,178.29 + ,221.478 + ,224.425 + ,54.246 + ,134.99 + ,175.844 + ,684.951 + ,146.311 + ,82.281 + ,205.401 + ,125.25 + ,401.432 + ,428.11 + ,248.945 + ,206.823 + ,251.551 + ,232.807 + ,129.242 + ,168.344 + ,464.963 + ,192.782 + ,105.935 + ,333.543 + ,166.653 + ,45.971 + ,370.407 + ,114.431 + ,228.531 + ,105.719 + ,310.386 + ,53.516 + ,159.619 + ,296.031 + ,258.861 + ,115.844 + ,149.782 + ,315.715 + ,130.141) > x <- c(26.012 + ,21.288 + ,28.576 + ,18.023 + ,23.666 + ,51.887 + ,16.642 + ,24.505 + ,6.886 + ,21.614 + ,17.972 + ,20.514 + ,31.325 + ,19.459 + ,35.75 + ,15.787 + ,45.21 + ,27.778 + ,21.489 + ,27.393 + ,28.944 + ,16.318 + ,4.148 + ,27.405 + ,20.413 + ,43.35 + ,19.125 + ,25.031 + ,23.804 + ,20.327 + ,12.455 + ,30.598 + ,6.343 + ,21.453 + ,50.435 + ,14.647 + ,78.187 + ,36.639 + ,69.935 + ,40.63 + ,4.437 + ,14.942 + ,20.483 + ,36.377 + ,28.392 + ,54.545 + ,15.787 + ,20.22 + ,23.05 + ,32.141 + ,218.987 + ,29.965 + ,28.942 + ,51.018 + ,21.637 + ,27.026 + ,24.258 + ,29.872 + ,21.59 + ,40.5 + ,22.056 + ,72.165 + ,14.026 + ,22.125 + ,26.845 + ,22.834 + ,20.719 + ,12.301 + ,343.037 + ,33.655 + ,65.078 + ,60.501 + ,73.215 + ,45.577 + ,150.834 + ,23.14 + ,41.579 + ,17.954 + ,43.676 + ,37.572 + ,12.208 + ,18.504 + ,26.145 + ,13.791 + ,42.453 + ,26.099 + ,33.494 + ,32.651 + ,28.751 + ,20.218 + ,18.734 + ,67.125 + ,27.585 + ,12.143 + ,324.724 + ,17.253 + ,19.001 + ,25.298 + ,23.449 + ,30.245 + ,91.059 + ,48.154 + ,17.748 + ,10.045 + ,12.871 + ,23.727 + ,12.821 + ,6.684 + ,23.341 + ,60.505 + ,123.69 + ,8.687 + ,27.213 + ,27.718 + ,36.96 + ,6.113 + ,14.345 + ,33.53 + ,46.639 + ,19.807 + ,44.131 + ,34.465 + ,12.509 + ,15.263 + ,2.974 + ,12.85 + ,14.459 + ,9.605 + ,30.422 + ,29.966 + ,48.422 + ,38.056 + ,29.639 + ,60.639 + ,40.353 + ,3.636 + ,19.599 + ,12.95 + ,29.676 + ,18.609 + ,10.562 + ,43.283 + ,20.266 + ,155.213 + ,73.938 + ,80.59 + ,23.077 + ,25.44 + ,52.128 + ,17.724 + ,8.431 + ,118.919 + ,26.719 + ,17.591 + ,101.462 + ,18.541 + ,8.059 + ,345.61 + ,26.573 + ,66.183 + ,13.047 + ,69.978 + ,11.313 + ,14.723 + ,60.973 + ,8.507 + ,20.146 + ,24.486 + ,21.939 + ,23.813) > 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 -252.69 -51.39 -16.09 29.44 475.02 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 171.1172 9.2181 18.563 < 2e-16 *** x 1.3078 0.1483 8.818 1.44e-15 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 94.99 on 168 degrees of freedom Multiple R-squared: 0.3164, Adjusted R-squared: 0.3123 F-statistic: 77.75 on 1 and 168 DF, p-value: 1.438e-15 > postscript(file="/var/www/rcomp/tmp/1y8ka1289555620.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/2y8ka1289555620.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 -8.961e-14 -6.564e-15 1.744e-16 8.236e-15 5.389e-14 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.711e+02 1.516e-15 1.129e+17 <2e-16 *** x 1.308e+00 2.439e-17 5.362e+16 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 1.562e-14 on 168 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 1 F-statistic: 2.875e+33 on 1 and 168 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/39zjv1289555620.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 -252.69 -51.39 -16.09 29.44 475.02 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 8.050e-16 9.218e+00 8.73e-17 1 x -2.237e-18 1.483e-01 -1.51e-17 1 Residual standard error: 94.99 on 168 degrees of freedom Multiple R-squared: 3.447e-36, Adjusted R-squared: -0.005952 F-statistic: 5.791e-34 on 1 and 168 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/4k91g1289555620.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 -45.914 -26.317 -17.412 2.218 402.175 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 2.209e+02 4.956e+00 44.58 <2e-16 *** m$residuals -1.116e-17 5.249e-02 -2.13e-16 1 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 64.62 on 168 degrees of freedom Multiple R-squared: 5.078e-31, Adjusted R-squared: -0.005952 F-statistic: 8.532e-29 on 1 and 168 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/5c00j1289555620.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 -261.24 -51.99 -17.32 31.14 474.00 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.27556 7.31062 0.038 0.970 Residuals -0.06096 0.07733 -0.788 0.432 Residual standard error: 95.04 on 167 degrees of freedom (2 observations deleted due to missingness) Multiple R-squared: 0.003708, Adjusted R-squared: -0.002258 F-statistic: 0.6215 on 1 and 167 DF, p-value: 0.4316 > abline(m5) > grid() > dev.off() null device 1 > postscript(file="/var/www/rcomp/tmp/6n9hm1289555620.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/7n9hm1289555620.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/8n9hm1289555620.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/9g1gp1289555620.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/10uaeg1289555620.tab") > > try(system("convert tmp/1y8ka1289555620.ps tmp/1y8ka1289555620.png",intern=TRUE)) character(0) > try(system("convert tmp/2y8ka1289555620.ps tmp/2y8ka1289555620.png",intern=TRUE)) character(0) > try(system("convert tmp/39zjv1289555620.ps tmp/39zjv1289555620.png",intern=TRUE)) character(0) > try(system("convert tmp/4k91g1289555620.ps tmp/4k91g1289555620.png",intern=TRUE)) character(0) > try(system("convert tmp/5c00j1289555620.ps tmp/5c00j1289555620.png",intern=TRUE)) character(0) > try(system("convert tmp/6n9hm1289555620.ps tmp/6n9hm1289555620.png",intern=TRUE)) character(0) > try(system("convert tmp/7n9hm1289555620.ps tmp/7n9hm1289555620.png",intern=TRUE)) character(0) > try(system("convert tmp/8n9hm1289555620.ps tmp/8n9hm1289555620.png",intern=TRUE)) character(0) > try(system("convert tmp/9g1gp1289555620.ps tmp/9g1gp1289555620.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.900 0.820 3.693