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(8.1,8,7.5,7.4,7.7,7.9,7.7,7.1,6.2,5.8,6.1,6.9,7.3,7.2,6.1,5.8,6.1,6.3,6.8,6.8,6.5,6.2,6.3,6.4,6.6,7.6,6.4,6.8,7,6.9,7.1,7.2,7.1,7,6.9,6.7,6.6,6.9,7.3,7.9,8.2,8.2,8.2,8.1,7.9,7.7,7.7,7.6,7.5,7.5,7.1,7.5,7.5,7.8,7.8,7.8,7.6,7.5,7.7,8.1,8) > x <- c(-2,-2,-6,-7,-6,-6,-3,-2,-5,-11,-11,-11,-10,-14,-8,-9,-5,-1,-2,-5,-4,-6,-2,-2,-2,-2,2,1,-8,-1,1,-1,2,2,1,-1,-2,-2,-1,-8,-4,-6,-3,-3,-7,-9,-11,-13,-11,-9,-17,-22,-25,-20,-24,-24,-22,-19,-18,-17,-11) > 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 1.046549934 2 0.946549934 3 0.338844561 4 0.211918218 5 0.538844561 6 0.738844561 7 0.619623591 8 0.046549934 9 -0.934229096 10 -1.495787156 11 -1.195787156 12 -0.395787156 13 0.031139187 14 -0.176566186 15 -1.115008126 16 -1.441934469 17 -1.034229096 18 -0.726523722 19 -0.253450066 20 -0.334229096 21 -0.607302752 22 -0.961155439 23 -0.753450066 24 -0.653450066 25 -0.453450066 26 0.546549934 27 -0.545744692 28 -0.172671035 29 -0.215008126 30 -0.126523722 31 0.127328965 32 0.173476278 33 0.154255308 34 0.054255308 35 -0.072671035 36 -0.326523722 37 -0.453450066 38 -0.153450066 39 0.273476278 40 0.684991874 41 1.092697248 42 1.038844561 43 1.119623591 44 1.019623591 45 0.711918218 46 0.458065531 47 0.404212844 48 0.250360157 49 0.204212844 50 0.258065531 51 -0.357345216 52 -0.091976933 53 -0.172755963 54 0.261875754 55 0.154170380 56 0.154170380 57 0.008023067 58 -0.011197903 59 0.215728440 60 0.642654784 61 0.704212844 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/1ql6q1257366635.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/2v6ob1257366635.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/3wzah1257366635.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/4oys31257366635.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/5nk1j1257366635.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/6bnjt1257366635.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/791lt1257366635.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/801j91257366635.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. -25.000 -11.000 -6.000 -7.443 -2.000 2.000 > > #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/90orm1257366635.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/10jq501257366635.tab") > > system("convert tmp/1ql6q1257366635.ps tmp/1ql6q1257366635.png") > system("convert tmp/2v6ob1257366635.ps tmp/2v6ob1257366635.png") > system("convert tmp/3wzah1257366635.ps tmp/3wzah1257366635.png") > system("convert tmp/4oys31257366635.ps tmp/4oys31257366635.png") > system("convert tmp/5nk1j1257366635.ps tmp/5nk1j1257366635.png") > system("convert tmp/6bnjt1257366635.ps tmp/6bnjt1257366635.png") > system("convert tmp/791lt1257366635.ps tmp/791lt1257366635.png") > system("convert tmp/801j91257366635.ps tmp/801j91257366635.png") > > > proc.time() user system elapsed 1.597 1.196 2.548