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(4.1,1.4,1.4,1.8,1.3,1.9,2.7,3.5,3.6,4.8,5.3,5.5,5.9,6.8,7.1,6.9,7.2,7.1,6.6,5.7,5.9,5.1,4.8,4.6,4.2,3.8,3.3,3.2,3.4,3.3,3.3,3.9,3.9,4.1,4,3.9,3.9,3.9,3.8,3.7,3.6,3.7,3.9,3.7,3.3,4,4,4.3,4,3.7,4.3,4.4,4.4,4.3,4.1,4.1,4.5,4,3.8,3.7) > x <- c(1,0.4,0.1,0.4,-0.5,1.6,2.6,3.8,5.5,6.3,6.1,4.2,3.6,5,5.5,5.9,6.4,5.5,6.7,3.6,4.3,3.2,3.4,4.7,3.5,4.1,2.5,3.7,5.6,5.2,3.7,7.6,5.7,6.3,7.9,6.8,8,7.6,8.7,5.3,5,3.6,3.7,3.1,1.7,5,4.7,3.8,3.5,3,2.5,4.8,3.4,3.7,4.6,3.9,5.9,3.5,1.5,3.9) > 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 1.00220694 2 -1.50054675 3 -1.40192360 4 -1.10054675 5 -1.30467729 6 -1.39503936 7 -0.92378321 8 -0.51827582 9 -0.97714036 10 -0.04013543 11 0.52561334 12 1.35022664 13 1.94747295 14 2.38723157 15 2.52285964 16 2.19136211 17 2.32699019 18 2.52285964 19 1.62836703 20 1.74747295 21 1.71735226 22 1.27897049 23 0.91322172 24 0.28585472 25 0.28034733 26 -0.31689897 27 -0.29090882 28 -0.78540144 29 -1.21001474 30 -1.17851720 31 -0.68540144 32 -1.36750243 33 -0.74288912 34 -0.74013543 35 -1.36612558 36 -1.10450735 37 -1.49899997 38 -1.36750243 39 -1.82912066 40 -0.81139159 41 -0.81276843 42 -0.25252705 43 -0.08540144 44 -0.08815513 45 -0.02791375 46 -0.41276843 47 -0.31414528 48 0.28172418 49 0.08034733 50 -0.05528074 51 0.70909118 52 0.05298034 53 0.51322172 54 0.31459856 55 -0.18127090 56 0.04884980 57 -0.20863789 58 0.08034733 59 0.53783502 60 -0.35115020 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/167m91258137868.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/2prxt1258137868.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/398gy1258137868.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/4hykj1258137868.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/5f3qs1258137868.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/6zgso1258137868.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/7h8jg1258137868.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/86vrg1258137868.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. -0.500 3.400 4.000 4.272 5.525 8.700 > > #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/91pd21258137868.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/10xxlp1258137868.tab") > > system("convert tmp/167m91258137868.ps tmp/167m91258137868.png") > system("convert tmp/2prxt1258137868.ps tmp/2prxt1258137868.png") > system("convert tmp/398gy1258137868.ps tmp/398gy1258137868.png") > system("convert tmp/4hykj1258137868.ps tmp/4hykj1258137868.png") > system("convert tmp/5f3qs1258137868.ps tmp/5f3qs1258137868.png") > system("convert tmp/6zgso1258137868.ps tmp/6zgso1258137868.png") > system("convert tmp/7h8jg1258137868.ps tmp/7h8jg1258137868.png") > system("convert tmp/86vrg1258137868.ps tmp/86vrg1258137868.png") > > > proc.time() user system elapsed 1.613 1.178 2.465