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(6.96781636,7.00781636,7.06781636,7.08781636,7.10781636,7.091298712,7.111298712,7.141298712,7.211298712,7.251298712,7.28781636,7.271298712,7.360851656,7.360851656,7.370851656,7.390851656,7.410851656,7.420851656,7.420851656,7.390851656,7.420851656,7.440851656,7.430851656,7.444334008,7.434334008,7.434334008,7.42781636,7.44781636,7.484334008,7.48781636,7.471298712,7.468263416,7.511745768,7.50522812,7.51522812,7.52522812,7.561745768,7.53522812,7.57522812,7.652192824,7.83263988,7.823086936,7.770498696,7.757910456,7.797910456,7.741839864,7.761839864,7.818357512,7.755322216,7.72228692,7.705769272,7.76228692,7.84228692,7.981839864,8.06487516,8.028357512,8.09487516,8.09487516,8.10487516,8.10487516) > x <- c(2.022031275,2.032031275,2.042031275,2.042031275,2.052031275,2.04943468,2.04943468,2.05943468,2.06943468,2.06943468,2.082031275,2.07943468,2.087224465,2.087224465,2.087224465,2.097224465,2.097224465,2.097224465,2.097224465,2.097224465,2.107224465,2.107224465,2.117224465,2.12462787,2.12462787,2.12462787,2.122031275,2.132031275,2.14462787,2.142031275,2.14943468,2.15424149,2.161644895,2.1690483,2.1690483,2.1790483,2.181644895,2.1790483,2.1890483,2.21385511,2.246065325,2.24827554,2.245292565,2.25230959,2.25230959,2.24192321,2.25192321,2.254519805,2.249326615,2.244133425,2.25153683,2.254133425,2.254133425,2.27192321,2.2671164,2.264519805,2.2671164,2.2671164,2.2671164,2.2671164) > par2 = '36' > par1 = '0' > 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 -0.086554002 2 -0.081753447 3 -0.056952892 4 -0.036952892 5 -0.052152337 6 -0.059530115 7 -0.039530115 8 -0.044729560 9 -0.009929005 10 0.030070995 11 0.022249328 12 0.014871550 13 0.077004884 14 0.077004884 15 0.087004884 16 0.071805439 17 0.091805439 18 0.101805439 19 0.101805439 20 0.071805439 21 0.066605994 22 0.086605994 23 0.041406549 24 0.028829326 25 0.018829326 26 0.018829326 27 0.021451549 28 0.006252104 29 -0.001569563 30 0.011052659 31 -0.031524564 32 -0.051479564 33 -0.034056787 34 -0.066634009 35 -0.056634009 36 -0.081833454 37 -0.054455677 38 -0.071833454 39 -0.067032899 40 -0.077386789 41 -0.010317902 42 -0.027650680 43 -0.069739014 44 -0.107026792 45 -0.067026792 46 -0.086537903 47 -0.101737348 48 -0.054359571 49 -0.099115126 50 -0.113870681 51 -0.156447904 52 -0.109070126 53 -0.029070126 54 0.047863762 55 0.147818762 56 0.120440985 57 0.177818762 58 0.177818762 59 0.187818762 60 0.187818762 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/1ji9w1257797390.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/27p1x1257797390.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/3d8h31257797390.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/4hn5h1257797390.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/508wu1257797390.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/6y81h1257797390.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/70pd11257797390.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/87zqf1257797390.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. 2.022 2.095 2.147 2.158 2.249 2.272 > > #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/9oug61257797390.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/10sfnd1257797390.tab") > > system("convert tmp/1ji9w1257797390.ps tmp/1ji9w1257797390.png") > system("convert tmp/27p1x1257797390.ps tmp/27p1x1257797390.png") > system("convert tmp/3d8h31257797390.ps tmp/3d8h31257797390.png") > system("convert tmp/4hn5h1257797390.ps tmp/4hn5h1257797390.png") > system("convert tmp/508wu1257797390.ps tmp/508wu1257797390.png") > system("convert tmp/6y81h1257797390.ps tmp/6y81h1257797390.png") > system("convert tmp/70pd11257797390.ps tmp/70pd11257797390.png") > system("convert tmp/87zqf1257797390.ps tmp/87zqf1257797390.png") > > > proc.time() user system elapsed 1.654 1.222 2.650