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(1173,669,1154,1948,722,336,2727,345,1416,1208,1432,1246,1205,1732,1214,3222,1385,2011,884,1631,1460,1950,860,1165,2115,1940,1858,1347,1093,1650,1551,1273,1478,670,2040,1562,2079,1113,686,2066,2251,1107,1245,1021,1735,3681,918,1582,2900,1497,1116,496,1778,744,1104,1703,1871,2460,1705,1334,2647,2218,1635,1741,991,1195,1283,1992,1522,1071,1441,852,1425,1246,1100,1400,1556,1015,1002,1190,1244,2657,1232,1344,870,1474,881,2489,1444,1995,1258,1357,1329,2041,1454,1171,1219,1522,2314,2289,1371,1639,1000,602,1380,1208,1490,1801,728,1152,1277,1401,391,1264,530,1123,2055,387,1486,449,2212,1148,814,1015,568,936,1586,871,2276,1638,2238,838,841,1904,3054,655,2617,1314,1154,1497,754,2832,1281,2035,1894,1268,1714,1568,0,207,5,8,0,0,1302,1831,0,4,151,474,141,705,29,1033) > 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 46145.7572 2 10697.7209 3 5170.1824 4 -46681.1135 5 11357.0084 6 -5047.1424 7 42096.4525 8 -11942.6596 9 -24483.2074 10 9156.0792 11 27346.5398 12 11664.2287 13 -14302.7484 14 17065.2995 15 16056.7344 16 -58427.9939 17 38331.9074 18 5483.2660 19 17205.6987 20 -8683.2296 21 22416.5973 22 95275.1049 23 1879.0779 24 -7343.1164 25 -68962.3773 26 -45788.9871 27 -23870.9414 28 34228.7578 29 -4307.9787 30 28307.3452 31 30882.0345 32 6123.6771 33 68087.5629 34 -680.6699 35 39909.9328 36 5350.7356 37 54774.6916 38 3303.2053 39 3402.0773 40 4601.7720 41 -2944.5262 42 7239.5501 43 9992.6195 44 -28746.8410 45 -85550.8729 46 -47584.3715 47 -21124.5886 48 -2880.0804 49 -54604.1560 50 -24626.8623 51 12086.0329 52 -35059.6706 53 84182.3226 54 -18123.5892 55 -17706.2775 56 2957.6327 57 -4820.0218 58 -51293.2036 59 41515.8511 60 9570.8383 61 -3171.2834 62 -16004.6298 63 -23337.7928 64 7942.7823 65 43790.8830 66 4593.1596 67 -16410.2309 68 -55535.3088 69 -3129.6323 70 -18185.3811 71 -21556.9774 72 -21590.7957 73 -8528.7246 74 20914.2287 75 -6812.7143 76 58437.0454 77 54630.0804 78 4146.5038 79 -4361.4158 80 2247.1136 81 -25845.9897 82 31810.8086 83 11301.7000 84 7368.9302 85 -14344.8301 86 -44280.8739 87 5745.8711 88 -18215.5368 89 25880.8502 90 -85520.4812 91 9996.5391 92 9952.8498 93 -13041.2077 94 -33461.4580 95 36181.9421 96 16591.5388 97 26411.7804 98 43932.3677 99 -20611.1467 100 20875.6234 101 23391.3786 102 21367.6440 103 -1477.6342 104 -26178.0955 105 -16964.1386 106 4265.0792 107 2408.8733 108 12689.3342 109 6466.6636 110 -27512.0360 111 57224.1139 112 6850.6546 113 -26188.6365 114 -7348.8057 115 -667.9578 116 -15935.7027 117 60388.0708 118 -27687.0733 119 19734.4365 120 -23303.3029 121 -24249.2850 122 17361.5272 123 -11898.9453 124 -26550.4962 125 -27973.8082 126 -10269.6230 127 33298.3564 128 41766.7791 129 20279.7038 130 40509.0348 131 42309.5542 132 47001.6755 133 -14706.4969 134 2148.0817 135 -13853.3394 136 -17846.8079 137 -8849.5593 138 -32187.3457 139 47482.1824 140 -18989.8623 141 2589.5028 142 -32968.5816 143 17451.5507 144 -34333.1132 145 18579.9897 146 -45811.3689 147 -28015.6661 148 22876.3908 149 -11437.8333 150 -16702.7291 151 -11821.7873 152 -11753.9597 153 -11437.8333 154 -11437.8333 155 952.3439 156 13122.6102 157 -11437.8333 158 -11620.3965 159 -18793.8442 160 -10467.0729 161 -7481.9362 162 -5826.3480 163 -13264.1665 164 -4347.5307 > library(lattice) > postscript(file="/var/wessaorg/rcomp/tmp/1jm2r1321983215.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/28k9w1321983215.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/36gin1321983215.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/4x8ih1321983215.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/58yt61321983215.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/6hv251321983215.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/7ncdb1321983215.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/8dstx1321983215.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.0 977.2 1292.0 1348.0 1718.0 3681.0 > > #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/9fvon1321983215.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/10gykm1321983215.tab") > > try(system("convert tmp/1jm2r1321983215.ps tmp/1jm2r1321983215.png",intern=TRUE)) character(0) > try(system("convert tmp/28k9w1321983215.ps tmp/28k9w1321983215.png",intern=TRUE)) character(0) > try(system("convert tmp/36gin1321983215.ps tmp/36gin1321983215.png",intern=TRUE)) character(0) > try(system("convert tmp/4x8ih1321983215.ps tmp/4x8ih1321983215.png",intern=TRUE)) character(0) > try(system("convert tmp/58yt61321983215.ps tmp/58yt61321983215.png",intern=TRUE)) character(0) > try(system("convert tmp/6hv251321983215.ps tmp/6hv251321983215.png",intern=TRUE)) character(0) > try(system("convert tmp/7ncdb1321983215.ps tmp/7ncdb1321983215.png",intern=TRUE)) character(0) > try(system("convert tmp/8dstx1321983215.ps tmp/8dstx1321983215.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.103 0.385 2.503