R version 2.12.0 (2010-10-15) Copyright (C) 2010 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(6.5,6.3,5.9,5.5,5.2,4.9,5.4,5.8,5.7,5.6,5.5,5.4,5.4,5.4,5.5,5.8,5.7,5.4,5.6,5.8,6.2,6.8,6.7,6.7,6.4,6.3,6.3,6.4,6.3,6,6.3,6.3,6.6,7.5,7.8,7.9,7.8,7.6,7.5,7.6,7.5,7.3,7.6,7.5,7.6,7.9,7.9,8.1,8.2,8,7.5,6.8,6.5,6.6,7.6,8,8.1,7.7,7.5,7.6,7.8,7.8,7.8,7.5,7.5,7.1,7.5,7.5,7.6,7.7,7.7,7.9,8.1,8.2,8.2,8.2,7.9,7.3,6.9,6.6,6.7,6.9,7,7.1,7.2,7.1,6.9,7,6.8,6.4,6.7,6.6,6.4,6.3,6.2,6.5,6.8,6.8,6.4,6.1,5.8,6.1,7.2,7.3,6.9,6.1,5.8,6.2,7.1,7.7,8,7.8,7.4,7.4,7.7,7.8,7.8,8,8.1,8.4) > x <- c(8.9,8.4,8.1,8.3,8.1,8,8.7,9.2,9,8.9,8.5,8.1,7.5,7.1,6.9,7.1,7,6.7,7,7.3,7.7,8.4,8.4,8.8,9.1,9,8.6,7.9,7.7,7.8,9.2,9.4,9.2,8.7,8.4,8.6,9,9.1,8.7,8.2,7.9,7.9,9.1,9.4,9.4,9.1,9,9.3,9.9,9.8,9.3,8.3,8,8.5,10.4,11.1,10.9,10,9.2,9.2,9.5,9.6,9.5,9.1,8.9,9,10.1,10.3,10.2,9.6,9.2,9.3,9.4,9.4,9.2,9,9,9,9.8,10,9.8,9.3,9,9,9.1,9.1,9.1,9.2,8.8,8.3,8.4,8.1,7.7,7.9,7.9,8,7.9,7.6,7.1,6.8,6.5,6.9,8.2,8.7,8.3,7.9,7.5,7.8,8.3,8.4,8.2,7.6,7.2,7.5,8.7,9,8.6,7.9,7.8,8.2) > par2 = '36' > par1 = '0' > 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 -0.588263732 2 -0.525598280 3 -0.767999008 4 -1.273065189 5 -1.467999008 6 -1.715465917 7 -1.583197551 8 -1.445863004 9 -1.440796823 10 -1.488263732 11 -1.378131370 12 -1.267999008 13 -0.952800465 14 -0.742668103 15 -0.537601922 16 -0.342668103 17 -0.390135012 18 -0.532535740 19 -0.490135012 20 -0.447734284 21 -0.257866646 22 -0.025598280 23 -0.125598280 24 -0.335730642 25 -0.793329913 26 -0.840796823 27 -0.630664461 28 -0.162932827 29 -0.157866646 30 -0.510399736 31 -0.945863004 32 -1.050929185 33 -0.645863004 34 0.516802449 35 0.974401720 36 0.969335539 37 0.659203177 38 0.406670087 39 0.516802449 40 0.879467902 41 0.937067173 42 0.737067173 43 0.406670087 44 0.149070815 45 0.249070815 46 0.706670087 47 0.759203177 48 0.801603906 49 0.586405362 50 0.438938453 51 0.201603906 52 0.026934811 53 -0.115465917 54 -0.278131370 55 -0.276260090 56 -0.243991724 57 -0.038925543 58 0.033872272 59 0.254136996 60 0.354136996 61 0.396537725 62 0.344004634 63 0.396537725 64 0.306670087 65 0.411736268 66 -0.040796823 67 -0.218660819 68 -0.323727000 69 -0.171193909 70 0.244004634 71 0.454136996 72 0.601603906 73 0.749070815 74 0.849070815 75 0.954136996 76 1.059203177 77 0.759203177 78 0.159203177 79 -0.661061547 80 -1.066127728 81 -0.861061547 82 -0.398396094 83 -0.140796823 84 -0.040796823 85 0.006670087 86 -0.093329913 87 -0.293329913 88 -0.245863004 89 -0.235730642 90 -0.373065189 91 -0.125598280 92 -0.067999008 93 -0.057866646 94 -0.262932827 95 -0.362932827 96 -0.115465917 97 0.237067173 98 0.394666445 99 0.257331897 100 0.114931169 101 -0.027469559 102 0.062398078 103 0.479467902 104 0.316802449 105 0.126934811 106 -0.462932827 107 -0.552800465 108 -0.310399736 109 0.326934811 110 0.874401720 111 1.279467902 112 1.394666445 113 1.204798807 114 1.047199535 115 0.716802449 116 0.659203177 117 0.869335539 118 1.437067173 119 1.589600264 120 1.679467902 > library(lattice) > postscript(file="/var/www/rcomp/tmp/1vsip1292678562.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > 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/rcomp/tmp/2n1za1292678562.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > 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/rcomp/tmp/3n1za1292678562.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(x,y,main='Scatter Plot',xlab='X[t]',ylab='Y[t]') > grid() > dev.off() null device 1 > postscript(file="/var/www/rcomp/tmp/4gtgv1292678562.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > 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/rcomp/tmp/5gtgv1292678562.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > hist(mylm$resid,main='Histogram of e[t]') > dev.off() null device 1 > postscript(file="/var/www/rcomp/tmp/6gtgv1292678562.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > 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/rcomp/tmp/792ff1292678562.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > 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/rcomp/tmp/892ff1292678562.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) + 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. 6.500 7.900 8.700 8.607 9.200 11.100 > > #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,'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/rcomp/tmp/9u2wl1292678562.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/rcomp/tmp/10qcuc1292678562.tab") > > try(system("convert tmp/1vsip1292678562.ps tmp/1vsip1292678562.png",intern=TRUE)) character(0) > try(system("convert tmp/2n1za1292678562.ps tmp/2n1za1292678562.png",intern=TRUE)) character(0) > try(system("convert tmp/3n1za1292678562.ps tmp/3n1za1292678562.png",intern=TRUE)) character(0) > try(system("convert tmp/4gtgv1292678562.ps tmp/4gtgv1292678562.png",intern=TRUE)) character(0) > try(system("convert tmp/5gtgv1292678562.ps tmp/5gtgv1292678562.png",intern=TRUE)) character(0) > try(system("convert tmp/6gtgv1292678562.ps tmp/6gtgv1292678562.png",intern=TRUE)) character(0) > try(system("convert tmp/792ff1292678562.ps tmp/792ff1292678562.png",intern=TRUE)) character(0) > try(system("convert tmp/892ff1292678562.ps tmp/892ff1292678562.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.250 1.280 3.551