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(581000,597000,587000,536000,524000,537000,536000,533000,528000,516000,502000,506000,518000,534000,528000,478000,469000,490000,493000,508000,517000,514000,510000,527000,542000,565000,555000,499000,511000,526000,532000,549000,561000,557000,566000,588000,620000,626000,620000,573000,573000,574000,580000,590000,593000,597000,595000,612000,628000,629000,621000,569000,567000,573000,584000,589000,591000,595000,594000,611000) > x <- c(111632,106707,108827,108413,106249,104861,102382,100320,100228,117089,121523,114948,112831,107605,108928,101993,102850,99925,101536,99450,98305,110159,109483,106810,96279,91982,90276,90999,86622,83117,80367,77550,77443,92844,92175,84822,81632,78872,81485,80651,78192,76844,76335,71415,73899,86822,86371,83469,82662,82880,89406,95378,97657,100247,99180,97493,101628,114585,115669,111311) > par2 = '36' > par1 = '0' > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: > 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 45942.138 2 55069.525 3 48027.888 4 -3549.830 5 -18569.593 6 -7506.484 7 -11965.815 8 -17843.242 9 -22971.624 10 -11442.867 11 -19255.423 12 -24430.535 13 -15384.712 14 -6677.357 15 -10831.171 16 -70508.647 17 -78312.743 18 -61394.447 19 -56146.370 20 -44057.288 21 -36655.083 22 -23113.366 23 -28056.694 24 -14786.743 25 -14482.274 26 2521.459 27 -9859.186 28 -64850.273 29 -58958.177 30 -48849.245 31 -46686.744 32 -33617.739 33 -21767.053 34 -4275.660 35 3790.781 36 15530.005 37 43078.506 38 45227.052 39 42873.374 40 -5290.435 41 -8721.857 42 -9602.930 43 -4313.216 44 -1178.852 45 5287.457 46 27320.914 47 24691.564 48 37641.955 49 52515.824 50 53820.033 51 54926.768 52 11260.422 53 12440.663 54 22054.889 55 31565.940 56 34211.808 57 41982.012 58 64062.915 59 64575.587 60 75494.197 > library(lattice) > postscript(file="/var/www/rcomp/tmp/1cj4n1257297025.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/2a6rd1257297025.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/3ur7b1257297025.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/4hsgr1257297025.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/5k3kc1257297025.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/6us8d1257297025.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/7lomg1257297025.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/83lvd1257297025.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. 71420 83380 97980 95860 106700 121500 > > #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/917ca1257297025.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/100l731257297025.tab") > system("convert tmp/1cj4n1257297025.ps tmp/1cj4n1257297025.png") > system("convert tmp/2a6rd1257297025.ps tmp/2a6rd1257297025.png") > system("convert tmp/3ur7b1257297025.ps tmp/3ur7b1257297025.png") > system("convert tmp/4hsgr1257297025.ps tmp/4hsgr1257297025.png") > system("convert tmp/5k3kc1257297025.ps tmp/5k3kc1257297025.png") > system("convert tmp/6us8d1257297025.ps tmp/6us8d1257297025.png") > system("convert tmp/7lomg1257297025.ps tmp/7lomg1257297025.png") > system("convert tmp/83lvd1257297025.ps tmp/83lvd1257297025.png") > > > proc.time() user system elapsed 2.060 1.670 3.433