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(1844,1790,1707,1617,1530,1453,1386,1329,1255,1201,1179,1167,1160,1161,1203,1290,1404,1550,1670,1746,1817,1836,1872,1956,2010,1933,1917,1900,1829,1805,1730,1650,1618,1582,1576,1512,1540,1519,1473,1402,1299,1267,1200,1145,1103,1076,1095,1080,1082,1060,1027,1003,987,959,913,912,889,882,901,913,921,914,950,894,930,890,898,880,840,845,819,838,833,837,850,927,932,978,978,974,977,950,935,913,942,990,1075,1181,1336,1492) > x <- c(106370,109375,116476,123297,114813,117925,126466,131235,120546,123791,129813,133463,122987,125418,130199,133016,121454,122044,128313,131556,120027,123001,130111,132524,123742,124931,133646,136557,127509,128945,137191,139716,129083,131604,139413,143125,133948,137116,144864,149277,138796,143258,150034,154708,144888,148762,156500,161088,152772,158011,163318,169969,162269,165765,170600,174681,166364,170240,176150,182056,172218,177856,182253,188090,176863,183273,187969,194650,183036,189516,193805,200499,188142,193732,197126,205140,191751,196700,199784,207360,196101,200824,205743,212489,200810,203683,207286,210910,194915,217920) > 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 152.407885 2 124.104831 3 101.828295 4 70.157368 5 -89.392677 6 -139.780732 7 -133.743258 8 -149.961650 9 -315.367523 10 -341.618242 11 -312.121735 12 -292.909139 13 -389.493565 14 -367.705121 15 -284.820896 16 -173.731613 17 -158.602855 18 -7.557532 19 166.051171 20 269.783349 21 242.194302 22 286.626155 23 383.426581 24 488.061100 25 466.962739 26 400.130349 27 458.655767 28 466.548881 29 318.175848 30 306.455653 31 301.970466 32 243.562741 33 120.635746 34 106.193816 35 166.971668 36 134.714451 37 84.238288 38 90.329111 39 110.585329 40 77.322640 41 -115.304543 42 -109.148214 43 -118.203953 44 -133.234728 45 -259.209438 46 -253.081329 47 -167.910626 48 -143.676820 49 -212.790231 50 -189.989466 51 -177.607207 52 -144.731871 53 -226.577621 54 -224.681940 55 -229.335940 56 -195.437692 57 -289.559654 58 -263.414443 59 -193.875691 60 -131.371146 61 -207.499781 62 -166.287010 63 -92.686521 64 -98.772021 65 -158.778546 66 -143.964097 67 -95.806740 68 -56.674863 69 -195.990778 70 -135.577730 71 -124.900792 72 -48.657747 73 -159.327349 74 -107.525044 75 -65.501606 76 80.029283 77 -29.465360 78 58.855499 79 85.228005 80 146.013382 81 52.733213 82 66.121457 83 93.185775 84 128.873493 85 58.001738 86 130.569899 87 246.380579 88 383.370839 89 401.591257 90 754.316126 > library(lattice) > postscript(file="/var/www/rcomp/tmp/1woc21257360763.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/2p8t41257360763.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/395hm1257360763.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/4v5l01257360763.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/5e16q1257360763.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/62weh1257360763.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/79m3q1257360763.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/89sib1257360763.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. 106400 130100 151400 157800 188100 217900 > > #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/9wdf01257360763.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/10bhdf1257360763.tab") > > system("convert tmp/1woc21257360763.ps tmp/1woc21257360763.png") > system("convert tmp/2p8t41257360763.ps tmp/2p8t41257360763.png") > system("convert tmp/395hm1257360763.ps tmp/395hm1257360763.png") > system("convert tmp/4v5l01257360763.ps tmp/4v5l01257360763.png") > system("convert tmp/5e16q1257360763.ps tmp/5e16q1257360763.png") > system("convert tmp/62weh1257360763.ps tmp/62weh1257360763.png") > system("convert tmp/79m3q1257360763.ps tmp/79m3q1257360763.png") > system("convert tmp/89sib1257360763.ps tmp/89sib1257360763.png") > > > proc.time() user system elapsed 2.030 1.720 3.468