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(2529,2196,3202,2718,2728,2354,2697,2651,2067,2641,2539,2294,2712,2314,3092,2677,2813,2668,2939,2617,2231,2481,2421,2408,2560,2100,3315,2801,2403,3024,2507,2980,2211,2471,2594,2452,2232,2373,3127,2802,2641,2787,2619,2806,2193,2323,2529,2412,2262,2154,3230,2295,2715,2733,2317,2730,1913,2390,2484,1960) > x <- c(1178,2141,2238,2685,4341,5376,4478,6404,4617,3024,1897,2075,1351,2211,2453,3042,4765,4992,4601,6266,4812,3159,1916,2237,1595,2453,2226,3597,4706,4974,5756,5493,5004,3225,2006,2291,1588,2105,2191,3591,4668,4885,5822,5599,5340,3082,2010,2301,1514,1979,2480,3499,4676,5585,5610,5796,6199,3030,1930,2552) > 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 -7.384480 2 -348.812296 3 656.338796 4 168.426819 5 163.934126 6 -219.123807 7 131.735153 8 68.879521 9 -499.481323 10 88.460018 11 -3.676899 12 -250.234689 13 174.101489 14 -231.424910 15 544.457197 16 124.302489 17 245.223437 18 98.236817 19 372.658703 20 36.087245 21 -337.187890 22 -72.721452 23 -121.843180 24 -137.652452 25 19.966092 26 -447.542803 27 769.443816 28 243.445336 29 -164.260217 30 454.394347 31 -69.449425 32 405.852253 33 -358.868202 34 -83.299059 35 50.369174 36 -94.125040 37 -307.972647 38 -171.497237 39 581.750123 40 244.497846 41 74.072344 42 218.173241 43 41.972968 44 230.924580 45 -379.808749 46 -230.047576 47 -14.665833 48 -134.212556 49 -277.325026 50 -389.394533 51 682.220903 52 -261.697005 53 148.002331 54 158.047103 55 -258.171688 56 153.200510 57 -667.326396 58 -162.592492 59 -58.965703 60 -588.409214 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/1ibek1257346276.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/2k8b31257346276.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/383my1257346276.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/46nef1257346276.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/5jp2q1257346276.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/6d7g41257346276.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/7827w1257346276.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/8082u1257346276.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. 1178 2206 3120 3560 4907 6404 > > #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/9wkqa1257346276.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/10xt261257346276.tab") > > system("convert tmp/1ibek1257346276.ps tmp/1ibek1257346276.png") > system("convert tmp/2k8b31257346276.ps tmp/2k8b31257346276.png") > system("convert tmp/383my1257346276.ps tmp/383my1257346276.png") > system("convert tmp/46nef1257346276.ps tmp/46nef1257346276.png") > system("convert tmp/5jp2q1257346276.ps tmp/5jp2q1257346276.png") > system("convert tmp/6d7g41257346276.ps tmp/6d7g41257346276.png") > system("convert tmp/7827w1257346276.ps tmp/7827w1257346276.png") > system("convert tmp/8082u1257346276.ps tmp/8082u1257346276.png") > > > proc.time() user system elapsed 1.712 1.276 5.355