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(3.2,3.7,3.5,3.4,3.3,3.1,3.4,3.9,3.8,3.4,3.3,3,2.9,3.1,2.9,2.8,2.7,2.5,2.7,3.1,3,2.5,2.3,2.1,2,2.3,2.1,2,1.9,1.8,1.9,2.3,2.2,1.9,1.7,1.6,1.5,1.7,1.6,1.6,1.5,1.4,1.6,1.9,1.8,1.6,1.6,1.6,1.7,2,1.9,2,2.1,2,2.2,2.6,2.6,2.2,2.1,2.1) > x <- c(3.9,4.4,4.1,4.1,3.8,3.4,3.4,3.6,3.6,3.4,3.3,3.1,3.2,3.4,3.1,3,2.8,2.5,2.5,2.6,2.5,2.3,2.2,2.1,2.1,2.3,2.2,2.1,1.9,1.7,1.7,1.9,1.8,1.7,1.6,1.6,1.6,1.9,1.8,1.8,1.6,1.5,1.5,1.7,1.7,1.7,1.8,2,2.3,3,3.2,3.4,3.5,3.2,3.2,3.4,3.3,3.1,3.1,3.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.037839660 2 0.122718491 3 0.126383600 4 0.026383600 5 0.130048710 6 0.201602189 7 0.501602189 8 0.865825449 9 0.765825449 10 0.501602189 11 0.469490558 12 0.305267298 13 0.137378928 14 0.201602189 15 0.205267298 16 0.173155668 17 0.208932407 18 0.212597517 19 0.412597517 20 0.744709147 21 0.712597517 22 0.348374256 23 0.216262626 24 0.084150996 25 -0.015849004 26 0.148374256 27 0.016262626 28 -0.015849004 29 0.019927735 30 0.055704475 31 0.155704475 32 0.419927735 33 0.387816105 34 0.155704475 35 0.023592844 36 -0.076407156 37 -0.176407156 38 -0.180072265 39 -0.212183895 40 -0.212183895 41 -0.176407156 42 -0.208518786 43 -0.008518786 44 0.155704475 45 0.055704475 46 -0.144295525 47 -0.212183895 48 -0.347960635 49 -0.451625744 50 -0.626844332 51 -0.862621072 52 -0.898397811 53 -0.866286181 54 -0.762621072 55 -0.562621072 56 -0.298397811 57 -0.230509442 58 -0.494732702 59 -0.594732702 60 -0.594732702 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/1wqnc1260434073.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/2iafj1260434073.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/38mwd1260434073.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/46ltu1260434073.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/5cu651260434073.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/61z861260434073.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/7o1j31260434073.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/869lj1260434073.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. 1.500 1.800 2.500 2.622 3.300 4.400 > > #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/938j61260434073.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/10sxfd1260434073.tab") > > system("convert tmp/1wqnc1260434073.ps tmp/1wqnc1260434073.png") > system("convert tmp/2iafj1260434073.ps tmp/2iafj1260434073.png") > system("convert tmp/38mwd1260434073.ps tmp/38mwd1260434073.png") > system("convert tmp/46ltu1260434073.ps tmp/46ltu1260434073.png") > system("convert tmp/5cu651260434073.ps tmp/5cu651260434073.png") > system("convert tmp/61z861260434073.ps tmp/61z861260434073.png") > system("convert tmp/7o1j31260434073.ps tmp/7o1j31260434073.png") > system("convert tmp/869lj1260434073.ps tmp/869lj1260434073.png") > > > proc.time() user system elapsed 1.555 1.141 2.195