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(3977.7,3983.4,4152.9,4286.1,4348.1,3949.3,4166.7,4217.9,4528.2,4232.2,4470.9,5121.2,4170.8,4398.6,4491.4,4251.8,4901.9,4745.2,4666.9,4210.4,5273.6,4095.3,4610.1,4718.1,4185.5,4314.7,4422.6,5059.2,5043.6,4436.6,4922.6,4454.8,5058.7,4768.9,5171.8,4989.3,5202.1,4838.4,4876.5,5875.5,5717.9,4778.8,6195.9,4625.4,5549.8,6397.6,5856.7,6343.8,6615.5,5904.6,6861,6553.5,5481,5435.3,5278,4671.8,4891.5,4241.6,4152.1,4484.4) > x <- c(2,1.8,2.7,2.3,1.9,2,2.3,2.8,2.4,2.3,2.7,2.7,2.9,3,2.2,2.3,2.8,2.8,2.8,2.2,2.6,2.8,2.5,2.4,2.3,1.9,1.7,2,2.1,1.7,1.8,1.8,1.8,1.3,1.3,1.3,1.2,1.4,2.2,2.9,3.1,3.5,3.6,4.4,4.1,5.1,5.8,5.9,5.4,5.5,4.8,3.2,2.7,2.1,1.9,0.6,0.7,-0.2,-1,-1.7) > 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 -775.10746 2 -707.67569 3 -815.96865 4 -559.30511 5 -373.84158 6 -803.50746 7 -678.70511 8 -781.83454 9 -348.07100 10 -613.20511 11 -497.96865 12 152.33135 13 -859.80042 14 -662.86631 15 -323.13923 16 -593.60511 17 -97.83454 18 -254.53454 19 -332.83454 20 -604.13923 21 335.59723 22 -904.43454 23 -297.03688 24 -158.17100 25 -659.90511 26 -407.24158 27 -237.60981 28 306.39254 29 259.92666 30 -223.60981 31 231.52431 32 -236.27569 33 367.62431 34 232.15373 35 635.05373 36 452.55373 37 696.21962 38 270.78785 39 61.96077 40 844.89958 41 625.56781 42 -436.99573 43 949.23838 44 -868.18869 45 148.80896 46 687.95011 47 -69.01108 48 387.22304 49 813.25246 50 71.48657 51 1243.94777 52 1430.30192 53 512.13135 54 651.62666 55 556.05842 56 351.11493 57 539.94904 58 167.84200 59 325.26908 60 873.63028 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/1z67f1257358383.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/2wifa1257358383.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/3kkil1257358383.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/46l1q1257358383.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/5uqlk1257358383.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/6weqv1257358383.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/7rmn61257358383.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/8ut011257358383.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.700 1.800 2.300 2.457 2.825 5.900 > > #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/9laoo1257358383.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/10vmng1257358383.tab") > > system("convert tmp/1z67f1257358383.ps tmp/1z67f1257358383.png") > system("convert tmp/2wifa1257358383.ps tmp/2wifa1257358383.png") > system("convert tmp/3kkil1257358383.ps tmp/3kkil1257358383.png") > system("convert tmp/46l1q1257358383.ps tmp/46l1q1257358383.png") > system("convert tmp/5uqlk1257358383.ps tmp/5uqlk1257358383.png") > system("convert tmp/6weqv1257358383.ps tmp/6weqv1257358383.png") > system("convert tmp/7rmn61257358383.ps tmp/7rmn61257358383.png") > system("convert tmp/8ut011257358383.ps tmp/8ut011257358383.png") > > > proc.time() user system elapsed 1.620 1.183 2.483