R version 2.9.0 (2009-04-17) Copyright (C) 2009 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(8987,8832,8802,8576,8498,8901,8835,8655,8665,8416,8423,8255,8919,9031,8737,8754,8640,8776,8896,8557,8777,8434,8626,8461,8794,8566,8184,8126,8066,8137,8092,7904,7898,7920,8083,8039,8054,8095,7985,7980,7914,7703,7726,7587,7367,7393,7403,7444,7512,7699,7627,7684,7843,7959,8191,8367,8057,8187,8319,8435) > x <- c(5840,5823,5855,5855,5907,6056,6040,5966,6031,6028,5959,5517,6115,6162,6137,6211,6263,6409,6441,6405,6514,6356,6382,6321,6332,6211,6102,6143,6180,6142,6162,6110,6114,6169,6193,6159,6103,6112,6045,6115,6121,6039,6012,5946,5930,5984,6050,6033,5917,6029,6078,6159,6229,6335,6471,6571,6467,6587,6633,6700) > 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 849.6881718 2 700.5910610 3 659.4797402 4 433.4797402 5 337.4238441 6 688.6867570 7 628.2424173 8 473.9373465 9 461.3674763 10 213.4091626 11 244.3679479 12 229.8430653 13 686.2002594 14 781.8805071 15 496.5612264 16 487.8662972 17 355.8104011 18 441.1150003 19 550.0036796 20 223.5039154 21 405.6559792 22 117.5181252 23 300.4901771 24 156.6711323 25 485.8516158 26 299.8662972 27 -44.2857666 28 -116.5221462 29 -189.3696108 30 -105.1749175 31 -157.1194929 32 -327.0635967 33 -334.4525118 34 -331.5500943 35 -176.8835849 36 -209.0778066 37 -174.6329953 38 -136.7580543 39 -223.4937265 40 -252.7997406 41 -320.8831132 42 -503.4103539 43 -471.0351770 44 -587.1180781 45 -801.5624177 46 -794.3127714 47 -807.2298704 48 -760.3269813 49 -652.0484437 50 -503.9380662 51 -592.9522760 52 -564.0778066 53 -429.3838207 54 -350.1900706 55 -165.4131836 56 -24.1360609 57 -298.0242685 58 -209.6917212 59 -93.6642448 60 -0.9285725 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/1j8ho1256657072.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/rcomp/tmp/2ugnw1256657072.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/rcomp/tmp/3n54z1256657072.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/rcomp/tmp/46wrk1256657072.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/rcomp/tmp/5bf6g1256657072.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/rcomp/tmp/6z6l31256657072.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/rcomp/tmp/7xdsj1256657072.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/rcomp/tmp/8d5b41256657072.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. 5517 6030 6118 6155 6278 6700 > > #Note: the /var/www/html/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/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/rcomp/tmp/9thqw1256657073.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/rcomp/tmp/10mkp81256657073.tab") > > system("convert tmp/1j8ho1256657072.ps tmp/1j8ho1256657072.png") > system("convert tmp/2ugnw1256657072.ps tmp/2ugnw1256657072.png") > system("convert tmp/3n54z1256657072.ps tmp/3n54z1256657072.png") > system("convert tmp/46wrk1256657072.ps tmp/46wrk1256657072.png") > system("convert tmp/5bf6g1256657072.ps tmp/5bf6g1256657072.png") > system("convert tmp/6z6l31256657072.ps tmp/6z6l31256657072.png") > system("convert tmp/7xdsj1256657072.ps tmp/7xdsj1256657072.png") > system("convert tmp/8d5b41256657072.ps tmp/8d5b41256657072.png") > > > proc.time() user system elapsed 1.554 1.154 2.130