R version 2.8.1 (2008-12-22) 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(461.0085031,-442.3522321,13.83029183,-667.7601076,-552.5321684,-692.5998601,-633.3513695,-395.4396126,-430.0771524,-32.30854178,158.1259228,400.3735508,493.0556435,-438.6298993,-19.88011491,-602.3548196,-371.3273681,-424.5098919,-157.5775837,-458.102879,-556.8098356,153.0110907,209.9408113,579.3932397,479.3229603,-649.315442,203.4806202,-780.856976,-201.1002914,23.37872603,-161.6444129,-162.5758586,25.26389388,570.5818013,105.0753323,421.3666506,553.8644943,-1016.912742,-164.8476375,-547.2854028,-107.9426315,-132.3265055,290.6058027,-139.3042291,172.9254352,746.4704192,650.0805075,422.7308358,925.1172975,510.8534308,912.8259792,-81.07887749,363.3350358,298.7214974,-38.48675301,380.5621124,16.85256824,388.2338547,-192.1406809,321.043568) > x <- c(-8073.991497,-8361.352232,-8064.169708,-8021.760108,-7863.532168,-7780.59986,-8318.35137,-7932.439613,-8024.077152,-7828.308542,-7679.874077,-7749.626449,-7862.944357,-8165.629899,-8127.880115,-7976.35482,-8006.327368,-7969.509892,-8219.577584,-8294.102879,-8537.809836,-8012.988909,-8039.059189,-7918.60676,-8038.67704,-8360.315442,-8020.51938,-7938.856976,-8003.100291,-7776.621274,-7745.644413,-7715.575859,-7953.736106,-7636.418199,-7985.924668,-7977.633349,-8001.135506,-8539.912742,-8336.847638,-7333.285403,-7243.942631,-7198.326506,-7515.394197,-7775.304229,-7480.074565,-7422.529581,-7479.919493,-7894.269164,-8391.882703,-8288.146569,-8039.174021,-7569.078877,-7245.664964,-7293.278503,-7534.486753,-7338.437888,-7787.147432,-8697.766145,-9082.140681,-8610.956432) > 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 494.99018 2 -338.27417 3 45.41612 4 -646.51932 5 -569.88819 6 -730.18570 7 -539.76258 8 -395.98693 9 -408.27117 10 -58.25672 11 95.96987 12 355.23231 13 475.55623 14 -382.29472 15 27.24670 16 -592.18982 17 -353.85112 18 -416.01459 19 -88.08285 20 -370.42907 21 -409.68818 22 172.11230 23 235.40139 24 575.47165 25 504.69032 26 -545.49029 27 224.41875 28 -779.83889 29 -184.41123 30 -15.17762 31 -207.75699 32 -216.02311 33 29.91147 34 497.82549 35 117.57472 36 431.84352 37 570.07428 38 -869.27812 39 -66.74702 40 -693.98541 41 -276.43617 42 -311.94726 43 188.32790 44 -178.18184 45 62.03196 46 621.53990 47 539.14920 48 412.87254 49 1036.64271 50 597.07431 51 938.31457 52 -170.26139 53 195.26163 54 142.26254 55 -136.10738 56 235.11896 57 -19.13611 58 574.37392 59 87.76051 60 486.00800 > library(lattice) > postscript(file="/var/www/rcomp/tmp/1wysy1256903977.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/rcomp/tmp/2cd6s1256903977.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/rcomp/tmp/3o6oy1256903977.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/rcomp/tmp/4kqnu1256903977.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/rcomp/tmp/5rg3c1256903977.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/rcomp/tmp/6xh0s1256903977.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/rcomp/tmp/79g2a1256903977.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/rcomp/tmp/808vn1256903977.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. -9082 -8087 -7973 -7935 -7738 -7198 > > #Note: the /var/www/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/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/rcomp/tmp/9algd1256903977.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/rcomp/tmp/10pr0r1256903977.tab") > > system("convert tmp/1wysy1256903977.ps tmp/1wysy1256903977.png") > system("convert tmp/2cd6s1256903977.ps tmp/2cd6s1256903977.png") > system("convert tmp/3o6oy1256903977.ps tmp/3o6oy1256903977.png") > system("convert tmp/4kqnu1256903977.ps tmp/4kqnu1256903977.png") > system("convert tmp/5rg3c1256903977.ps tmp/5rg3c1256903977.png") > system("convert tmp/6xh0s1256903977.ps tmp/6xh0s1256903977.png") > system("convert tmp/79g2a1256903977.ps tmp/79g2a1256903977.png") > system("convert tmp/808vn1256903977.ps tmp/808vn1256903977.png") > > > proc.time() user system elapsed 1.630 1.480 3.205