R version 2.13.0 (2011-04-13) Copyright (C) 2011 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(170650 + ,86621 + ,127843 + ,152526 + ,92389 + ,38778 + ,316392 + ,32750 + ,123444 + ,137034 + ,176816 + ,143205 + ,113286 + ,195452 + ,144513 + ,263581 + ,183271 + ,210763 + ,113853 + ,159968 + ,174585 + ,294675 + ,96213 + ,116390 + ,146342 + ,152647 + ,166661 + ,175505 + ,112485 + ,198790 + ,191822 + ,140267 + ,221991 + ,75339 + ,247985 + ,167351 + ,266609 + ,122024 + ,80964 + ,215183 + ,225469 + ,125382 + ,141437 + ,81106 + ,93125 + ,318668 + ,78800 + ,161048 + ,236367 + ,131108 + ,131096 + ,24188 + ,267003 + ,65029 + ,100147 + ,178549 + ,186965 + ,197266 + ,217300 + ,149594 + ,263413 + ,209228 + ,145699 + ,187197 + ,150752 + ,131218 + ,118697 + ,147913 + ,155015 + ,96487 + ,128780 + ,71972 + ,140266 + ,152455 + ,110655 + ,204822 + ,216052 + ,113421 + ,103660 + ,128390 + ,105502 + ,299359 + ,141493 + ,148356 + ,80953 + ,109237 + ,102104 + ,233139 + ,176507 + ,118217 + ,142694 + ,152193 + ,126500 + ,174710 + ,187772 + ,140903 + ,155350 + ,202077 + ,213875 + ,252952 + ,166981 + ,190790 + ,106351 + ,43287 + ,127493 + ,132143 + ,157469 + ,197727 + ,88077 + ,94968 + ,191753 + ,153332 + ,22938 + ,125927 + ,61857 + ,103749 + ,269909 + ,21054 + ,174409 + ,31414 + ,200405 + ,139456 + ,78001 + ,82724 + ,38214 + ,91390 + ,197612 + ,137161 + ,251103 + ,209835 + ,269470 + ,139215 + ,77796 + ,197114 + ,291962 + ,56727 + ,254843 + ,105908 + ,170155 + ,136745 + ,86706 + ,251448 + ,152366 + ,173260 + ,212582 + ,87850 + ,148636 + ,185455 + ,0 + ,14688 + ,98 + ,455 + ,0 + ,0 + ,137891 + ,201052 + ,0 + ,203 + ,7199 + ,46660 + ,17547 + ,73567 + ,969 + ,106662) > x <- c(26,20,27,25,17,16,20,18,19,22,30,40,26,36,31,41,24,27,19,30,31,26,15,33,28,27,21,27,21,30,30,33,35,26,27,25,30,20,8,24,25,28,23,21,21,26,26,30,34,30,18,4,31,18,14,21,37,24,29,24,31,21,31,26,24,18,21,29,24,21,30,20,30,24,26,27,24,23,26,25,18,30,25,27,8,21,26,24,30,27,24,25,21,24,24,24,24,24,40,22,31,26,20,19,15,22,25,28,23,25,26,32,1,24,11,31,26,0,19,8,27,31,24,20,8,22,33,33,31,33,35,21,24,25,31,22,27,24,27,26,16,23,24,21,30,37,24,29,0,0,0,0,0,0,20,31,0,0,0,5,1,23,0,16) > 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 11178.5750 2 -38911.9437 3 -37284.8385 4 -1289.0114 5 -16174.7031 6 -64129.2895 7 190859.0563 8 -81470.1166 9 3567.4698 10 188.2292 11 -5281.0792 12 -95456.2147 13 -46185.4250 14 -20583.5605 15 -43240.4927 16 19263.3718 17 35112.4021 18 45635.1615 19 -6023.5302 20 -22129.0792 21 -13168.4927 22 135203.5750 23 -1037.8760 24 -82676.3198 25 -24442.2521 26 -12480.8385 27 35471.6427 28 10377.1615 29 -18704.3573 30 16692.9208 31 9724.9208 32 -58799.3198 33 11611.8531 34 -84132.4250 35 82857.1615 36 13535.9886 37 84511.9208 38 -3508.9437 39 23308.0189 40 67024.4021 41 71653.9886 42 -45402.2521 43 -1065.1844 44 -50083.3573 45 -38064.3573 46 159196.5750 47 -80671.4250 48 -21049.0792 49 31644.2666 50 -50989.0792 51 16875.8834 52 -10842.3269 53 79249.5073 54 -49191.1166 55 8552.5376 56 47359.6427 57 -34726.9740 58 49107.4021 59 40859.3344 60 1435.4021 61 75659.5073 62 78038.6427 63 -42054.4927 64 27725.5750 65 2593.4021 66 16997.8834 67 -12492.3573 68 -28527.6656 69 6856.4021 70 -34702.3573 71 -53317.0792 72 -53560.9437 73 -41831.0792 74 4296.4021 75 -48816.4250 76 39694.1615 77 67893.4021 78 -29081.1844 79 -55811.4250 80 -25425.0114 81 -8718.1166 82 117261.9208 83 -12322.0114 84 -16771.8385 85 23297.0189 86 -21952.3573 87 -57367.4250 88 84980.4021 89 -5590.0792 90 -46910.8385 91 -5464.5979 92 -1622.0114 93 -4689.3573 94 26551.4021 95 39613.4021 96 -7255.5979 97 7191.4021 98 53918.4021 99 -24786.2147 100 116106.2292 101 -20772.4927 102 31318.5750 103 -19181.9437 104 -76589.5302 105 30242.1240 106 -4702.7708 107 3653.9886 108 26942.7479 109 -54425.1844 110 -58847.0114 111 32281.5750 112 -40077.9063 113 4876.9137 114 -22231.5979 115 -12768.2218 116 -84004.4927 117 110437.5750 118 8649.3273 119 54532.4698 120 -26241.9811 121 35277.1615 122 -48297.4927 123 -70157.5979 124 -42808.9437 125 -19441.9811 126 -45455.7708 127 -1454.3198 128 -61905.3198 129 63349.5073 130 10768.6802 131 59090.8531 132 8025.6427 133 -70362.5979 134 43298.9886 135 104208.5073 136 -80118.7708 137 89715.1615 138 -42250.5979 139 5027.1615 140 -22726.4250 141 -16201.2895 142 108945.8156 143 4207.4021 144 42070.6427 145 30484.9208 146 -133841.9740 147 477.4021 148 9014.3344 149 -12404.6727 150 2283.3273 151 -12306.6727 152 -11949.6727 153 -12404.6727 154 -12404.6727 155 12358.0563 156 13298.5073 157 -12404.6727 158 -12201.6727 159 -5205.6727 160 5973.2595 161 -514.0863 162 -68935.1844 163 -11435.6727 164 3754.7105 > library(lattice) > postscript(file="/var/wessaorg/rcomp/tmp/1ha0i1321983850.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/wessaorg/rcomp/tmp/289981321983850.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/wessaorg/rcomp/tmp/398sl1321983850.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/wessaorg/rcomp/tmp/4lvds1321983850.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/wessaorg/rcomp/tmp/52o761321983850.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/wessaorg/rcomp/tmp/6e9yk1321983850.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/wessaorg/rcomp/tmp/7xsyz1321983850.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/wessaorg/rcomp/tmp/86euo1321983850.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. 0.00 20.00 24.00 22.80 28.25 41.00 > > #Note: the /var/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/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/wessaorg/rcomp/tmp/9ov6w1321983850.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/wessaorg/rcomp/tmp/104g5e1321983850.tab") > > try(system("convert tmp/1ha0i1321983850.ps tmp/1ha0i1321983850.png",intern=TRUE)) character(0) > try(system("convert tmp/289981321983850.ps tmp/289981321983850.png",intern=TRUE)) character(0) > try(system("convert tmp/398sl1321983850.ps tmp/398sl1321983850.png",intern=TRUE)) character(0) > try(system("convert tmp/4lvds1321983850.ps tmp/4lvds1321983850.png",intern=TRUE)) character(0) > try(system("convert tmp/52o761321983850.ps tmp/52o761321983850.png",intern=TRUE)) character(0) > try(system("convert tmp/6e9yk1321983850.ps tmp/6e9yk1321983850.png",intern=TRUE)) character(0) > try(system("convert tmp/7xsyz1321983850.ps tmp/7xsyz1321983850.png",intern=TRUE)) character(0) > try(system("convert tmp/86euo1321983850.ps tmp/86euo1321983850.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.224 0.353 2.619