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(110.8,119.3,128.1,127.6,137.9,151.4,143.6,143.4,141.9,135.2,133.1,129.6,134.1,136.8,143.5,162.5,163.1,157.2,158.8,155.4,148.5,154.2,153.3,149.4,147.9,156.0,163.0,159.1,159.5,157.3,156.4,156.6,162.4,166.8,162.6,168.1,171.3,171.0,178.7,187.5,211.4,211.6,199.4,198.7,209.3,215.5,212.8,203.2,175.7,171.0,172.5,183.5,185.4,180.9,187.3,202.0,203.3,205.8,221.5,226.6) > x <- c(149,139,135,130,127,122,117,112,113,149,157,157,147,137,132,125,123,117,114,111,112,144,150,149,134,123,116,117,111,105,102,95,93,124,130,124,115,106,105,105,101,95,93,84,87,116,120,117,109,105,107,109,109,108,107,99,103,131,137,135) > par2 = '36' > 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: > par1 <- as.numeric(par1) > par2 <- as.numeric(par2) > x <- as.ts(x) > y <- as.ts(y) > mylm <- lm(y~x) > cbind(mylm$resid) [,1] 1 -31.343716252 2 -31.153894664 3 -25.677966028 4 -30.333055234 5 -22.526108758 6 -13.181197963 7 -25.136287169 8 -29.491376375 9 -30.160358534 10 -6.943716252 11 -2.395573523 12 -5.895573523 13 -9.705751935 14 -15.315930346 15 -12.771019552 16 0.411855560 17 -0.650180122 18 -11.536287169 19 -12.429340692 20 -18.322394216 21 -24.391376375 22 7.901194542 23 11.987301589 24 7.256283748 25 -6.708983870 26 -7.750180122 27 -6.567305010 28 -9.636287169 29 -14.222394216 30 -21.408501263 31 -24.801554786 32 -30.418679674 33 -26.280715357 34 3.880837719 35 4.666944766 36 5.180837719 37 0.901677149 38 -6.877483422 39 -0.008501263 40 8.791498737 41 29.367427373 42 24.581320326 43 10.719284643 44 2.540124073 45 15.633177597 46 45.932694990 47 46.556766354 48 34.463712831 49 0.315570102 50 -7.708501263 51 -4.546465581 52 8.115570102 53 10.015570102 54 4.684552261 55 10.253534419 56 18.305391690 57 22.929463055 58 48.697962607 59 69.384069654 60 72.822033972 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/1j5t61258050591.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=4.1666666666667) > plot(y,type='l',main='Run Sequence Plot of Y[t]',xlab='time or index',ylab='value') > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/25zi01258050591.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=4.1666666666667) > plot(x,type='l',main='Run Sequence Plot of X[t]',xlab='time or index',ylab='value') > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/30i2s1258050591.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=4.1666666666667) > plot(x,y,main='Scatter Plot',xlab='X[t]',ylab='Y[t]') > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/4239a1258050591.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=4.1666666666667) > plot(mylm$resid,type='l',main='Run Sequence Plot of e[t]',xlab='time or index',ylab='value') > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/5bu051258050591.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=4.1666666666667) > hist(mylm$resid,main='Histogram of e[t]') > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/6u85g1258050591.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=4.1666666666667) > if (par1 > 0) + { + densityplot(~mylm$resid,col='black',main=paste('Density Plot of e[t] bw = ',par1),bw=par1) + } else { + densityplot(~mylm$resid,col='black',main='Density Plot of e[t]') + } > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/7158l1258050591.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=4.1666666666667) > qqnorm(mylm$resid,main='QQ plot of e[t]') > qqline(mylm$resid) > grid() > dev.off() null device 1 > if (par2 > 0) + { + postscript(file="/var/www/html/rcomp/tmp/8o57d1258050591.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=4.1666666666667) + acf(mylm$resid,lag.max=par2,main='Residual Autocorrelation Function') + grid() + dev.off() + } null device 1 > summary(x) Min. 1st Qu. Median Mean 3rd Qu. Max. 84.0 106.8 116.5 119.1 131.2 157.0 > > #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,'Model: Y[t] = c + b X[t] + e[t]',2,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'c',1,TRUE) > a<-table.element(a,mylm$coeff[[1]]) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'b',1,TRUE) > a<-table.element(a,mylm$coeff[[2]]) > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/www/html/rcomp/tmp/932fd1258050591.tab") > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Descriptive Statistics about e[t]',2,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'# observations',header=TRUE) > a<-table.element(a,length(mylm$resid)) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'minimum',header=TRUE) > a<-table.element(a,min(mylm$resid)) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Q1',header=TRUE) > a<-table.element(a,quantile(mylm$resid,0.25)) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'median',header=TRUE) > a<-table.element(a,median(mylm$resid)) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'mean',header=TRUE) > a<-table.element(a,mean(mylm$resid)) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Q3',header=TRUE) > a<-table.element(a,quantile(mylm$resid,0.75)) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'maximum',header=TRUE) > a<-table.element(a,max(mylm$resid)) > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/www/html/rcomp/tmp/10mbey1258050592.tab") > system("convert tmp/1j5t61258050591.ps tmp/1j5t61258050591.png") > system("convert tmp/25zi01258050591.ps tmp/25zi01258050591.png") > system("convert tmp/30i2s1258050591.ps tmp/30i2s1258050591.png") > system("convert tmp/4239a1258050591.ps tmp/4239a1258050591.png") > system("convert tmp/5bu051258050591.ps tmp/5bu051258050591.png") > system("convert tmp/6u85g1258050591.ps tmp/6u85g1258050591.png") > system("convert tmp/7158l1258050591.ps tmp/7158l1258050591.png") > system("convert tmp/8o57d1258050591.ps tmp/8o57d1258050591.png") > > > proc.time() user system elapsed 1.537 1.126 2.328