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(29571,30167,30524,30996,31033,31198,30937,31649,33115,34106,33926,33382,32851,32948,36112,36113,35210,35193,34383,35349,37058,38076,36630,36045,35638,35114,35465,35254,35299,35916,36683,37288,38536,38977,36407,34955,34951,32680,34791,34178,35213,34871,35299,35443,37108,36419,34471,33868,34385,33643,34627,32919,35500,36110,37086,37711,40427,39884,38512,38767) > x <- c(5594,5585,5710,5511,5403,5826,5884,5965,5960,6064,6046,5954,5952,5960,5983,5996,6021,6094,6202,6276,6306,6342,6345,6328,6191,6261,6253,6198,6247,6293,6381,6448,6470,6516,6532,6526,6533,6498,6507,6464,6453,6468,6497,6808,6793,6907,6792,6757,6734,6654,6589,6469,6521,6448,6410,6528,6445,6458,6215,6167) > 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 -2607.91339 2 -1974.63445 3 -2135.39747 4 -839.11875 5 -354.77150 6 -1941.88155 7 -2443.12360 8 -2066.63403 9 -579.92351 10 -19.70234 11 -125.14447 12 -288.07089 13 -810.78668 14 -746.92351 15 2321.80809 16 2268.96074 17 1262.40814 18 943.03453 19 -314.31272 20 345.17158 21 1929.90845 22 2798.79270 23 1340.36639 24 825.78216 25 986.25043 26 172.30314 27 556.43997 28 573.25570 29 415.29260 30 841.75581 31 1244.25064 32 1571.72966 33 2728.60337 34 2979.06658 35 342.79291 36 -1084.35446 37 -1117.34919 38 -3243.37555 39 -1169.65448 40 -1604.54401 41 -523.98086 42 -928.11242 43 -620.23344 44 -1764.42783 45 -37.29627 46 -1198.49615 47 -2670.15417 48 -3128.18052 49 -2515.91213 50 -2926.54379 51 -1673.30702 52 -2884.25453 53 -518.64394 54 393.72966 55 1527.12962 56 1663.36133 57 4723.15597 58 4126.30862 59 3760.83993 60 4214.66093 > library(lattice) > postscript(file="/var/www/rcomp/tmp/18j8o1256853239.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/2kz2q1256853239.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/3ymf61256853239.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/4cgzz1256853239.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/5sy4c1256853239.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/6898n1256853239.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/7wca51256853239.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/8mxn21256853239.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. 5403 6040 6335 6279 6500 6907 > > #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/9nfp81256853239.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/10gmds1256853239.tab") > > system("convert tmp/18j8o1256853239.ps tmp/18j8o1256853239.png") > system("convert tmp/2kz2q1256853239.ps tmp/2kz2q1256853239.png") > system("convert tmp/3ymf61256853239.ps tmp/3ymf61256853239.png") > system("convert tmp/4cgzz1256853239.ps tmp/4cgzz1256853239.png") > system("convert tmp/5sy4c1256853239.ps tmp/5sy4c1256853239.png") > system("convert tmp/6898n1256853239.ps tmp/6898n1256853239.png") > system("convert tmp/7wca51256853239.ps tmp/7wca51256853239.png") > system("convert tmp/8mxn21256853239.ps tmp/8mxn21256853239.png") > > > proc.time() user system elapsed 1.610 1.580 3.205