R version 2.8.1 (2008-12-22) Copyright (C) 2008 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(25.60,23.70,22.00,21.30,20.70,20.40,20.30,20.40,19.80,19.50,23.10,23.50,23.50,22.90,21.90,21.50,20.50,20.20,19.40,19.20,18.80,18.80,22.60,23.30,23.00,21.40,19.90,18.80,18.60,18.40,18.60,19.90,19.20,18.40,21.10,20.50,19.10,18.10,17.00,17.10,17.40,16.80,15.30,14.30,13.40,15.30,22.10,23.70,22.20,19.50,16.60,17.30,19.80,21.20,21.50,20.60,19.10,19.60,23.50,24.00) > x <- c(161,149,139,135,130,127,122,117,112,113,149,157,157,147,137,132,125,123,117,114,111,112,144,150,149,134,123,116,117,111,105,102,95,93,124,130,124,115,106,105,105,101,95,93,84,87,116,120,117,109,105,107,109,109,108,107,99,103,131,137) > 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.67582611 2 0.17518537 3 -0.35868191 4 -0.59222883 5 -0.60916247 6 -0.55932265 7 -0.07625629 8 0.60681007 9 0.58987643 10 0.17326315 11 -0.42481463 12 -0.95772081 13 -0.95772081 14 -0.39158809 15 -0.22545537 16 -0.04238901 17 -0.22609611 18 -0.29286956 19 -0.39318993 20 -0.24335012 21 -0.29351030 22 -0.41012357 23 -0.34174827 24 -0.34142790 25 -0.52481463 26 -0.37561555 27 -0.59286956 28 -0.87657666 29 -1.19318993 30 -0.69351030 31 0.20616933 32 1.85600915 33 1.97230205 34 1.40552859 35 0.49051716 36 -0.80916247 37 -1.50948284 38 -1.45996339 39 -1.51044394 40 -1.29383067 41 -0.99383067 42 -1.12737758 43 -1.92769795 44 -2.69447141 45 -2.54495196 46 -0.99479178 47 2.42342334 48 3.55697025 49 2.40681007 50 0.63971624 51 -1.79383067 52 -1.32705721 53 0.93971624 54 2.33971624 55 2.75632951 56 1.97294279 57 1.40584896 58 1.43939587 59 2.07422426 60 1.87454463 > library(lattice) > postscript(file="/var/www/rcomp/tmp/14wal1257675165.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/rcomp/tmp/2alti1257675165.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/rcomp/tmp/36ouq1257675165.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/rcomp/tmp/4ibs91257675165.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/rcomp/tmp/566od1257675165.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/rcomp/tmp/6t6pp1257675165.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/rcomp/tmp/771311257675165.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/rcomp/tmp/8qx541257675165.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. 84.0 106.8 116.5 119.5 131.2 161.0 > > #Note: the /var/www/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/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/rcomp/tmp/93tdx1257675165.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/rcomp/tmp/101ayk1257675165.tab") > > system("convert tmp/14wal1257675165.ps tmp/14wal1257675165.png") > system("convert tmp/2alti1257675165.ps tmp/2alti1257675165.png") > system("convert tmp/36ouq1257675165.ps tmp/36ouq1257675165.png") > system("convert tmp/4ibs91257675165.ps tmp/4ibs91257675165.png") > system("convert tmp/566od1257675165.ps tmp/566od1257675165.png") > system("convert tmp/6t6pp1257675165.ps tmp/6t6pp1257675165.png") > system("convert tmp/771311257675165.ps tmp/771311257675165.png") > system("convert tmp/8qx541257675165.ps tmp/8qx541257675165.png") > > > proc.time() user system elapsed 1.770 1.580 3.365