R version 2.13.0 (2011-04-13) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-pc-linux-gnu (32-bit) 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(140824,110459,105079,112098,43929,76173,22807,144408,66485,79089,81625,68788,103297,69446,114948,167949,125081,125818,136588,112431,82317,118906,83515,104581,103129,83243,37110,113344,139165,86652,112302,69652,119442,69867,70168,31081,103925,92622,79011,93487,64520,93473,114360,33032,96125,151911,89256,95671,5950,149695,32551,31701,100087,169707,150491,120192,95893,151715,176225,59900,104767,114799,72128,143592,89626,131072,126817,81351,22618,88977,92059,81897,108146,126372,249771,71154,71571,55918,160141,38692,102812,56622,15986,123534,108535,93879,144551,56750,127654,65594,59938,146975,143372,168553,183500,165986,184923,140358,149959,57224,43750,48029,104978,100046,101047,197426,160902,147172,109432,1168,83248,25162,45724,855,101382,14116,89506,135356,116066,144244,8773,102153,117440,104128,134238,134047,279488,79756,66089,102070,146760,154771,165933,64593,92280,67150,128692,124089,125386,37238,140015,150047,154451,156349,84601,68946,6179,52789,100350) > x <- c(272545 + ,179444 + ,222373 + ,218443 + ,167843 + ,70849 + ,33186 + ,216660 + ,213274 + ,307153 + ,237633 + ,166215 + ,364402 + ,244103 + ,384448 + ,325587 + ,323652 + ,176082 + ,266736 + ,278265 + ,180393 + ,189897 + ,234247 + ,238002 + ,267268 + ,270787 + ,155915 + ,342564 + ,282172 + ,216584 + ,318563 + ,98672 + ,391593 + ,273950 + ,227636 + ,115658 + ,349863 + ,324178 + ,178083 + ,195153 + ,177694 + ,153778 + ,455168 + ,78800 + ,208051 + ,348077 + ,175523 + ,224591 + ,24188 + ,372238 + ,65029 + ,101097 + ,279012 + ,317644 + ,340471 + ,358958 + ,252529 + ,377482 + ,304468 + ,270190 + ,264889 + ,228595 + ,216027 + ,198798 + ,238146 + ,234891 + ,175816 + ,239314 + ,73566 + ,242622 + ,187167 + ,209049 + ,360592 + ,342846 + ,207650 + ,206500 + ,182357 + ,153613 + ,456979 + ,145943 + ,280366 + ,80953 + ,150216 + ,167878 + ,369718 + ,322454 + ,179797 + ,264350 + ,262793 + ,189142 + ,275997 + ,328875 + ,189252 + ,222504 + ,287386 + ,389104 + ,397681 + ,287748 + ,294320 + ,186856 + ,43287 + ,185468 + ,235352 + ,268077 + ,305195 + ,143356 + ,154287 + ,307000 + ,298039 + ,23623 + ,195817 + ,61857 + ,163766 + ,21054 + ,252805 + ,31961 + ,317367 + ,240153 + ,175083 + ,152043 + ,38214 + ,216299 + ,357602 + ,198104 + ,410803 + ,316105 + ,397297 + ,187992 + ,102424 + ,286327 + ,409878 + ,143860 + ,391854 + ,157429 + ,258751 + ,282399 + ,217665 + ,367246 + ,239072 + ,173260 + ,323545 + ,168994 + ,253330 + ,301703 + ,246435 + ,384136 + ,46660 + ,116678 + ,206501) > 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 -77131 -25885 -7747 18126 156852 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 3.037e+04 7.967e+03 3.812 0.000202 *** x 3.012e-01 3.146e-02 9.575 < 2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 37170 on 147 degrees of freedom Multiple R-squared: 0.3841, Adjusted R-squared: 0.3799 F-statistic: 91.69 on 1 and 147 DF, p-value: < 2.2e-16 > postscript(file="/var/wessaorg/rcomp/tmp/1niwa1324378381.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/2a5q11324378381.ps",horizontal=F,onefile=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.957e-11 -5.127e-12 -1.322e-12 2.986e-12 1.609e-10 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 3.037e+04 3.260e-12 9.318e+15 <2e-16 *** x 3.012e-01 1.287e-17 2.340e+16 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 1.521e-11 on 147 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 1 F-statistic: 5.477e+32 on 1 and 147 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/wessaorg/rcomp/tmp/3s50t1324378381.ps",horizontal=F,onefile=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 -77131 -25885 -7747 18126 156852 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -3.730e-13 7.967e+03 0 1 x 3.167e-18 3.146e-02 0 1 Residual standard error: 37170 on 147 degrees of freedom Multiple R-squared: 3.615e-34, Adjusted R-squared: -0.006803 F-statistic: 5.314e-32 on 1 and 147 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/wessaorg/rcomp/tmp/45ekb1324378381.ps",horizontal=F,onefile=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 -64156 -17541 252 21209 67146 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.009e+05 2.405e+03 41.94 <2e-16 *** m$residuals 6.068e-17 6.514e-02 0.00 1 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 29360 on 147 degrees of freedom Multiple R-squared: 1.922e-31, Adjusted R-squared: -0.006803 F-statistic: 2.826e-29 on 1 and 147 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/wessaorg/rcomp/tmp/52dir1324378381.ps",horizontal=F,onefile=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 -74448 -26448 -7647 18315 157945 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -185.04760 3035.80434 -0.061 0.951 Residuals 0.12492 0.08196 1.524 0.130 Residual standard error: 36930 on 146 degrees of freedom (2 observations deleted due to missingness) Multiple R-squared: 0.01566, Adjusted R-squared: 0.008921 F-statistic: 2.323 on 1 and 146 DF, p-value: 0.1296 > abline(m5) > grid() > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/6nshs1324378381.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/7iq4k1324378381.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/8ylcm1324378381.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/948we1324378381.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > qqnorm(x) > qqline(x) > grid() > dev.off() null device 1 > > #Note: the /var/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/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/wessaorg/rcomp/tmp/10eng71324378381.tab") > > try(system("convert tmp/1niwa1324378381.ps tmp/1niwa1324378381.png",intern=TRUE)) character(0) > try(system("convert tmp/2a5q11324378381.ps tmp/2a5q11324378381.png",intern=TRUE)) character(0) > try(system("convert tmp/3s50t1324378381.ps tmp/3s50t1324378381.png",intern=TRUE)) character(0) > try(system("convert tmp/45ekb1324378381.ps tmp/45ekb1324378381.png",intern=TRUE)) character(0) > try(system("convert tmp/52dir1324378381.ps tmp/52dir1324378381.png",intern=TRUE)) character(0) > try(system("convert tmp/6nshs1324378381.ps tmp/6nshs1324378381.png",intern=TRUE)) character(0) > try(system("convert tmp/7iq4k1324378381.ps tmp/7iq4k1324378381.png",intern=TRUE)) character(0) > try(system("convert tmp/8ylcm1324378381.ps tmp/8ylcm1324378381.png",intern=TRUE)) character(0) > try(system("convert tmp/948we1324378381.ps tmp/948we1324378381.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.768 0.520 3.297