R version 2.8.0 (2008-10-20) 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(23.2,23.2,20.9,20.9,20.9,19.8,19.8,19.8,20.6,20.6,20.6,21.1,21.1,21.1,22.4,22.4,22.4,20.5,20.5,20.5,18.4,18.4,18.4,17.6,17.6,17.6,18.5,18.5,18.5,17.3,17.3,17.3,16.2,16.2,16.2,18.5,18.5,18.5,16.3,16.3,16.3,16.8,16.8,16.8,14.8,14.8,14.8,21.4,21.4,21.4,16.1,16.1,16.1,19.6,19.6,19.6,18.9,18.9,18.9,18.9,18.9) > x <- c(8,8.1,7.7,7.5,7.6,7.8,7.8,7.8,7.5,7.5,7.1,7.5,7.5,7.6,7.7,7.7,7.9,8.1,8.2,8.2,8.2,7.9,7.3,6.9,6.6,6.7,6.9,7,7.1,7.2,7.1,6.9,7,6.8,6.4,6.7,6.6,6.4,6.3,6.2,6.5,6.8,6.8,6.4,6.1,5.8,6.1,7.2,7.3,6.9,6.1,5.8,6.2,7.1,7.7,7.9,7.7,7.4,7.5,8,8.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 2.28372188 2 2.03252639 3 0.73730837 4 1.23969935 5 0.98850386 6 -0.61388713 7 -0.61388713 8 -0.61388713 9 0.93969935 10 0.93969935 11 1.94448133 12 1.43969935 13 1.43969935 14 1.18850386 15 2.23730837 16 2.23730837 17 1.73491738 18 -0.66747361 19 -0.91866910 20 -0.91866910 21 -3.01866910 22 -2.26508262 23 -0.75790966 24 -0.55312768 25 0.20045880 26 -0.05073669 27 0.34687232 28 0.09567682 29 -0.15551867 30 -1.60671416 31 -1.35551867 32 -0.85312768 33 -2.20432318 34 -1.70193219 35 -0.69715021 36 0.84926331 37 1.10045880 38 1.60284979 39 -0.34595472 40 -0.09475922 41 -0.84834570 42 -1.10193219 43 -1.10193219 44 -0.09715021 45 -1.34356373 46 -0.58997725 47 -1.34356373 48 2.49328584 49 2.24209034 50 3.24687232 51 -0.04356373 52 0.71002275 53 -0.29475922 54 0.94448133 55 -0.56269163 56 -1.06508262 57 -1.26269163 58 -0.50910515 59 -0.76030065 60 -2.01627812 61 -2.26747361 > library(lattice) > postscript(file="/var/www/html/freestat/rcomp/tmp/1i25g1257355204.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/freestat/rcomp/tmp/24yab1257355204.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/freestat/rcomp/tmp/3ir841257355204.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/freestat/rcomp/tmp/48p4q1257355204.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/freestat/rcomp/tmp/56j2w1257355204.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/freestat/rcomp/tmp/6786b1257355204.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/freestat/rcomp/tmp/78gxi1257355204.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/freestat/rcomp/tmp/8hicf1257355204.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.800 6.700 7.200 7.187 7.700 8.200 > > #Note: the /var/www/html/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/freestat/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/freestat/rcomp/tmp/9a0ah1257355204.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/freestat/rcomp/tmp/1073ne1257355204.tab") > > system("convert tmp/1i25g1257355204.ps tmp/1i25g1257355204.png") > system("convert tmp/24yab1257355204.ps tmp/24yab1257355204.png") > system("convert tmp/3ir841257355204.ps tmp/3ir841257355204.png") > system("convert tmp/48p4q1257355204.ps tmp/48p4q1257355204.png") > system("convert tmp/56j2w1257355204.ps tmp/56j2w1257355204.png") > system("convert tmp/6786b1257355204.ps tmp/6786b1257355204.png") > system("convert tmp/78gxi1257355204.ps tmp/78gxi1257355204.png") > system("convert tmp/8hicf1257355204.ps tmp/8hicf1257355204.png") > > > proc.time() user system elapsed 2.568 1.931 3.672