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(3922,3759,4138,4634,3995,4308,4143,4429,5219,4929,5755,5592,4163,4962,5208,4755,4491,5732,5731,5040,6102,4904,5369,5578,4619,4731,5011,5299,4146,4625,4736,4219,5116,4205,4121,5103,4300,4578,3809,5526,4247,3830,4394,4826,4409,4569,4106,4794,3914,3793,4405,4022,4100,4788,3163,3585,3903,4178,3863,4187) > 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 -97.041303 2 -338.041354 3 138.458710 4 517.458633 5 -277.541471 6 -120.541574 7 -305.041587 8 -253.041742 9 439.458193 10 110.458167 11 858.458115 12 519.957999 13 -967.542040 14 -129.542014 15 57.957947 16 -375.542040 17 -542.041975 18 874.458141 19 834.458115 20 299.458219 21 1419.958258 22 260.958284 23 803.958335 24 1090.958387 25 229.458452 26 360.958465 27 601.958439 28 909.458452 29 -243.541548 30 118.458374 31 229.458374 32 -326.541652 33 589.958361 34 -301.541626 35 -385.541626 36 596.458374 37 -187.041613 38 110.458400 39 -639.041587 40 1058.458400 41 -259.541626 42 -637.541600 43 4.458452 44 299.958361 45 -117.041639 46 -15.541678 47 -420.041639 48 326.458400 49 -670.541678 50 -811.041691 51 -199.041691 52 -562.541678 53 -445.541652 54 242.458348 55 -1460.541704 56 -941.041639 57 -584.041613 58 -289.541600 59 -643.541626 60 -358.541652 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/1mcn01257270946.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/2y4kb1257270946.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/364rb1257270946.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/4w8f01257270946.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/5ehbs1257270946.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/6beaq1257270946.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/7ex611257270946.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/8hqzr1257270946.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/9tyzy1257270946.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/101q1o1257270946.tab") > > system("convert tmp/1mcn01257270946.ps tmp/1mcn01257270946.png") > system("convert tmp/2y4kb1257270946.ps tmp/2y4kb1257270946.png") > system("convert tmp/364rb1257270946.ps tmp/364rb1257270946.png") > system("convert tmp/4w8f01257270946.ps tmp/4w8f01257270946.png") > system("convert tmp/5ehbs1257270946.ps tmp/5ehbs1257270946.png") > system("convert tmp/6beaq1257270946.ps tmp/6beaq1257270946.png") > system("convert tmp/7ex611257270946.ps tmp/7ex611257270946.png") > system("convert tmp/8hqzr1257270946.ps tmp/8hqzr1257270946.png") > > > proc.time() user system elapsed 1.602 1.165 3.750