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(10001.60,10411.75,10673.38,10539.51,10723.78,10682.06,10283.19,10377.18,10486.64,10545.38,10554.27,10532.54,10324.31,10695.25,10827.81,10872.48,10971.19,11145.65,11234.68,11333.88,10997.97,11036.89,11257.35,11533.59,11963.12,12185.15,12377.62,12512.89,12631.48,12268.53,12754.80,13407.75,13480.21,13673.28,13239.71,13557.69,13901.28,13200.58,13406.97,12538.12,12419.57,12193.88,12656.63,12812.48,12056.67,11322.38,11530.75,11114.08,9181.73,8614.55,8595.56,8396.20,7690.50,7235.47,7992.12,8398.37,8593.01,8679.75,9374.63,9634.97) > x <- c(7599725.698,8118339.533,8534811.674,8891429.423,9489973.136,9648602.688,9730094.876,9371312.788,9593329.236,9996283.656,10609091.27,10738794.54,10859133.9,11316428.72,12209223.99,13447109.02,14539426.56,15350410.56,15174998.16,14448057.12,12745756.81,13701916.59,14917129.55,15761694.01,17127347.79,17637900.06,18411736.99,19748336.09,20273766.97,18983274.72,21079760.21,22061433.24,21357337.96,20819508.87,17661174.35,18459826.32,19671265.15,16852502.83,16947054.22,14780103.36,13845692.16,13501215.36,14881232.06,14448057.12,12280609.1,9196662.76,9284391.821,8775458.276,4830412.752,4058008.803,3470135.609,3630587.268,3279684.78,2789133.805,3476136.514,4210786.08,4119276.16,4288336.889,5259729.428,5969568.293) > 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 186.53067 2 452.21673 3 597.83516 4 364.62649 5 382.16746 6 296.25996 7 -125.31033 8 68.62123 9 116.23681 10 62.73070 11 -99.08165 12 -156.94151 13 -398.69298 14 -155.13603 15 -271.27114 16 -571.42370 17 -776.98729 18 -828.43323 19 -690.54073 20 -388.84562 21 -250.56655 22 -477.99234 23 -596.03941 24 -555.05945 25 -505.94299 26 -426.13132 27 -449.21965 28 -686.26979 29 -714.04267 30 -717.51596 31 -815.23839 32 -435.74109 33 -167.14984 34 175.73666 35 621.94544 36 717.45469 37 723.58893 38 808.07722 39 988.12919 40 722.90030 41 864.63785 42 734.90456 43 813.24011 44 1089.75438 45 937.70398 46 1062.47136 47 1246.40374 48 971.50116 49 138.07445 50 -213.94638 51 -69.17971 52 -313.23477 53 -921.18814 54 -1239.57133 55 -674.29131 56 -472.68369 57 -252.55289 58 -212.90607 59 211.38494 60 273.99377 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/18oft1257283735.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/29ti41257283735.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/3ee0p1257283735.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/4q97r1257283735.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/59m8m1257283735.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/6lxra1257283735.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/7zu6m1257283735.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/86nto1257283735.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. 2789000 8715000 12240000 12070000 16030000 22060000 > > #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/97x3o1257283735.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/100ex31257283735.tab") > > system("convert tmp/18oft1257283735.ps tmp/18oft1257283735.png") > system("convert tmp/29ti41257283735.ps tmp/29ti41257283735.png") > system("convert tmp/3ee0p1257283735.ps tmp/3ee0p1257283735.png") > system("convert tmp/4q97r1257283735.ps tmp/4q97r1257283735.png") > system("convert tmp/59m8m1257283735.ps tmp/59m8m1257283735.png") > system("convert tmp/6lxra1257283735.ps tmp/6lxra1257283735.png") > system("convert tmp/7zu6m1257283735.ps tmp/7zu6m1257283735.png") > system("convert tmp/86nto1257283735.ps tmp/86nto1257283735.png") > > > proc.time() user system elapsed 1.578 1.158 2.231