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(78973,46146,46492,60656,21898,36555,74680,22807,61282,37981,41553,45081,38557,51641,30658,52924,79256,53462,68950,53639,67819,48333,28001,51665,39019,46221,65792,39858,19574,41829,78688,36781,44314,24874,56911,37048,48426,33388,26998,46502,41507,40001,33144,29501,43059,43249,29272,49821,98341,44372,42448,5950,64839,32551,30767,62046,71930,67328,67253,35373,85544,88087,30621,50580,49670,25456,69245,43787,53638,35683,38008,18801,44324,51408,53880,55708,63858,183643,35660,41664,29883,62047,33321,46553,56622,15430,49379,58215,38253,77786,21331,55292,30105,37651,59370,46216,73122,93927,55935,93308,74344,78094,25625,43750,28995,47336,57582,60875,165877,32984,61638,36367,1168,40530,21427,15024,39088,855,80455,14116,43915,76705,40112,41821,8773,52045,51491,53470,53211,63091,131634,41745,23656,51442,54574,35708,66627,39585,50029,25266,34860,62759,62307,37238,42452,59820,75075,97567,0,6023,0,0,0,0,42420,31116,0,0,1644,6179,3926,23238,0,38818) > x <- c(309,210,360,737,143,81,1074,102,488,371,478,318,398,626,363,1003,434,650,302,415,408,756,258,279,750,637,640,339,366,482,553,345,493,150,759,603,626,337,212,670,959,421,385,248,791,1282,330,404,943,527,278,216,512,253,411,585,411,666,563,429,746,740,634,540,340,281,392,584,520,341,417,301,397,450,329,561,598,240,270,396,439,784,516,287,437,548,220,795,435,655,389,403,338,673,513,340,352,427,603,796,380,480,293,214,428,349,505,571,175,322,373,376,135,436,185,261,605,146,528,193,703,332,183,302,276,280,518,233,960,506,718,287,252,544,875,195,1065,407,329,456,212,970,408,716,490,290,618,479,0,85,0,0,0,0,407,489,0,0,74,259,69,187,0,312) > 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 -45680 -13844 -4769 9304 147373 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 24141.684 3935.919 6.134 6.34e-09 *** x 50.537 8.009 6.310 2.56e-09 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 24310 on 162 degrees of freedom Multiple R-squared: 0.1973, Adjusted R-squared: 0.1923 F-statistic: 39.82 on 1 and 162 DF, p-value: 2.556e-09 > postscript(file="/var/wessaorg/rcomp/tmp/1ra5h1321354485.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/2kn9i1321354485.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.018e-10 -7.650e-13 8.210e-13 2.577e-12 6.015e-12 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 2.414e+04 1.392e-12 1.734e+16 <2e-16 *** x 5.054e+01 2.833e-15 1.784e+16 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 8.599e-12 on 162 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 1 F-statistic: 3.182e+32 on 1 and 162 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/3jfss1321354485.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 -45680 -13844 -4769 9304 147373 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 3.601e-14 3.936e+03 0 1 x 7.515e-16 8.009e+00 0 1 Residual standard error: 24310 on 162 degrees of freedom Multiple R-squared: 2.009e-34, Adjusted R-squared: -0.006173 F-statistic: 3.254e-32 on 1 and 162 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/4vmas1321354485.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 -21758 -7620 -1265 6619 43030 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 4.590e+04 9.411e+02 48.77 <2e-16 *** m$residuals -9.031e-17 3.895e-02 0.00 1 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 12050 on 162 degrees of freedom Multiple R-squared: 1.283e-31, Adjusted R-squared: -0.006173 F-statistic: 2.078e-29 on 1 and 162 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/5bwcf1321354485.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 -43358 -14757 -4150 9837 146675 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -241.24775 1884.94109 -0.128 0.898 Residuals 0.09885 0.07778 1.271 0.206 Residual standard error: 24070 on 161 degrees of freedom (2 observations deleted due to missingness) Multiple R-squared: 0.009931, Adjusted R-squared: 0.003781 F-statistic: 1.615 on 1 and 161 DF, p-value: 0.2056 > abline(m5) > grid() > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/60z6d1321354485.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/7fyfp1321354485.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/8a5y11321354485.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/9f4j01321354485.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/10rsjb1321354485.tab") > > try(system("convert tmp/1ra5h1321354485.ps tmp/1ra5h1321354485.png",intern=TRUE)) character(0) > try(system("convert tmp/2kn9i1321354485.ps tmp/2kn9i1321354485.png",intern=TRUE)) character(0) > try(system("convert tmp/3jfss1321354485.ps tmp/3jfss1321354485.png",intern=TRUE)) character(0) > try(system("convert tmp/4vmas1321354485.ps tmp/4vmas1321354485.png",intern=TRUE)) character(0) > try(system("convert tmp/5bwcf1321354485.ps tmp/5bwcf1321354485.png",intern=TRUE)) character(0) > try(system("convert tmp/60z6d1321354485.ps tmp/60z6d1321354485.png",intern=TRUE)) character(0) > try(system("convert tmp/7fyfp1321354485.ps tmp/7fyfp1321354485.png",intern=TRUE)) character(0) > try(system("convert tmp/8a5y11321354485.ps tmp/8a5y11321354485.png",intern=TRUE)) character(0) > try(system("convert tmp/9f4j01321354485.ps tmp/9f4j01321354485.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.623 0.428 3.080