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(6.3,6.2,6.1,6.3,6.5,6.6,6.5,6.2,6.2,5.9,6.1,6.1,6.1,6.1,6.1,6.4,6.7,6.9,7,7,6.8,6.4,5.9,5.5,5.5,5.6,5.8,5.9,6.1,6.1,6,6,5.9,5.5,5.6,5.4,5.2,5.2,5.2,5.5,5.8,5.8,5.5,5.3,5.1,5.2,5.8,5.8,5.5,5,4.9,5.3,6.1,6.5,6.8,6.6,6.4,6.4) > x <- c(8.9,8.2,7.6,7.7,8.1,8.3,8.3,7.9,7.8,8,8.5,8.6,8.5,8,7.8,8,8.2,8.3,8.2,8.1,8,7.8,7.8,7.7,7.6,7.6,7.6,7.8,8,8,7.9,7.7,7.4,6.9,6.7,6.5,6.4,6.7,6.8,6.9,6.9,6.7,6.4,6.2,5.9,6.1,6.7,6.8,6.6,6.4,6.4,6.7,7.1,7.1,6.9,6.4,6,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.27321459 2 -0.09475247 3 0.04392934 4 0.20414904 5 0.24502783 6 0.26546722 7 0.16546722 8 0.02458843 9 0.06436873 10 -0.31519187 11 -0.31409338 12 -0.35387368 13 -0.31409338 14 -0.11519187 15 -0.03563127 16 0.18480813 17 0.40524753 18 0.56546722 19 0.70524753 20 0.74502783 21 0.58480813 22 0.26436873 23 -0.23563127 24 -0.59585096 25 -0.55607066 26 -0.45607066 27 -0.25607066 28 -0.23563127 29 -0.11519187 30 -0.11519187 31 -0.17541157 32 -0.09585096 33 -0.07651006 34 -0.27760855 35 -0.09804794 36 -0.21848734 37 -0.37870704 38 -0.49804794 39 -0.53782824 40 -0.27760855 41 0.02239145 42 0.10195206 43 -0.07870704 44 -0.19914643 45 -0.27980552 46 -0.25936613 47 0.10195206 48 0.06217176 49 -0.15826764 50 -0.57870704 51 -0.67870704 52 -0.39804794 53 0.24283085 54 0.64283085 55 1.02239145 56 1.02129296 57 0.98041417 58 0.98041417 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/1h9vi1257964495.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/2ayye1257964495.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/33xzf1257964495.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/43npe1257964495.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/5etyy1257964495.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/6ibw01257964495.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/73yc01257964495.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/8s5gd1257964495.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. 5.900 6.700 7.600 7.381 8.000 8.900 > > #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/9y17n1257964495.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/10t07m1257964495.tab") > > system("convert tmp/1h9vi1257964495.ps tmp/1h9vi1257964495.png") > system("convert tmp/2ayye1257964495.ps tmp/2ayye1257964495.png") > system("convert tmp/33xzf1257964495.ps tmp/33xzf1257964495.png") > system("convert tmp/43npe1257964495.ps tmp/43npe1257964495.png") > system("convert tmp/5etyy1257964495.ps tmp/5etyy1257964495.png") > system("convert tmp/6ibw01257964495.ps tmp/6ibw01257964495.png") > system("convert tmp/73yc01257964495.ps tmp/73yc01257964495.png") > system("convert tmp/8s5gd1257964495.ps tmp/8s5gd1257964495.png") > > > proc.time() user system elapsed 1.641 1.183 2.179