R version 2.8.1 (2008-12-22) 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(1.3,1.2,1.1,1.4,1.2,1.5,1.1,1.3,1.5,1.1,1.4,1.3,1.5,1.6,1.7,1.1,1.6,1.3,1.7,1.6,1.7,1.9,1.8,1.9,1.6,1.5,1.6,1.6,1.7,2,2,1.9,1.7,1.8,1.9,1.7,2,2.1,2.4,2.5,2.5,2.6,2.2,2.5,2.8,2.8,2.9,3,3.1,2.9,2.7,2.2,2.5,2.3,2.6,2.3,2.2,1.8,1.8) > x <- c(2,2.1,2.1,2.5,2.2,2.3,2.3,2.2,2.2,1.6,1.8,1.7,1.9,1.8,1.9,1.5,1,0.8,1.1,1.5,1.7,2.3,2.4,3,3,3.2,3.2,3.2,3.5,4,4.3,4.1,4,4.1,4.2,4.5,5.6,6.5,7.6,8.5,8.7,8.3,8.3,8.5,8.7,8.7,8.5,7.9,7,5.8,4.5,3.7,3.1,2.7,2.3,1.8,1.5,1.2,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.317612831 2 -0.434080826 3 -0.534080826 4 -0.299952806 5 -0.450548821 6 -0.167016816 7 -0.567016816 8 -0.350548821 9 -0.150548821 10 -0.451740850 11 -0.184676840 12 -0.268208845 13 -0.101144835 14 0.015323160 15 0.098855165 16 -0.435272855 17 0.147067121 18 -0.119996889 19 0.230599126 20 0.064727145 21 0.131791155 22 0.232983184 23 0.116515189 24 0.117707218 25 -0.182292782 26 -0.315228773 27 -0.215228773 28 -0.215228773 29 -0.164632758 30 0.053027266 31 0.003623281 32 -0.063440729 33 -0.246972734 34 -0.163440729 35 -0.079908724 36 -0.329312710 37 -0.210460657 38 -0.258672613 39 -0.139820560 40 -0.188032517 41 -0.220968507 42 -0.055096526 43 -0.455096526 44 -0.188032517 45 0.079031493 46 0.079031493 47 0.211967483 48 0.410775454 49 0.658987411 50 0.656603353 51 0.670687290 52 0.302431252 53 0.701239223 54 0.567111203 55 0.932983184 56 0.715323160 57 0.664727145 58 0.314131131 59 0.347067121 > library(lattice) > postscript(file="/var/www/rcomp/tmp/1b4131256660397.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/rcomp/tmp/28jrr1256660397.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/rcomp/tmp/3mcmd1256660397.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/rcomp/tmp/4g4891256660397.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/rcomp/tmp/5ocjf1256660397.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/rcomp/tmp/6fhws1256660397.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/rcomp/tmp/7ccnr1256660397.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/rcomp/tmp/8gk8k1256660397.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. 0.800 1.900 3.000 3.756 4.500 8.700 > > #Note: the /var/www/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/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/rcomp/tmp/9eiy51256660397.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/rcomp/tmp/106cc81256660397.tab") > > system("convert tmp/1b4131256660397.ps tmp/1b4131256660397.png") > system("convert tmp/28jrr1256660397.ps tmp/28jrr1256660397.png") > system("convert tmp/3mcmd1256660397.ps tmp/3mcmd1256660397.png") > system("convert tmp/4g4891256660397.ps tmp/4g4891256660397.png") > system("convert tmp/5ocjf1256660397.ps tmp/5ocjf1256660397.png") > system("convert tmp/6fhws1256660397.ps tmp/6fhws1256660397.png") > system("convert tmp/7ccnr1256660397.ps tmp/7ccnr1256660397.png") > system("convert tmp/8gk8k1256660397.ps tmp/8gk8k1256660397.png") > > > proc.time() user system elapsed 1.790 1.570 3.529