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(94.3,99.4,115.7,116.8,99.8,96,115.9,109.1,117.3,109.8,112.8,110.7,100,113.3,122.4,112.5,104.2,92.5,117.2,109.3,106.1,118.8,105.3,106,102,112.9,116.5,114.8,100.5,85.4,114.6,109.9,100.7,115.5,100.7,99,102.3,108.8,105.9,113.2,95.7,80.9,113.9,98.1,102.8,104.7,95.9,94.6,101.6,103.9,110.3,114.1,96.8,87.4,111.4,97.4,102.9,112.7,97,95.1) > x <- c(160,171.4,192,231.2,250.8,268.4,266.9,268.5,268.2,265.3,253.8,243.4,213.6,221,227.3,221.6,222.1,232.2,229.6,238.9,238.2,223.9,215,211.1,210.6,206.6,207,201.7,204.5,204.5,195.1,205.5,187.5,173.5,172.3,167.5,157.5,151.1,148.5,147.9,145.6,139.8,138.9,141.4,148.7,150.9,147.3,144.5,134,135.1,131.4,128.4,127.6,127.4,124,123.5,128,129.9,127.6,121.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 -9.26650305 2 -4.97251763 3 9.87099988 4 8.19944097 5 -10.18633849 6 -15.23071188 7 4.77534267 8 -2.13778219 9 6.08342872 10 -1.21153248 11 2.60155241 12 1.23686396 13 -7.35618564 14 5.42061191 15 14.07518280 16 4.57819009 17 -3.75716143 18 -16.17126207 19 8.71256582 20 0.15502761 21 -2.99548027 22 10.71557311 23 -2.15516989 24 -1.17942806 25 -5.14407654 26 6.03873559 27 9.61045438 28 8.28518045 29 -6.21278804 30 -21.31278804 31 8.55182048 32 3.11650893 33 -4.81083647 34 10.97900600 35 -3.73615036 36 -5.09677580 37 -1.08974546 38 5.86275395 39 3.14658184 40 10.48900366 41 -6.84837936 42 -21.23830177 43 11.82533096 44 -4.15142662 45 0.03244123 46 1.77689456 47 -6.76857452 48 -7.87060603 49 -0.12822417 50 2.09400249 51 8.75560371 52 12.76771281 53 -4.47572476 54 -13.86158415 55 10.37880616 56 -3.58584232 57 1.59599403 58 11.26165826 59 -4.27572476 60 -5.76564716 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/1f4bz1257166925.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/2b5921257166925.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/3d1p31257166925.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/4nacl1257166925.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/5590b1257166925.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/608zb1257166925.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/71oxw1257166925.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/8vyaf1257166925.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. 121.8 143.7 189.8 186.2 222.6 268.5 > > #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/9fqaq1257166925.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/10pn4j1257166925.tab") > system("convert tmp/1f4bz1257166925.ps tmp/1f4bz1257166925.png") > system("convert tmp/2b5921257166925.ps tmp/2b5921257166925.png") > system("convert tmp/3d1p31257166925.ps tmp/3d1p31257166925.png") > system("convert tmp/4nacl1257166925.ps tmp/4nacl1257166925.png") > system("convert tmp/5590b1257166925.ps tmp/5590b1257166925.png") > system("convert tmp/608zb1257166925.ps tmp/608zb1257166925.png") > system("convert tmp/71oxw1257166925.ps tmp/71oxw1257166925.png") > system("convert tmp/8vyaf1257166925.ps tmp/8vyaf1257166925.png") > > > proc.time() user system elapsed 1.615 1.156 2.825