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(18234,18989,18315,16020,21277,25816,29747,32185,39228,37028,34974,31455,30342,31150,32564,33756,32960,34947,30217,32096,30015,29706,27064,30058,28177,27062,28541,29117,30572,32482,31412,31029,25084,29468,30462,24755,24535,19576,18101,16006,14926,12766,13440,14723,15448,11842,11492,13342,16334,22768,22397,12430,16714,23804,25533,25648,23595,21547,22757,24885,27730,33168,24939,20630,28186,25205,28906,33856) > x <- c(29211,29870,32045,32209,32062,31623,32652,30030,29220,29894,28375,29082,29699,27736,28417,28412,29158,29099,29981,30560,31645,31761,32543,33313,34318,36850,35171,35317,36010,36216,37668,38994,38723,38981,39375,39958,39464,40061,40216,39824,40682,41632,41340,41893,41454,42224,42581,44372,43560,44959,45354,45173,46021,44923,44731,46597,44071,45190,43860,44595,44112,45170,44002,43981,44465,42478,41200,41232) > 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 -12011.80764 2 -10860.90729 3 -10228.25592 4 -12424.73141 5 -7256.04302 6 -2980.77633 7 1568.40494 8 2431.21419 9 8987.59920 10 7192.51093 11 4225.95763 12 1131.69442 13 389.36288 14 18.07247 15 1841.18952 16 3030.18572 17 2682.35212 18 4633.90733 19 433.77698 20 2660.61659 21 1231.44038 22 992.12845 23 -1180.07782 24 2276.50681 25 999.26985 26 1405.39227 27 1875.71749 28 2539.42834 29 4410.75450 30 6444.51091 31 6246.81334 32 6660.42011 33 552.61435 34 5091.61024 35 6322.30938 36 965.55202 37 448.77695 38 -4151.56977 39 -5533.45209 40 -7863.94972 41 -8428.49828 42 -10017.77699 43 -9519.19869 44 -7903.97883 45 -7442.71214 46 -10586.12752 47 -10721.65646 48 -7795.69665 49 -5291.51316 50 1982.94903 51 1849.24894 52 -8226.48849 53 -3433.04464 54 2997.32170 55 4610.97592 56 5846.99269 57 2276.47482 58 900.72442 59 1311.71462 60 3881.27267 61 6436.10595 62 12509.70924 63 3579.02243 64 -742.59351 65 7104.17396 66 2929.46533 67 5862.69501 68 10831.91931 > library(lattice) > postscript(file="/var/www/rcomp/tmp/1dlrg1257349785.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/2su221257349785.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/3h33x1257349785.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/4dks21257349785.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/5iu141257349785.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/6h97p1257349785.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/7giew1257349785.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/818sf1257349785.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. 27740 31730 39180 37610 43640 46600 > > #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/9gvvu1257349785.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/10v9pu1257349785.tab") > > system("convert tmp/1dlrg1257349785.ps tmp/1dlrg1257349785.png") > system("convert tmp/2su221257349785.ps tmp/2su221257349785.png") > system("convert tmp/3h33x1257349785.ps tmp/3h33x1257349785.png") > system("convert tmp/4dks21257349785.ps tmp/4dks21257349785.png") > system("convert tmp/5iu141257349785.ps tmp/5iu141257349785.png") > system("convert tmp/6h97p1257349785.ps tmp/6h97p1257349785.png") > system("convert tmp/7giew1257349785.ps tmp/7giew1257349785.png") > system("convert tmp/818sf1257349785.ps tmp/818sf1257349785.png") > > > proc.time() user system elapsed 2.070 1.690 4.092