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(62,64,62,64,64,69,69,65,56,58,53,62,55,60,59,58,53,57,57,53,54,53,57,57,55,49,50,49,54,58,58,52,56,52,59,53,52,53,51,50,56,52,46,48,46,48,48,49,53,48,51,48,50,55,52,53,52,55,53,53,56,54,52,55,54,59,56,56,51,53,52,51,46,49,46,55,57,53,52,53,50,54,53,50,51,52,47,51,49,53,52,45,53,51,48,48,48,48,40,43,40,39,39,36,41,39,40,39,46,40,37,37,44,41,40,36,38,43,42,45,46) > x <- c(33,39,45,46,45,45,49,50,54,59,58,56,48,50,52,53,55,43,42,38,41,41,39,34,27,15,14,31,41,43,46,42,45,45,40,35,36,38,39,32,24,21,12,29,36,31,28,30,38,27,40,40,44,47,45,42,38,46,37,41,40,33,34,36,36,38,42,35,25,24,22,27,17,30,30,34,37,36,33,33,33,37,40,35,37,43,42,33,39,40,37,44,42,43,40,30,30,31,18,24,22,26,28,23,17,12,9,19,21,18,18,15,24,18,19,30,33,35,36,47,46) > par2 = '1' > 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 11.83621813 2 11.27692398 3 6.71762983 4 8.29108081 5 8.71762983 6 13.71762983 7 12.01143373 8 7.58488471 9 -3.12131139 10 -3.25405652 11 -7.82750749 12 2.02559056 13 -1.56201724 14 2.58488471 15 0.73178666 16 -0.69476237 17 -6.54786042 18 2.57072788 19 2.99727691 20 0.70347300 21 0.42382593 22 -0.57617407 23 4.27692398 24 6.40966910 25 7.39551228 26 6.51410057 27 7.94064960 28 -0.31068382 29 0.42382593 30 3.57072788 31 2.29108081 32 -2.00272309 33 0.71762983 34 -3.28237017 35 5.85037495 36 1.98312008 37 0.55657105 38 0.70347300 39 -1.72307602 40 0.26276715 41 9.67515935 42 6.95480643 43 4.79374765 44 -0.45758577 45 -5.44342895 46 -1.31068382 47 -0.03103675 48 0.11586520 49 0.70347300 50 0.39551228 51 -2.14962505 52 -5.14962505 53 -4.85582114 54 -1.13546822 55 -3.28237017 56 -1.00272309 57 -0.29652700 58 -0.70891919 59 1.13002203 60 -0.57617407 61 2.85037495 62 3.83621813 63 1.40966910 64 3.55657105 65 2.55657105 66 6.70347300 67 1.99727691 68 4.98312008 69 4.24861033 70 6.67515935 71 6.52825740 72 3.39551228 73 2.66100252 74 0.11586520 75 -2.88413480 76 4.40966910 77 5.13002203 78 1.55657105 79 1.83621813 80 2.83621813 81 -0.16378187 82 2.13002203 83 -0.14962505 84 -1.01687992 85 -0.86997797 86 -2.42927212 87 -7.00272309 88 0.83621813 89 -3.72307602 90 -0.14962505 91 0.13002203 92 -9.85582114 93 -1.00272309 94 -3.42927212 95 -5.14962505 96 -0.88413480 97 -0.88413480 98 -1.31068382 99 -3.76554650 100 -3.32484065 101 -5.47174260 102 -8.17793870 103 -9.03103675 104 -9.89829162 105 -2.33899748 106 -2.20625235 107 0.07339472 108 -5.19209552 109 0.95480643 110 -3.76554650 111 -6.76554650 112 -5.48589943 113 -2.32484065 114 -2.76554650 115 -4.19209552 116 -12.88413480 117 -12.16378187 118 -8.01687992 119 -9.44342895 120 -11.13546822 121 -9.70891919 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/1g3sp1256303294.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/2aonu1256303294.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/38ita1256303294.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/47bhr1256303294.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/590yf1256303294.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/68hto1256303294.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/7rzok1256303294.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/8b4ac1256303294.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. 9.00 29.00 36.00 35.17 42.00 59.00 > > #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/945a51256303294.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/10ika91256303294.tab") > > system("convert tmp/1g3sp1256303294.ps tmp/1g3sp1256303294.png") > system("convert tmp/2aonu1256303294.ps tmp/2aonu1256303294.png") > system("convert tmp/38ita1256303294.ps tmp/38ita1256303294.png") > system("convert tmp/47bhr1256303294.ps tmp/47bhr1256303294.png") > system("convert tmp/590yf1256303294.ps tmp/590yf1256303294.png") > system("convert tmp/68hto1256303294.ps tmp/68hto1256303294.png") > system("convert tmp/7rzok1256303294.ps tmp/7rzok1256303294.png") > system("convert tmp/8b4ac1256303294.ps tmp/8b4ac1256303294.png") > > > proc.time() user system elapsed 1.641 1.227 2.574