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(1901,1395,1639,1643,1751,1797,1373,1558,1555,2061,2010,2119,1985,1963,2017,1975,1589,1679,1392,1511,1449,1767,1899,2179,2217,2049,2343,2175,1607,1702,1764,1766,1615,1953,2091,2411,2550,2351,2786,2525,2474,2332,1978,1789,1904,1997,2207,2453,1948,1384,1989,2140,2100,2045,2083,2022,1950,1422,1859,2147) > x <- c(9.253017,9.139274,9.181632,9.104646,9.111845,9.09212,9.111404,9.11548,9.1214,9.195937,9.195024,9.236885,9.243872,9.17885,9.222763,9.143025,9.129564,9.129564,9.154193,9.142811,9.151651,9.203618,9.225032,9.275847,9.281265,9.186048,9.265491,9.141312,9.149422,9.159258,9.142918,9.139811,9.168893,9.226214,9.228377,9.288227,9.315151,9.19766,9.301825,9.138952,9.17056,9.148252,9.188504,9.151121,9.165029,9.226804,9.243485,9.28452,9.329456,9.228475,9.300272,9.172431,9.180809,9.173365,9.167328,9.184099,9.185433,9.259892,9.282568,9.312807) > 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 -191.295251 2 -392.613351 3 -262.077176 4 -51.855776 5 36.860356 6 135.697458 7 -339.958343 8 -165.876671 9 -184.734499 10 121.604206 11 73.049847 12 69.917329 13 -82.798658 14 69.374931 15 5.745747 16 177.338894 17 -172.603300 18 -82.603300 19 -435.576683 20 -286.087867 21 -371.767460 22 -192.970790 23 -118.332194 24 25.550324 25 49.037198 26 136.093742 27 217.290807 28 381.927485 29 -207.796667 30 -139.144233 31 -33.374486 32 -23.051806 33 -251.953382 34 -67.498402 35 64.707598 36 224.388179 37 291.267209 38 406.988828 39 562.963392 40 738.249186 41 602.581247 42 520.337397 43 58.514886 44 -30.347756 45 47.397065 46 -25.078827 47 140.237994 48 276.318071 49 -349.051409 50 -642.554913 51 -229.876607 52 263.569423 53 201.127383 54 166.067529 55 220.238763 56 114.314503 57 38.741134 58 -688.711224 59 -312.453131 60 -105.453949 > library(lattice) > postscript(file="/var/www/rcomp/tmp/1c8lv1256664034.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/2c3o81256664034.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/32b7c1256664034.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/4qsf41256664034.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/57z3k1256664034.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/65sig1256664034.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/7avg21256664034.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/8c7911256664034.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. 9.092 9.147 9.183 9.196 9.239 9.329 > > #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/9hwhc1256664034.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/10vmp91256664034.tab") > > system("convert tmp/1c8lv1256664034.ps tmp/1c8lv1256664034.png") > system("convert tmp/2c3o81256664034.ps tmp/2c3o81256664034.png") > system("convert tmp/32b7c1256664034.ps tmp/32b7c1256664034.png") > system("convert tmp/4qsf41256664034.ps tmp/4qsf41256664034.png") > system("convert tmp/57z3k1256664034.ps tmp/57z3k1256664034.png") > system("convert tmp/65sig1256664034.ps tmp/65sig1256664034.png") > system("convert tmp/7avg21256664034.ps tmp/7avg21256664034.png") > system("convert tmp/8c7911256664034.ps tmp/8c7911256664034.png") > > > proc.time() user system elapsed 1.870 1.650 3.321