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(10898,11078,11157,11203,11425,11368,11118,11041,10837,11018,11035,11220,11486,11553,11626,11861,11951,11935,11717,11841,11701,11842,11818,12088,11876,11839,11582,11848,11741,11455,11154,10922,10556,10923,11001,10702,10805,10831,10925,11220,11188,10752,10771,10274,10261,10600,10596,10556,10716,10958,11273,11806,11922,12127,11985,11805,11901,12217,12344,12314) > x <- c(6675,6539,6699,6962,6981,7024,6940,6774,6671,6965,6969,6822,6878,6691,6837,7018,7167,7076,7171,7093,6971,7142,7047,6999,6650,6475,6437,6639,6422,6272,6232,6003,5673,6050,5977,5796,5752,5609,5839,6069,6006,5809,5797,5502,5568,5864,5764,5615,5615,5681,5915,6334,6494,6620,6578,6495,6538,6737,6651,6530) > 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 -617.639791 2 -339.520558 3 -375.954950 4 -519.700232 5 -311.408066 6 -399.431059 7 -588.828003 8 -546.064821 9 -675.753931 10 -706.864627 11 -692.750487 12 -401.695139 13 -176.097176 14 25.816770 15 -6.517113 16 97.897731 17 80.399453 18 130.052764 19 -156.486407 20 23.787859 21 -28.193417 22 -10.563923 23 33.975247 24 338.605565 25 378.396833 26 467.653199 27 238.068867 28 358.332947 29 407.890842 30 230.110584 31 -42.030818 32 -108.815344 33 -236.731910 34 -141.724197 35 -11.057255 36 -179.472099 37 -44.727641 38 84.441847 39 12.504908 40 141.567969 41 155.020261 42 -138.851143 43 -111.193564 44 -395.361403 45 -455.978090 46 -330.531716 47 -262.385221 48 -194.886943 49 -34.886943 50 159.496370 51 305.673572 52 536.379757 53 536.945365 54 651.040781 55 539.342309 56 419.223900 57 484.200907 58 656.629382 59 845.675368 60 902.972627 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/1ree61257272356.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/28a6h1257272356.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/3hyv81257272356.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/4jywh1257272356.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/5ezji1257272356.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/67c3s1257272356.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/7q8161257272356.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/8uknq1257272356.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. 5502 5962 6538 6435 6894 7171 > > #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/9f3vr1257272356.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/102k8q1257272356.tab") > > system("convert tmp/1ree61257272356.ps tmp/1ree61257272356.png") > system("convert tmp/28a6h1257272356.ps tmp/28a6h1257272356.png") > system("convert tmp/3hyv81257272356.ps tmp/3hyv81257272356.png") > system("convert tmp/4jywh1257272356.ps tmp/4jywh1257272356.png") > system("convert tmp/5ezji1257272356.ps tmp/5ezji1257272356.png") > system("convert tmp/67c3s1257272356.ps tmp/67c3s1257272356.png") > system("convert tmp/7q8161257272356.ps tmp/7q8161257272356.png") > system("convert tmp/8uknq1257272356.ps tmp/8uknq1257272356.png") > > > proc.time() user system elapsed 1.560 1.147 2.134