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(82.1,55.1,60.6,56.5,53.4,58.5,60.7,47.3,53.7,46.9,51.8,55.2,61.6,47.5,46.1,54.3,49.2,62.6,54.7,48.4,42.1,46.6,55,56.7,55.7,52,65.2,51,57.3,60.5,59.2,40.8,39.5,54.6,54.7,53.3,56.7,57.8,57.1,51.1,60.3,58,63.2,54.5,50.3,48.2,51.3,52.6,68,67.5,53.4,65.3,64.9,51.9,60.6,50.5,61.5,74.4,66.4,69.8,96.8) > x <- c(107.3,107.2,107.2,105.7,105.7,104.9,104.8,104,104,103.6,103.6,103.6,103.6,104.2,104.2,104.7,104.7,104.7,106.1,106.1,106.1,106.1,106.1,106.1,106.1,106.1,106.1,106.1,106.1,106.1,106.1,106.1,106.1,106.2,106.4,106.4,106.4,107,107,107,107,106.1,106.3,106.2,106.2,106.3,106.3,106.2,107.1,105.2,103.4,102.4,100.6,100.6,100.6,99.8,100.2,101.4,101,100.6,100) > 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 28.624811242 2 1.487661115 3 6.987661115 4 0.830409209 5 -2.269590791 6 1.733208193 7 3.796058065 8 -10.701142951 9 -4.301142951 10 -11.649743459 11 -6.749743459 12 -3.349743459 13 3.050256541 14 -10.226842697 15 -11.626842697 16 -2.741092062 17 -7.841092062 18 5.558907938 19 -0.420990283 20 -6.720990283 21 -13.020990283 22 -8.520990283 23 -0.120990283 24 1.579009717 25 0.579009717 26 -3.120990283 27 10.079009717 28 -4.120990283 29 2.179009717 30 5.379009717 31 4.079009717 32 -14.320990283 33 -15.620990283 34 -0.383840155 35 -0.009539901 36 -1.409539901 37 1.990460099 38 3.913360861 39 3.213360861 40 -2.786639139 41 6.413360861 42 2.879009717 43 8.353309972 44 -0.483840155 45 -4.683840155 46 -6.646690028 47 -3.546690028 48 -2.383840155 49 14.250510988 50 11.144658574 51 -5.424043714 52 5.104455016 53 2.235752728 54 -10.764247272 55 -2.064247272 56 -13.261448288 57 -1.712847780 58 12.832953745 59 4.284353237 60 7.135752728 61 33.312851966 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/1nmxn1257934486.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/27rlp1257934486.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/3aq2z1257934486.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/4xq3j1257934486.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/5qri91257934486.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/61puf1257934486.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/7ur4e1257934486.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/8p9z91257934486.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. 99.8 104.0 106.1 104.9 106.2 107.3 > > #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/9a8yx1257934486.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/10ln0x1257934486.tab") > > system("convert tmp/1nmxn1257934486.ps tmp/1nmxn1257934486.png") > system("convert tmp/27rlp1257934486.ps tmp/27rlp1257934486.png") > system("convert tmp/3aq2z1257934486.ps tmp/3aq2z1257934486.png") > system("convert tmp/4xq3j1257934486.ps tmp/4xq3j1257934486.png") > system("convert tmp/5qri91257934486.ps tmp/5qri91257934486.png") > system("convert tmp/61puf1257934486.ps tmp/61puf1257934486.png") > system("convert tmp/7ur4e1257934486.ps tmp/7ur4e1257934486.png") > system("convert tmp/8p9z91257934486.ps tmp/8p9z91257934486.png") > > > proc.time() user system elapsed 1.619 1.175 1.985