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(210944,218238,212696,214774,212248,212055,210783,206482,206037,207351,215248,214080,213840,207623,202097,204023,204776,202436,198365,196066,195898,196621,205523,206211,200855,190133,183418,182122,181712,177421,172267,169850,166037,163600,177263,179606,169189,164017,159004,160079,160792,157135,153070,151414,146612,150703,163627,165264,155839,151095,148609,152353,154304,154504,154436,154589,151473,156009,169123,171568,162335) > x <- c(1.3,1.3,1.2,1.1,1.4,1.2,1.5,1.1,1.3,1.5,1.1,1.4,1.3,1.5,1.6,1.7,1.1,1.6,1.3,1.7,1.6,1.7,1.9,1.8,1.9,1.6,1.5,1.6,1.6,1.7,2,2,1.9,1.7,1.8,1.9,1.7,2,2.1,2.4,2.5,2.5,2.6,2.2,2.5,2.8,2.8,2.9,3,3.1,2.9,2.7,2.2,2.5,2.3,2.6,2.3,2.2,1.8,1.8,2) > 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 7201.8324 2 14495.8324 3 5193.7496 4 3511.6668 5 12265.9152 6 4552.7496 7 14560.9980 8 -4780.3332 9 2294.8324 10 11128.9980 11 3985.6668 12 14097.9152 13 10097.8324 14 11400.9980 15 9635.0808 16 15321.1636 17 -6486.3332 18 9974.0808 19 -5377.1676 20 7364.1636 21 3436.0808 22 7919.1636 23 24341.3292 24 21269.2464 25 19673.3292 26 -2328.9192 27 -12804.0020 28 -10339.9192 29 -10749.9192 30 -11280.8364 31 -5154.5880 32 -7571.5880 33 -15144.6708 34 -25101.8364 35 -7678.7536 36 -1575.6708 37 -19512.8364 38 -13404.5880 39 -14657.5052 40 -2302.2567 41 2170.8261 42 -1486.1739 43 -1791.0911 44 -18487.4223 45 -12009.1739 46 3362.0745 47 16286.0745 48 21683.1573 49 16018.2401 50 15034.3229 51 5028.1573 52 1251.9917 53 -15597.4223 54 -4117.1739 55 -11705.3395 56 -272.0911 57 -14668.3395 58 -13892.4223 59 -15818.7536 60 -13373.7536 61 -15086.5880 > library(lattice) > postscript(file="/var/www/rcomp/tmp/1j3i71257268314.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/2kvp51257268314.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/3ne891257268314.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/4xeqd1257268314.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/5uvg41257268314.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/6uvrq1257268314.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/73uqw1257268314.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/8vuky1257268314.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.100 1.500 1.800 1.898 2.300 3.100 > > #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/999k81257268314.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/10nw2h1257268314.tab") > > system("convert tmp/1j3i71257268314.ps tmp/1j3i71257268314.png") > system("convert tmp/2kvp51257268314.ps tmp/2kvp51257268314.png") > system("convert tmp/3ne891257268314.ps tmp/3ne891257268314.png") > system("convert tmp/4xeqd1257268314.ps tmp/4xeqd1257268314.png") > system("convert tmp/5uvg41257268314.ps tmp/5uvg41257268314.png") > system("convert tmp/6uvrq1257268314.ps tmp/6uvrq1257268314.png") > system("convert tmp/73uqw1257268314.ps tmp/73uqw1257268314.png") > system("convert tmp/8vuky1257268314.ps tmp/8vuky1257268314.png") > > > proc.time() user system elapsed 2.10 1.74 2.95