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(8.9,9,9,9,9,9,9,9,9,9,9,9.1,9,9,9.1,9,9,9,9,8.9,8.9,8.9,8.9,8.8,8.8,8.7,8.7,8.5,8.5,8.4,8.2,8.2,8.1,8.1,8,7.9,7.8,7.7,7.6,7.5,7.5,7.5,7.5,7.5,7.4,7.4,7.3,7.3,7.3,7.2,7.2,7.3,7.4,7.4,7.5,7.6,7.7,7.9,8,8.2) > x <- c(1.9,1.6,1.7,2,2.5,2.4,2.3,2.3,2.1,2.4,2.2,2.4,1.9,2.1,2.1,2.1,2,2.1,2.2,2.2,2.6,2.5,2.3,2.2,2.4,2.3,2.2,2.5,2.5,2.5,2.4,2.3,1.7,1.6,1.9,1.9,1.8,1.8,1.9,1.9,1.9,1.9,1.8,1.7,2.1,2.6,3.1,3.1,3.2,3.3,3.6,3.3,3.7,4,4,3.8,3.6,3.2,2.1,1.6) > 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.397380852 2 0.355498782 3 0.402792805 4 0.544674875 5 0.781144993 6 0.733850969 7 0.686556946 8 0.686556946 9 0.591968899 10 0.733850969 11 0.639262922 12 0.833850969 13 0.497380852 14 0.591968899 15 0.691968899 16 0.591968899 17 0.544674875 18 0.591968899 19 0.639262922 20 0.539262922 21 0.728439016 22 0.681144993 23 0.586556946 24 0.439262922 25 0.533850969 26 0.386556946 27 0.339262922 28 0.281144993 29 0.281144993 30 0.181144993 31 -0.066149031 32 -0.113443054 33 -0.497207195 34 -0.544501218 35 -0.502619148 36 -0.602619148 37 -0.749913171 38 -0.849913171 39 -0.902619148 40 -1.002619148 41 -1.002619148 42 -1.002619148 43 -1.049913171 44 -1.097207195 45 -1.008031101 46 -0.771560984 47 -0.635090866 48 -0.635090866 49 -0.587796843 50 -0.640502819 51 -0.498620749 52 -0.540502819 53 -0.251326725 54 -0.109444655 55 -0.009444655 56 -0.004032702 57 0.001379251 58 0.012203157 59 -0.408031101 60 -0.444501218 > library(lattice) > postscript(file="/var/www/rcomp/tmp/1fea81257347895.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/2l2u21257347895.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/3wmtm1257347895.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/46ifg1257347895.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/587q51257347895.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/67pxj1257347895.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/7kltg1257347895.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/8dmeb1257347895.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.600 1.900 2.200 2.388 2.500 4.000 > > #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/9ritu1257347895.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/10pevj1257347895.tab") > > system("convert tmp/1fea81257347895.ps tmp/1fea81257347895.png") > system("convert tmp/2l2u21257347895.ps tmp/2l2u21257347895.png") > system("convert tmp/3wmtm1257347895.ps tmp/3wmtm1257347895.png") > system("convert tmp/46ifg1257347895.ps tmp/46ifg1257347895.png") > system("convert tmp/587q51257347895.ps tmp/587q51257347895.png") > system("convert tmp/67pxj1257347895.ps tmp/67pxj1257347895.png") > system("convert tmp/7kltg1257347895.ps tmp/7kltg1257347895.png") > system("convert tmp/8dmeb1257347895.ps tmp/8dmeb1257347895.png") > > > proc.time() user system elapsed 1.870 1.610 3.352