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(111.2,116.7,114.8,100.0,98.8,106.3,119.5,120.7,121.1,112.4,108.2,113.6,106.7,114.3,117.3,109.6,109.9,112.5,116.1,112.0,113.3,107.9,108.2,114.8,105.6,111.9,113.6,108.4,111.1,112.5,112.6,108.7,108.9,104.5,105.9,111.1,102.2,108.3,112.3,110.8,108.6,103.8,96.6,88.0,85.6,88.8,92.9,98.8,88.8,90.5,87.7,81.9,80.2,86.3,94.3,94.6,92.2,88.8,88.2,96.3) > x <- c(126.2,127.0,127.1,123.6,125.0,134.7,140.7,137.9,142.1,137.5,136.4,140.7,120.0,123.8,132.2,136.4,144.2,144.9,138.9,129.3,133.3,137.5,140.0,146.3,124.6,130.2,139.0,149.1,151.9,149.0,127.8,113.8,117.5,123.2,127.3,131.5,110.8,112.7,116.9,127.3,130.8,130.6,124.1,113.8,112.3,112.5,112.7,120.4,104.6,107.9,108.5,110.9,111.5,124.5,133.3,125.9,121.1,108.9,105.5,114.8) > 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 7.1731465 2 12.1726323 3 10.2100680 4 -2.4001821 5 -4.4760821 6 -3.0448174 7 6.4013256 8 9.3531255 9 7.1254257 10 1.3033827 11 -2.2084102 12 0.5013256 13 6.5521320 14 11.7746893 15 9.5192896 16 -0.8084102 17 -5.3884242 18 -3.2263742 19 4.1274827 20 6.0336538 21 4.8310825 22 -3.1966173 23 -4.4607244 24 -1.8022742 25 2.5741750 26 5.3705752 27 1.5649184 28 -9.9540741 29 -9.0058740 30 -5.7915098 31 7.5721180 32 12.4311175 33 10.3162391 34 2.3500750 35 1.1849394 36 3.7572396 37 7.8080460 38 12.7193246 39 14.0916248 40 6.0849394 41 1.6951895 42 -2.9796819 43 -6.1130036 44 -8.2688825 45 -9.7304183 46 -6.6555468 47 -2.6806754 48 -1.5981251 49 -1.7129686 50 -2.0775899 51 -5.2529756 52 -12.5545183 53 -14.6299040 54 -16.6632607 55 -14.1689175 56 -9.2391606 57 -8.6360751 58 -4.4032327 59 -2.8760471 60 -0.5945253 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/1ckfx1258137792.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/2q8rk1258137792.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/3nbgc1258137792.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/4dgri1258137792.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/5rkd01258137792.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/6qox61258137792.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/7nvew1258137792.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/8fkl61258137792.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. 104.6 116.4 127.0 126.9 136.7 151.9 > > #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/9rglk1258137792.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/108smv1258137792.tab") > > system("convert tmp/1ckfx1258137792.ps tmp/1ckfx1258137792.png") > system("convert tmp/2q8rk1258137792.ps tmp/2q8rk1258137792.png") > system("convert tmp/3nbgc1258137792.ps tmp/3nbgc1258137792.png") > system("convert tmp/4dgri1258137792.ps tmp/4dgri1258137792.png") > system("convert tmp/5rkd01258137792.ps tmp/5rkd01258137792.png") > system("convert tmp/6qox61258137792.ps tmp/6qox61258137792.png") > system("convert tmp/7nvew1258137792.ps tmp/7nvew1258137792.png") > system("convert tmp/8fkl61258137792.ps tmp/8fkl61258137792.png") > > > proc.time() user system elapsed 1.587 1.164 1.933