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(412,602,613,482,241,277,252,383,506,366,473,581,688,792,761,592,251,162,183,164,223,237,567,778,888,1118,1275,419,324,197,172,220,98,122,303,750,745,293,534,318,72,67,256,82,337,596,1152,1028,1011,823,1545,1211,593,348,341,340,589,1095,788,432) > x <- c(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,2273,1881,2454,2081,2376,2265,2131,2333,1881,1563,1738,1990) > 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 -96.561405 2 102.155496 3 91.759465 4 -22.599178 5 -110.657182 6 -110.317233 7 -21.601293 8 62.248195 9 209.814008 10 -56.184838 11 -1.486246 12 -4.428626 13 87.514908 14 258.080336 15 110.590837 16 8.156265 17 -107.789192 18 -234.430357 19 -237.996170 20 -257.788615 21 -138.958975 22 -258.882276 23 16.438979 24 100.647688 25 155.572721 26 464.421055 27 449.064143 28 -303.521710 29 -378.314348 30 -449.050712 31 -333.787846 32 -210.901739 33 -378.467360 34 -391.316079 35 -293.522864 36 56.006331 37 251.098838 38 22.568489 39 23.853703 40 -251.975937 41 -482.127026 42 -465.334773 43 -291.391238 44 -441.221648 45 -157.693608 46 310.512023 47 693.362666 48 455.250503 49 388.326432 50 355.645764 51 850.610108 52 664.401207 53 -70.484515 54 -271.503785 55 -225.409932 56 -306.446935 57 121.645764 58 753.644610 59 377.305623 60 -78.542519 > library(lattice) > postscript(file="/var/www/rcomp/tmp/1kbq11256746274.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/27qq81256746274.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/3iju71256746274.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/4e6qb1256746274.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/5b7wf1256746274.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/6wx3h1256746274.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/77g5k1256746274.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/8atcz1256746274.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. 1384 1784 1994 2008 2210 2786 > > #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/9jryb1256746274.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/103lzt1256746274.tab") > > system("convert tmp/1kbq11256746274.ps tmp/1kbq11256746274.png") > system("convert tmp/27qq81256746274.ps tmp/27qq81256746274.png") > system("convert tmp/3iju71256746274.ps tmp/3iju71256746274.png") > system("convert tmp/4e6qb1256746274.ps tmp/4e6qb1256746274.png") > system("convert tmp/5b7wf1256746274.ps tmp/5b7wf1256746274.png") > system("convert tmp/6wx3h1256746274.ps tmp/6wx3h1256746274.png") > system("convert tmp/77g5k1256746274.ps tmp/77g5k1256746274.png") > system("convert tmp/8atcz1256746274.ps tmp/8atcz1256746274.png") > > > proc.time() user system elapsed 1.810 1.590 3.498