R version 2.8.0 (2008-10-20) Copyright (C) 2008 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(523.568,-3273.144,-10414.076,-6902.788,-2897.144,-4727.212,-8504.924,-9664.076,-9522.584,-11281.652,11711.704,18606.992,18669.28,20458.484,12320.416,11765.348,10978.348,12736.416,13642.196,6972.128,2179.06,2409.484,25864.196,29791.196,31499.552,23225.06,17110.416,20072.484,15823.416,14852.704,7120.212,7283.28,7607.992,2783.924,19491.856,20415.856,19612.432,5818.432,-1078.5,-4449.144,-681.788,-4945.432,-13923.432,-15768.432,-26036.212,-36721.212,-12942.856,-12288.924,-16241.5,-16101.008,-19161.516,-14289.804,-10476.38,-13384.024,-16588.176,-17771.888,-23359.328,-18508.192,3181.164,608.384,-161.26,-6787.108,-15131.804,-8601.584,-1830.652,-180.076,-3207.704,-2290.704,-14767.264,-14364.756,2786.108,11306.312) > x <- c(14836.775,4362.995,-4002.335,-1812.115,847.995,-1406.675,-4893.455,-8497.335,-9477.105,-4271.775,24414.115,33009.335,33054.555,37817.565,26184.895,25413.225,21611.225,20980.895,19480.345,12208.675,8744.005,13570.565,43565.345,47787.345,46298.235,32359.005,22631.895,24020.565,21922.895,17815.115,9175.885,6032.555,6020.335,8397.665,35700.995,41018.995,32444.435,13947.435,1575.105,-2651.005,-2245.115,-8832.225,-17035.225,-20944.225,-29913.675,-31604.675,2188.215,8149.545,-7346.895,-15975.665,-24040.435,-22757.655,-20422.095,-26004.205,-30769.085,-33706.865,-40292.965,-31693.625,-1712.735,1714.815,-12289.295,-24404.415,-34307.655,-30919.105,-28222.775,-28942.335,-33556.905,-34260.905,-43434.805,-37319.035,-9341.375,3.635) > 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 -7307.05098 2 -5575.86930 3 -8301.71382 4 -5946.38894 5 -3344.70848 6 -3984.79769 7 -5922.24293 8 -5179.32467 9 -4520.72572 10 -9027.08370 11 -1173.68196 12 1185.18630 13 1223.60791 14 498.97135 15 -1499.55934 16 -1647.35225 17 -427.71742 18 1663.02868 19 3360.77499 20 528.57819 21 -2435.89235 22 -4752.84958 23 2871.09694 24 4569.79282 25 7064.07727 26 6146.48808 27 5165.65727 28 7394.80744 29 4252.85614 30 5450.16477 31 2277.32028 32 4099.38762 33 4430.54914 34 -1648.23564 35 649.43517 36 -1233.32023 37 2488.77149 38 -1542.80754 39 -1909.82151 40 -3049.99220 41 503.14154 42 -283.93108 43 -4932.51879 44 -4714.41106 45 -10248.25871 46 -20040.77594 47 -14097.76717 48 -16590.12987 49 -12363.93251 50 -7669.31362 51 -6473.36491 52 -2278.68369 53 302.06907 54 340.57351 55 -348.75098 56 18.05035 57 -2093.35134 58 -1780.80955 59 4085.11189 60 -296.67422 61 6324.82721 62 6093.14592 63 2975.22171 64 7717.01918 65 13064.87130 66 15095.21956 67 14503.08786 68 15791.64780 69 8156.92560 70 5331.62794 71 7716.33015 72 11304.38724 > library(lattice) > postscript(file="/var/www/html/freestat/rcomp/tmp/1uzoq1257688140.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/freestat/rcomp/tmp/25e151257688140.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/freestat/rcomp/tmp/3u2mn1257688140.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/freestat/rcomp/tmp/4hf9x1257688140.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/freestat/rcomp/tmp/56nqg1257688140.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/freestat/rcomp/tmp/6ueky1257688140.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/freestat/rcomp/tmp/75j2k1257688140.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/freestat/rcomp/tmp/896zy1257688140.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. -4.343e+04 -2.140e+04 -7.015e+02 -8.194e-03 1.986e+04 4.779e+04 > > #Note: the /var/www/html/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/freestat/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/freestat/rcomp/tmp/9i0811257688140.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/freestat/rcomp/tmp/10vzs41257688140.tab") > > system("convert tmp/1uzoq1257688140.ps tmp/1uzoq1257688140.png") > system("convert tmp/25e151257688140.ps tmp/25e151257688140.png") > system("convert tmp/3u2mn1257688140.ps tmp/3u2mn1257688140.png") > system("convert tmp/4hf9x1257688140.ps tmp/4hf9x1257688140.png") > system("convert tmp/56nqg1257688140.ps tmp/56nqg1257688140.png") > system("convert tmp/6ueky1257688140.ps tmp/6ueky1257688140.png") > system("convert tmp/75j2k1257688140.ps tmp/75j2k1257688140.png") > system("convert tmp/896zy1257688140.ps tmp/896zy1257688140.png") > > > proc.time() user system elapsed 2.603 2.003 2.862