R version 2.8.0 (2008-10-20) 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(22.9,22.6,22.3,22.3,22.6,23.1,22.8,22.5,22.9,23.1,23.1,23.2,22.5,22.6,22.9,22.6,22.4,21.7,22,22.2,21.9,21.6,21.6,21.2,21.2,21.5,21.6,21.7,21.8,21.8,21.8,21.3,21.3,21.4,21.1,21.5,22.2,22.9,23.1,23.5,23.6,24.4,24.2,25.2,25.8,25.9,25.4,25.5,24.7,23.1,22.6,22.3,21.9,20.6,20.6,19.6,18.9,18.3,19.2,18.8) > x <- c(24,23,24,24,27,28,25,19,19,19,20,16,22,21,25,29,28,25,26,24,28,28,28,28,32,31,22,29,31,29,32,32,31,29,28,28,29,22,26,24,27,27,23,21,19,17,19,21,13,8,5,10,6,6,8,11,12,13,19,19) > 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.57022083 2 0.27900054 3 -0.02977917 4 -0.02977917 5 0.24388172 6 0.73510202 7 0.46144113 8 0.21411935 9 0.61411935 10 0.81411935 11 0.80533965 12 0.94045846 13 0.18778024 14 0.29655994 15 0.56144113 16 0.22632232 17 0.03510202 18 -0.63855887 19 -0.34733857 20 -0.12977917 21 -0.46489798 22 -0.76489798 23 -0.76489798 24 -1.16489798 25 -1.20001679 26 -0.89123709 27 -0.71221976 28 -0.67367768 29 -0.59123709 30 -0.57367768 31 -0.60001679 32 -1.10001679 33 -1.09123709 34 -0.97367768 35 -1.26489798 36 -0.86489798 37 -0.17367768 38 0.58778024 39 0.75266143 40 1.17022083 41 1.24388172 42 2.04388172 43 1.87900054 44 2.89655994 45 3.51411935 46 3.63167875 47 3.11411935 48 3.19655994 49 2.46679757 50 0.91069608 51 0.43703519 52 0.09313668 53 -0.27174451 54 -1.57174451 55 -1.58930392 56 -2.61564303 57 -3.32442273 58 -3.93320243 59 -3.08588065 60 -3.48588065 > library(lattice) > postscript(file="/var/www/html/freestat/rcomp/tmp/1f5aq1258021895.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/freestat/rcomp/tmp/2z4ju1258021895.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/freestat/rcomp/tmp/3ipb81258021895.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/freestat/rcomp/tmp/4g9jf1258021895.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/freestat/rcomp/tmp/59bfp1258021895.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/freestat/rcomp/tmp/6i6af1258021895.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/freestat/rcomp/tmp/782pa1258021895.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/freestat/rcomp/tmp/8iwyf1258021895.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.00 19.00 24.00 22.32 28.00 32.00 > > #Note: the /var/www/html/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/freestat/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/freestat/rcomp/tmp/9qk2p1258021895.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/freestat/rcomp/tmp/10od7p1258021895.tab") > > system("convert tmp/1f5aq1258021895.ps tmp/1f5aq1258021895.png") > system("convert tmp/2z4ju1258021895.ps tmp/2z4ju1258021895.png") > system("convert tmp/3ipb81258021895.ps tmp/3ipb81258021895.png") > system("convert tmp/4g9jf1258021895.ps tmp/4g9jf1258021895.png") > system("convert tmp/59bfp1258021895.ps tmp/59bfp1258021895.png") > system("convert tmp/6i6af1258021895.ps tmp/6i6af1258021895.png") > system("convert tmp/782pa1258021895.ps tmp/782pa1258021895.png") > system("convert tmp/8iwyf1258021895.ps tmp/8iwyf1258021895.png") > > > proc.time() user system elapsed 2.480 1.858 2.960