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(9769,9321,9939,9336,10195,9464,10010,10213,9563,9890,9305,9391,9928,8686,9843,9627,10074,9503,10119,10000,9313,9866,9172,9241,9659,8904,9755,9080,9435,8971,10063,9793,9454,9759,8820,9403,9676,8642,9402,9610,9294,9448,10319,9548,9801,9596,8923,9746,9829,9125,9782,9441,9162,9915,10444,10209,9985,9842,9429,10132,9849,9172,10313,9819,9955,10048,10082,10541,10208,10233,9439,9963,10158,9225,10474,9757,10490,10281,10444,10640,10695,10786,9832,9747,10411,9511,10402,9701,10540,10112,10915,11183,10384,10834,9886,10216) > x <- c(1579,2146,2462,3695,4831,5134,6250,5760,6249,2917,1741,2359,1511,2059,2635,2867,4403,5720,4502,5749,5627,2846,1762,2429,1169,2154,2249,2687,4359,5382,4459,6398,4596,3024,1887,2070,1351,2218,2461,3028,4784,4975,4607,6249,4809,3157,1910,2228,1594,2467,2222,3607,4685,4962,5770,5480,5000,3228,1993,2288,1580,2111,2192,3601,4665,4876,5813,5589,5331,3075,2002,2306,1507,1992,2487,3490,4647,5594,5611,5788,6204,3013,1931,2549,1504,2090,2702,2939,4500,6208,6415,5657,5964,3163,1997,2422) > 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 -1063.20 -368.18 36.70 269.43 1115.12 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 9.375e+03 1.206e+02 77.715 < 2e-16 *** x 1.225e-01 3.061e-02 4.002 0.000125 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 476.6 on 94 degrees of freedom Multiple R-squared: 0.1456, Adjusted R-squared: 0.1365 F-statistic: 16.01 on 1 and 94 DF, p-value: 0.0001253 > postscript(file="/var/www/html/rcomp/tmp/1og4k1290950509.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/2og4k1290950509.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 -2.524e-12 -1.031e-12 -4.998e-13 9.555e-14 5.086e-11 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 9.375e+03 1.354e-12 6.926e+15 <2e-16 *** x 1.225e-01 3.434e-16 3.566e+14 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 5.348e-12 on 94 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 1 F-statistic: 1.272e+29 on 1 and 94 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/3y7l51290950509.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 -1063.20 -368.18 36.70 269.43 1115.12 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -8.927e-14 1.206e+02 -7.40e-16 1 x 2.555e-17 3.061e-02 8.35e-16 1 Residual standard error: 476.6 on 94 degrees of freedom Multiple R-squared: 3.789e-33, Adjusted R-squared: -0.01064 F-statistic: 3.562e-31 on 1 and 94 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/49zl81290950509.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 -298.59 -170.90 -68.02 168.34 343.95 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 9.817e+03 2.008e+01 489 <2e-16 *** m$residuals 3.568e-16 4.257e-02 8.38e-15 1 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 196.7 on 94 degrees of freedom Multiple R-squared: 8.741e-28, Adjusted R-squared: -0.01064 F-statistic: 8.217e-26 on 1 and 94 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/5k8kb1290950509.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 -1017.13 -382.77 38.57 266.85 1044.38 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -1.5204 48.8563 -0.031 0.975 Residuals 0.1032 0.1038 0.994 0.323 Residual standard error: 476.2 on 93 degrees of freedom (2 observations deleted due to missingness) Multiple R-squared: 0.01052, Adjusted R-squared: -0.0001246 F-statistic: 0.9883 on 1 and 93 DF, p-value: 0.3227 > abline(m5) > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/6uhjw1290950509.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/7uhjw1290950509.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/8nrjh1290950509.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/9nrjh1290950509.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/101ig81290950509.tab") > try(system("convert tmp/1og4k1290950509.ps tmp/1og4k1290950509.png",intern=TRUE)) character(0) > try(system("convert tmp/2og4k1290950509.ps tmp/2og4k1290950509.png",intern=TRUE)) character(0) > try(system("convert tmp/3y7l51290950509.ps tmp/3y7l51290950509.png",intern=TRUE)) character(0) > try(system("convert tmp/49zl81290950509.ps tmp/49zl81290950509.png",intern=TRUE)) character(0) > try(system("convert tmp/5k8kb1290950509.ps tmp/5k8kb1290950509.png",intern=TRUE)) character(0) > try(system("convert tmp/6uhjw1290950509.ps tmp/6uhjw1290950509.png",intern=TRUE)) character(0) > try(system("convert tmp/7uhjw1290950509.ps tmp/7uhjw1290950509.png",intern=TRUE)) character(0) > try(system("convert tmp/8nrjh1290950509.ps tmp/8nrjh1290950509.png",intern=TRUE)) character(0) > try(system("convert tmp/9nrjh1290950509.ps tmp/9nrjh1290950509.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.881 1.428 4.691