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(43237,47637,55718,53091,47034,26149,27356,35438,39086,41761,42622,44051,43565,47534,54807,52653,46562,25565,26450,34689,37310,37886,38124,38692,38444,42169,48621,47913,43528,22487,23558,30953,32986,36055,37676,38433,39215,45390,51579,51588,46390,23099,23988,33335,35907,39032,41248,40744,46211,53145,61271,58672,51349,24935,26599,35324,38546,42065,44148,54424,58397) > x <- c(268606,276444,289742,303725,298305,266795,259497,266148,271037,276239,279681,277509,271115,275902,287224,300713,293860,264221,256167,262572,263276,264291,263903,260376,255603,261076,270976,285257,280445,250741,243803,253158,255542,262522,268381,267153,266424,276427,286994,303598,296806,263290,264981,272566,276475,284678,291542,291413,295916,309119,327616,335083,329765,301631,298423,298989,302963,309664,313218,314485,313927) > 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 6407.3425 2 8338.1075 3 12229.7879 4 5197.6701 5 848.1534 6 -10110.1313 7 -6604.0146 8 -617.3044 9 1490.4953 10 2526.6894 11 2303.3431 12 4416.5965 13 5944.9227 14 8405.8558 15 12112.0430 16 5708.5520 17 1776.4787 18 -9883.2343 19 -6460.9520 20 -239.7435 21 2159.4727 22 2415.7134 23 2775.9465 24 4455.0707 25 5710.7271 26 7711.5471 27 11044.7124 28 5837.7145 29 2968.6572 30 -8714.5785 31 -5457.8740 32 -1010.0152 33 271.9442 34 1142.0082 35 917.2251 36 2061.0866 37 3072.7463 38 6096.4631 39 8956.5008 40 3734.6794 41 676.3891 42 -12055.9378 43 -11699.6600 44 -4742.1914 45 -3401.6586 46 -2860.8809 47 -2807.2730 48 -3270.6336 49 777.7692 50 3552.3778 51 5851.1974 52 899.8400 53 -4747.8102 54 -22298.6491 55 -19624.0206 56 -11077.3297 57 -9107.2741 58 -7699.3156 59 -6735.9458 60 3140.9064 61 7289.6952 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/1bmgs1293355988.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/html/rcomp/tmp/2bmgs1293355988.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/html/rcomp/tmp/34vxd1293355988.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/html/rcomp/tmp/44vxd1293355988.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/html/rcomp/tmp/54vxd1293355988.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/html/rcomp/tmp/64vxd1293355988.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/html/rcomp/tmp/7w5eg1293355988.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/html/rcomp/tmp/8pwdj1293355988.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. 243800 264300 276400 281600 298300 335100 > > #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/9aec71293355988.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/10efad1293355988.tab") > > try(system("convert tmp/1bmgs1293355988.ps tmp/1bmgs1293355988.png",intern=TRUE)) character(0) > try(system("convert tmp/2bmgs1293355988.ps tmp/2bmgs1293355988.png",intern=TRUE)) character(0) > try(system("convert tmp/34vxd1293355988.ps tmp/34vxd1293355988.png",intern=TRUE)) character(0) > try(system("convert tmp/44vxd1293355988.ps tmp/44vxd1293355988.png",intern=TRUE)) character(0) > try(system("convert tmp/54vxd1293355988.ps tmp/54vxd1293355988.png",intern=TRUE)) character(0) > try(system("convert tmp/64vxd1293355988.ps tmp/64vxd1293355988.png",intern=TRUE)) character(0) > try(system("convert tmp/7w5eg1293355988.ps tmp/7w5eg1293355988.png",intern=TRUE)) character(0) > try(system("convert tmp/8pwdj1293355988.ps tmp/8pwdj1293355988.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.601 1.187 5.774