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(4,3.8,4.7,4.3,3.9,4,4.3,4.8,4.4,4.3,4.7,4.7,4.9,5,4.2,4.3,4.8,4.8,4.8,4.2,4.6,4.8,4.5,4.4,4.3,3.9,3.7,4,4.1,3.7,3.8,3.8,3.8,3.3,3.3,3.3,3.2,3.4,4.2,4.9,5.1,5.5,5.6,6.4,6.1,7.1,7.8,7.9,7.4,7.5,6.8,5.2,4.7,4.1,3.9,2.6,2.7,1.8,1,0.3) > x <- c(9.3,8.7,8.2,8.3,8.5,8.6,8.5,8.2,8.1,7.9,8.6,8.7,8.7,8.5,8.4,8.5,8.7,8.7,8.6,8.5,8.3,8,8.2,8.1,8.1,8,7.9,7.9,8,8,7.9,8,7.7,7.2,7.5,7.3,7,7,7,7.2,7.3,7.1,6.8,6.4,6.1,6.5,7.7,7.9,7.5,6.9,6.6,6.9,7.7,8,8,7.7,7.3,7.4,8.1,8.3) > 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.431041768 2 -0.135023566 3 0.459921989 4 0.120932878 5 -0.157045344 6 0.003965545 7 0.242954656 8 0.559921989 9 0.098911100 10 -0.123110678 11 0.703965545 12 0.764976434 13 0.964976434 14 0.942954656 15 0.081943767 16 0.242954656 17 0.864976434 18 0.864976434 19 0.803965545 20 0.142954656 21 0.420932878 22 0.437900211 23 0.259921989 24 0.098911100 25 -0.001088900 26 -0.462099789 27 -0.723110678 28 -0.423110678 29 -0.262099789 30 -0.662099789 31 -0.623110678 32 -0.562099789 33 -0.745132456 34 -1.550186901 35 -1.367154234 36 -1.489176012 37 -1.772208679 38 -1.572208679 39 -0.772208679 40 0.049813099 41 0.310823988 42 0.588802210 43 0.505769543 44 1.061725987 45 0.578693320 46 1.822736876 47 3.254867544 48 3.476889322 49 2.732845766 50 2.466780432 51 1.583747765 52 0.166780432 53 0.154867544 54 -0.262099789 55 -0.462099789 56 -1.945132456 57 -2.089176012 58 -2.928165123 59 -3.301088900 60 -3.879067122 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/1l03a1256810612.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/2ig4n1256810612.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/358w61256810612.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/4brhh1256810612.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/5a1fl1256810612.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/6pmqg1256810613.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/7fer41256810613.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/80mwc1256810613.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. 6.100 7.300 8.000 7.845 8.325 9.300 > > #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/998ey1256810613.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/10iarn1256810613.tab") > > system("convert tmp/1l03a1256810612.ps tmp/1l03a1256810612.png") > system("convert tmp/2ig4n1256810612.ps tmp/2ig4n1256810612.png") > system("convert tmp/358w61256810612.ps tmp/358w61256810612.png") > system("convert tmp/4brhh1256810612.ps tmp/4brhh1256810612.png") > system("convert tmp/5a1fl1256810612.ps tmp/5a1fl1256810612.png") > system("convert tmp/6pmqg1256810613.ps tmp/6pmqg1256810613.png") > system("convert tmp/7fer41256810613.ps tmp/7fer41256810613.png") > system("convert tmp/80mwc1256810613.ps tmp/80mwc1256810613.png") > > > proc.time() user system elapsed 1.555 1.178 2.495