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(22782,16169,13807,29743,25591,29096,26482,22404,27044,17970,18730,19684,19785,18479,10698,31956,29506,34506,27165,26736,23691,18157,17328,18205,20995,17382,9367,31124,26551,30651,25859,25100,25778,20418,18688,20424,24776,19814,12738,31566,30111,30019,31934,25826,26835,20205,17789,20520,22518,15572,11509,25447,24090,27786,26195,20516,22759,19028,16971,20036) > x <- c(-0.6,-0.2,-0.7,-0.1,0.7,1.5,1.6,2.8,3.3,3.5,3.9,4.8,5.1,4.9,5.2,5.1,4.6,3.7,3.9,3.1,2.8,2.6,2.2,1.8,1.3,1.2,1.4,1.3,1.3,1.9,1.9,2.1,2,1.9,1.9,1.9,1.8,1.7,1.6,1.7,1.9,1.7,1.3,2,2,2.3,2,1.7,2.3,2.4,2.4,2.3,2.1,2.1,2.5,2,1.8,1.7,1.9,2.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 335.28071 2 -6315.15645 3 -8630.36000 4 7249.48425 5 3022.60993 6 6452.73560 7 3829.37631 8 -360.93519 9 4232.26836 10 -4860.45022 11 -4137.88739 12 -3268.12101 13 -3195.19888 14 -4482.48030 15 -12291.55817 16 8975.80112 17 6572.59758 18 11656.83119 19 4297.11261 20 3942.98694 21 926.06481 22 -4589.21660 23 -5380.77944 24 -4466.34228 25 -1629.54582 26 -5233.18653 27 -13266.90511 28 8499.45418 29 3926.45418 30 7970.29843 31 3178.29843 32 2400.57985 33 3087.93914 34 -2262.70157 35 -3992.70157 36 -2256.70157 37 2104.65772 38 -2847.98298 39 -9914.62369 40 8904.01702 41 7430.29843 42 7357.01702 43 9309.45418 44 3135.93914 45 4144.93914 46 -2513.13873 47 -4901.06086 48 -2141.98298 49 -200.13873 50 -7155.49802 51 -11218.49802 52 2728.86127 53 1390.57985 54 5086.57985 55 3458.14269 56 -2174.06086 57 87.65772 58 -3633.98298 59 -5709.70157 60 -2663.42015 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/1qxlj1257271132.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/2yn111257271132.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/3v0yt1257271132.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/4rbuu1257271132.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/5v8kh1257271132.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/6zyub1257271132.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/7cj4a1257271132.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/8zcnc1257271132.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. -0.700 1.700 2.000 2.215 2.525 5.200 > > #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/9ybdf1257271132.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/10w76o1257271132.tab") > > system("convert tmp/1qxlj1257271132.ps tmp/1qxlj1257271132.png") > system("convert tmp/2yn111257271132.ps tmp/2yn111257271132.png") > system("convert tmp/3v0yt1257271132.ps tmp/3v0yt1257271132.png") > system("convert tmp/4rbuu1257271132.ps tmp/4rbuu1257271132.png") > system("convert tmp/5v8kh1257271132.ps tmp/5v8kh1257271132.png") > system("convert tmp/6zyub1257271132.ps tmp/6zyub1257271132.png") > system("convert tmp/7cj4a1257271132.ps tmp/7cj4a1257271132.png") > system("convert tmp/8zcnc1257271132.ps tmp/8zcnc1257271132.png") > > > proc.time() user system elapsed 1.573 1.162 2.031