R version 2.8.0 (2008-10-20) 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. Natural language support but running in an English locale 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(25.64,27.97,27.62,23.31,29.07,29.58,28.63,29.92,32.68,31.54,32.43,26.54,25.85,27.6,25.71,25.38,28.57,27.64,25.36,25.9,26.29,21.74,19.2,19.32,19.82,20.36,24.31,25.97,25.61,24.67,25.59,26.09,28.37,27.34,24.46,27.46,30.23,32.33,29.87,24.87,25.48,27.28,28.24,29.58,26.95,29.08,28.76,29.59,30.7,30.52,32.67,33.19,37.13,35.54,37.75,41.84,42.94,49.14,44.61,40.22,44.23,45.85,53.38,53.26,51.8,55.3,57.81,63.96,63.77,59.15,56.12,57.42,63.52,61.71,63.01,68.18,72.03,69.75,74.41,74.33,64.24,60.03,59.44,62.5,55.04,58.34,61.92,67.65,67.68,70.3,75.26,71.44,76.36,81.71,92.6,90.6,92.23,94.09,102.79,109.65,124.05,132.69,135.81,116.07,101.42,75.73,55.48,43.8,45.29) > x <- c(3030.29,2803.47,2767.63,2882.6,2863.36,2897.06,3012.61,3142.95,3032.93,3045.78,3110.52,3013.24,2987.1,2995.55,2833.18,2848.96,2794.83,2845.26,2915.03,2892.63,2604.42,2641.65,2659.81,2638.53,2720.25,2745.88,2735.7,2811.7,2799.43,2555.28,2304.98,2214.95,2065.81,1940.49,2042,1995.37,1946.81,1765.9,1635.25,1833.42,1910.43,1959.67,1969.6,2061.41,2093.48,2120.88,2174.56,2196.72,2350.44,2440.25,2408.64,2472.81,2407.6,2454.62,2448.05,2497.84,2645.64,2756.76,2849.27,2921.44,2981.85,3080.58,3106.22,3119.31,3061.26,3097.31,3161.69,3257.16,3277.01,3295.32,3363.99,3494.17,3667.03,3813.06,3917.96,3895.51,3801.06,3570.12,3701.61,3862.27,3970.1,4138.52,4199.75,4290.89,4443.91,4502.64,4356.98,4591.27,4696.96,4621.4,4562.84,4202.52,4296.49,4435.23,4105.18,4116.68,3844.49,3720.98,3674.4,3857.62,3801.06,3504.37,3032.6,3047.03,2962.34,2197.82,2014.45,1862.83,1905.41) > 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 -23.0003724 2 -15.8406810 3 -15.4275378 4 -22.1856007 5 -16.0159223 6 -16.2234983 7 -19.6339112 8 -21.1192484 9 -16.0165861 10 -17.4302019 11 -17.9187145 12 -21.7373258 13 -21.8707253 14 -20.3006516 15 -18.7332978 16 -19.3993022 17 -15.0567090 18 -17.0605179 19 -20.8261346 20 -19.8091701 21 -13.2822978 22 -18.6250383 23 -21.5517203 24 -20.9786040 25 -22.2186727 26 -22.2244138 27 -18.0576505 28 -18.0159229 29 -18.1146571 30 -13.8559569 31 -7.6063045 32 -5.1892905 33 0.2663562 34 1.9048023 35 -3.1366561 36 0.8562392 37 4.6602301 38 10.6123573 39 10.9342953 40 1.7146500 41 0.6848716 42 1.4364014 43 2.1849613 44 1.5700457 45 -1.7428227 46 -0.1962525 47 -1.6592638 48 -1.3011180 49 -3.4642869 50 -5.5566164 51 -2.7335429 52 -3.5799184 53 1.7486019 54 -0.8425977 55 1.5072977 56 4.5371163 57 2.4900023 58 6.3239177 59 -0.1759031 60 -6.1026231 61 -3.3789367 62 -3.8612003 63 3.1228457 64 2.7241195 65 2.5001815 66 5.2325668 67 6.3717197 68 10.4888715 69 9.8762043 70 4.8663284 71 0.3741341 72 -1.0977962 73 1.3214857 74 -3.5979395 75 -4.5315813 76 1.1164478 77 6.9775772 78 9.6149960 79 11.4751718 80 7.9742291 81 -4.4118014 82 -12.2079782 83 -14.1017522 84 -12.9824015 85 -23.7006652 86 -21.6512065 87 -14.9696597 88 -14.2284103 89 -16.4488736 90 -12.2199701 91 -6.0130486 92 -2.1607339 93 0.7583574 94 3.1541585 95 21.0719323 96 18.8270622 97 26.2528197 98 30.7427253 99 40.4345559 100 43.3932418 101 58.9975772 102 73.9550146 103 87.1204406 104 67.0731818 105 54.2264909 106 44.8154596 107 28.4699677 108 20.0184212 109 20.6017627 > library(lattice) > postscript(file="/var/www/html/freestat/rcomp/tmp/19isw1291827550.ps",horizontal=F,onefile=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/freestat/rcomp/tmp/29isw1291827550.ps",horizontal=F,onefile=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/freestat/rcomp/tmp/39isw1291827550.ps",horizontal=F,onefile=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/freestat/rcomp/tmp/49isw1291827550.ps",horizontal=F,onefile=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/freestat/rcomp/tmp/51r9g1291827550.ps",horizontal=F,onefile=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/freestat/rcomp/tmp/61r9g1291827550.ps",horizontal=F,onefile=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/freestat/rcomp/tmp/7uj811291827550.ps",horizontal=F,onefile=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/freestat/rcomp/tmp/8uj811291827550.ps",horizontal=F,onefile=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. 1635 2455 2921 3027 3667 4697 > > #Note: the /var/www/html/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/freestat/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/freestat/rcomp/tmp/9yjpp1291827550.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/freestat/rcomp/tmp/10ct5y1291827550.tab") > > try(system("convert tmp/19isw1291827550.ps tmp/19isw1291827550.png",intern=TRUE)) character(0) > try(system("convert tmp/29isw1291827550.ps tmp/29isw1291827550.png",intern=TRUE)) character(0) > try(system("convert tmp/39isw1291827550.ps tmp/39isw1291827550.png",intern=TRUE)) character(0) > try(system("convert tmp/49isw1291827550.ps tmp/49isw1291827550.png",intern=TRUE)) character(0) > try(system("convert tmp/51r9g1291827550.ps tmp/51r9g1291827550.png",intern=TRUE)) character(0) > try(system("convert tmp/61r9g1291827550.ps tmp/61r9g1291827550.png",intern=TRUE)) character(0) > try(system("convert tmp/7uj811291827550.ps tmp/7uj811291827550.png",intern=TRUE)) character(0) > try(system("convert tmp/8uj811291827550.ps tmp/8uj811291827550.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.656 1.914 3.022