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(11.1,10.9,10,9.2,9.2,9.5,9.6,9.5,9.1,8.9,9,10.1,10.3,10.2,9.6,9.2,9.3,9.4,9.4,9.2,9,9,9,9.8,10,9.8,9.3,9,9,9.1,9.1,9.1,9.2,8.8,8.3,8.4,8.1,7.7,7.9,7.9,8,7.9,7.6,7.1,6.8,6.5,6.9,8.2,8.7,8.3,7.9,7.5,7.8,8.3,8.4,8.2,7.7,7.2,7.3,8.1) > 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.29775432 2 0.05395622 3 0.75686475 4 0.28167234 5 -0.01832766 6 0.04736949 7 0.36926854 8 0.84736949 9 0.45977328 10 0.11597518 11 0.53787423 12 0.97876380 13 1.02256191 14 1.10066285 15 0.26926854 16 0.28167234 17 0.60357139 18 0.32547044 19 0.12547044 20 -0.61832766 21 -0.36212577 22 -0.16212577 23 -0.46212577 24 -0.58693335 25 -0.54313525 26 -0.98693335 27 -1.09642861 28 -0.86212577 29 -0.76212577 30 -0.64022672 31 -0.54022672 32 -0.54022672 33 -0.51832766 34 -1.10592387 35 -1.21541913 36 -1.09352008 37 -1.45921723 38 -1.14681344 39 -0.40301534 40 0.29698466 41 0.51888372 42 0.89698466 43 0.93128751 44 1.62179225 45 1.35609509 46 2.29039794 47 2.97799415 48 3.36268182 49 2.97217708 50 2.98458087 51 2.09698466 52 0.40938846 53 -0.02491439 54 -0.21541913 55 -0.59352008 56 -1.93731818 57 -2.04681344 58 -3.15630870 59 -3.83440965 60 -4.25921723 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/18uv31257801146.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/2ns1z1257801146.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/3zbfp1257801146.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/42js41257801146.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/52n221257801146.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/6i0e91257801146.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/7qe4s1257801146.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/82q0z1257801146.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. 6.500 7.975 9.000 8.743 9.325 11.100 > > #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/9n7vy1257801146.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/101x8d1257801146.tab") > > system("convert tmp/18uv31257801146.ps tmp/18uv31257801146.png") > system("convert tmp/2ns1z1257801146.ps tmp/2ns1z1257801146.png") > system("convert tmp/3zbfp1257801146.ps tmp/3zbfp1257801146.png") > system("convert tmp/42js41257801146.ps tmp/42js41257801146.png") > system("convert tmp/52n221257801146.ps tmp/52n221257801146.png") > system("convert tmp/6i0e91257801146.ps tmp/6i0e91257801146.png") > system("convert tmp/7qe4s1257801146.ps tmp/7qe4s1257801146.png") > system("convert tmp/82q0z1257801146.ps tmp/82q0z1257801146.png") > > > proc.time() user system elapsed 1.612 1.153 7.433