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.2,4,4.9,4.6,4.3,4.3,4.6,5.1,4.8,4.5,4.9,5.1,5.1,5.2,4.5,4.6,4.9,4.6,4.4,3.7,4,4.2,3.9,3.6,3.6,3.2,3.2,3.5,3.6,3.7,3.8,3.8,3.8,3.3,3.3,3.4,3.1,3.5,4.2,4.9,5.1,5.5,5.6,6.4,6.2,7.2,7.8,7.9,7.4,7.5,6.7,5.1,4.6,4.3,3.9,2.6,2.6,1.6,0.9,0.3) > x <- c(8,8.1,7.7,7.5,7.6,7.8,7.8,7.8,7.5,7.5,7.1,7.5,7.5,7.6,7.7,7.7,7.9,8.1,8.2,8.2,8.2,7.9,7.3,6.9,6.6,6.7,6.9,7,7.1,7.2,7.1,6.9,7,6.8,6.4,6.7,6.6,6.4,6.3,6.2,6.5,6.8,6.8,6.4,6.1,5.8,6.1,7.2,7.3,6.9,6.1,5.8,6.2,7.1,7.7,7.9,7.7,7.4,7.5,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 0.38173786 2 0.25418106 3 0.86440825 4 0.41952185 5 0.19196505 6 0.33685145 7 0.63685145 8 1.13685145 9 0.61952185 10 0.31952185 11 0.42974904 12 0.91952185 13 0.91952185 14 1.09196505 15 0.46440825 16 0.56440825 17 1.00929466 18 0.85418106 19 0.72662426 20 0.02662426 21 0.32662426 22 0.30929466 23 -0.42536456 24 -1.01513737 25 -1.23246697 26 -1.56002377 27 -1.41513737 28 -1.04269416 29 -0.87025096 30 -0.69780776 31 -0.67025096 32 -0.81513737 33 -0.74269416 34 -1.38758057 35 -1.67735338 36 -1.36002377 37 -1.73246697 38 -1.47735338 39 -0.84979658 40 -0.22223978 41 0.19508983 42 0.81241943 43 0.91241943 44 1.42264662 45 1.00531702 46 1.78798741 47 2.60531702 48 3.50219224 49 3.07463544 50 2.88486263 51 1.50531702 52 -0.31201259 53 -0.52223978 54 -0.17025096 55 -0.13559175 56 -1.29070534 57 -1.43559175 58 -2.65292135 59 -3.28047815 60 -3.51826214 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/1x8iv1257799895.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/2dyf81257799895.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/37xi11257799895.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/4msv11257799895.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/5m6vg1257799895.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/659m31257799895.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/7alj21257799895.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/8h7771257799895.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. 5.800 6.700 7.200 7.172 7.700 8.200 > > #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/9kdz81257799895.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/10xjh41257799895.tab") > > system("convert tmp/1x8iv1257799895.ps tmp/1x8iv1257799895.png") > system("convert tmp/2dyf81257799895.ps tmp/2dyf81257799895.png") > system("convert tmp/37xi11257799895.ps tmp/37xi11257799895.png") > system("convert tmp/4msv11257799895.ps tmp/4msv11257799895.png") > system("convert tmp/5m6vg1257799895.ps tmp/5m6vg1257799895.png") > system("convert tmp/659m31257799895.ps tmp/659m31257799895.png") > system("convert tmp/7alj21257799895.ps tmp/7alj21257799895.png") > system("convert tmp/8h7771257799895.ps tmp/8h7771257799895.png") > > > proc.time() user system elapsed 1.624 1.198 2.329