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(9487,8700,9627,8947,9283,8829,9947,9628,9318,9605,8640,9214,9567,8547,9185,9470,9123,9278,10170,9434,9655,9429,8739,9552,9687,9019,9672,9206,9069,9788,10312,10105,9863,9656,9295,9946,9701,9049,10190,9706,9765,9893,9994,10433,10073,10112,9266,9820,10097,9115,10411,9678,10408,10153,10368,10581,10597,10680,9738,9556) > x <- c(1.00,1.00,0.99,0.97,0.96,0.96,1.09,1.10,1.10,1.09,1.07,1.08,1.09,1.09,1.07,1.07,1.05,1.06,1.20,1.22,1.21,1.19,1.15,1.17,1.18,1.18,1.17,1.14,1.13,1.14,1.25,1.28,1.29,1.28,1.25,1.25,1.24,1.24,1.23,1.20,1.19,1.20,1.30,1.32,1.32,1.29,1.25,1.25,1.25,1.24,1.22,1.21,1.20,1.20,1.30,1.31,1.30,1.23,1.19,1.17) > 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 434.768662 2 -352.231338 3 608.753348 4 -3.277280 5 366.707407 6 -87.292593 7 588.906485 8 235.921799 9 -74.078201 10 246.906485 11 -650.124143 12 -110.108829 13 208.906485 14 -811.093515 15 -105.124143 16 179.875857 17 -99.154770 18 21.860544 19 438.074936 20 -365.894437 21 -110.909751 22 -268.940378 23 -823.001633 24 -77.971006 25 23.044308 26 -644.955692 27 42.028994 28 -322.016947 29 -425.032260 30 259.983053 31 410.151504 32 101.197445 33 -174.787241 34 -347.802555 35 -606.848496 36 44.151504 37 -166.863810 38 -818.863810 39 356.120877 40 -25.925064 41 67.059622 42 161.074936 43 -77.771927 44 293.258700 45 -66.741300 46 74.212759 47 -635.848496 48 -81.848496 49 195.151504 50 -752.863810 51 611.105563 52 -87.909751 53 676.074936 54 421.074936 55 296.228073 56 475.243386 57 525.228073 58 846.120877 59 40.059622 60 -73.971006 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/1bpsg1257360860.ps",horizontal=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/html/rcomp/tmp/20xqz1257360860.ps",horizontal=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/html/rcomp/tmp/3deb61257360860.ps",horizontal=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/html/rcomp/tmp/4js2r1257360860.ps",horizontal=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/html/rcomp/tmp/59w7s1257360860.ps",horizontal=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/html/rcomp/tmp/6inly1257360860.ps",horizontal=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/html/rcomp/tmp/7uxvr1257360860.ps",horizontal=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/html/rcomp/tmp/8sqja1257360860.ps",horizontal=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. 0.960 1.090 1.195 1.173 1.250 1.320 > > #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/9obrf1257360860.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/10abw21257360860.tab") > > system("convert tmp/1bpsg1257360860.ps tmp/1bpsg1257360860.png") > system("convert tmp/20xqz1257360860.ps tmp/20xqz1257360860.png") > system("convert tmp/3deb61257360860.ps tmp/3deb61257360860.png") > system("convert tmp/4js2r1257360860.ps tmp/4js2r1257360860.png") > system("convert tmp/59w7s1257360860.ps tmp/59w7s1257360860.png") > system("convert tmp/6inly1257360860.ps tmp/6inly1257360860.png") > system("convert tmp/7uxvr1257360860.ps tmp/7uxvr1257360860.png") > system("convert tmp/8sqja1257360860.ps tmp/8sqja1257360860.png") > > > proc.time() user system elapsed 1.644 1.211 2.190