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,5,7,10,10,5,8,2,11,7,11,9,2,3,12,9,7,4,6,9,10,2,6,2,6,6,9,2,10,16,4,4,11,3,5,3,5,11,8,3,1,7,5,6,9,7,8,4,6,4,5,5,13,4,8,4,5,9,4,8) > x <- c(369,380,474,413,537,439,355,473,435,478,450,365,315,340,326,483,406,409,423,404,551,467,332,442,305,368,411,318,398,586,367,383,533,527,418,576,359,342,456,406,374,568,335,458,456,386,457,396,366,499,354,365,594,456,366,398,468,609,418,352) > 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.2046465 2 -0.9372935 3 -0.1502351 4 3.6368866 5 2.0368359 6 -1.6986079 7 2.3852974 8 -5.1373315 9 4.3530066 10 -0.2018497 11 4.1594521 12 3.2562610 13 -3.0985572 14 -2.4211481 15 6.7595028 16 1.7336322 17 0.7272120 18 -2.3114989 19 -0.4921498 20 2.7530193 21 1.8561850 22 -5.0599097 23 0.6820810 24 -4.7373188 25 1.0304791 26 0.2175501 27 2.6626939 28 -3.1372681 29 3.8304411 30 7.4045578 31 -1.7695462 32 -1.9760044 33 3.0884504 34 -4.8341278 35 -1.4276316 36 -5.4664059 37 -0.6663171 38 5.5530446 39 1.0820303 40 -3.2727880 41 -4.8598717 42 -1.3631768 43 -0.3566299 44 -0.9437770 45 2.0820303 46 0.9852847 47 1.0691267 48 -2.1437516 49 0.2433574 50 -3.4728260 51 -0.6017990 52 -0.7437390 53 4.3013287 54 -2.9179697 55 2.2433574 56 -2.1695589 57 -2.0728133 58 0.1077742 59 -2.4276316 60 2.4240083 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/18bl81260021448.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/27uz51260021448.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/3025e1260021448.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/44oix1260021448.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/544qh1260021448.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/6vu1p1260021448.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/7i6fk1260021448.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/8d9zf1260021448.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. 305.0 366.0 410.0 424.9 467.2 609.0 > > #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/97ekl1260021448.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/10ozq01260021448.tab") > > system("convert tmp/18bl81260021448.ps tmp/18bl81260021448.png") > system("convert tmp/27uz51260021448.ps tmp/27uz51260021448.png") > system("convert tmp/3025e1260021448.ps tmp/3025e1260021448.png") > system("convert tmp/44oix1260021448.ps tmp/44oix1260021448.png") > system("convert tmp/544qh1260021448.ps tmp/544qh1260021448.png") > system("convert tmp/6vu1p1260021448.ps tmp/6vu1p1260021448.png") > system("convert tmp/7i6fk1260021448.ps tmp/7i6fk1260021448.png") > system("convert tmp/8d9zf1260021448.ps tmp/8d9zf1260021448.png") > > > proc.time() user system elapsed 1.595 1.169 1.978