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(10436,9314,9717,8997,9062,8885,9058,9095,9149,9857,9848,10269,10341,9690,10125,9349,9224,9224,9454,9347,9430,9933,10148,10677,10735,9760,10567,9333,9409,9502,9348,9319,9594,10160,10182,10810,11105,9874,10958,9311,9610,9398,9784,9425,9557,10166,10337,10770,11265,10183,10941,9628,9709,9637,9579,9741,9754,10508,10749,11079) > x <- c(498,350,314,288,254,229,306,170,230,440,305,426,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) > 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 461.00850 2 -442.35223 3 13.83029 4 -667.76011 5 -552.53217 6 -692.59986 7 -633.35137 8 -395.43961 9 -430.07715 10 -32.30854 11 158.12592 12 400.37355 13 493.05564 14 -438.62990 15 -19.88011 16 -602.35482 17 -371.32737 18 -424.50989 19 -157.57758 20 -458.10288 21 -556.80984 22 153.01109 23 209.94081 24 579.39324 25 479.32296 26 -649.31544 27 203.48062 28 -780.85698 29 -201.10029 30 23.37873 31 -161.64441 32 -162.57586 33 25.26389 34 570.58180 35 105.07533 36 421.36665 37 553.86449 38 -1016.91274 39 -164.84764 40 -547.28540 41 -107.94263 42 -132.32651 43 290.60580 44 -139.30423 45 172.92544 46 746.47042 47 650.08051 48 422.73084 49 925.11730 50 510.85343 51 912.82598 52 -81.07888 53 363.33504 54 298.72150 55 -38.48675 56 380.56211 57 16.85257 58 388.23385 59 -192.14068 60 321.04357 > library(lattice) > postscript(file="/var/www/rcomp/tmp/1a0iq1256902610.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/2qm0w1256902610.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/32vrx1256902610.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/47u5m1256902610.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/57vtf1256902610.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/638yt1256902610.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/796qp1256902610.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/8fiyp1256902610.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. 67.0 235.2 330.5 429.4 583.8 1275.0 > > #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/9gctj1256902610.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/10dkpc1256902610.tab") > > system("convert tmp/1a0iq1256902610.ps tmp/1a0iq1256902610.png") > system("convert tmp/2qm0w1256902610.ps tmp/2qm0w1256902610.png") > system("convert tmp/32vrx1256902610.ps tmp/32vrx1256902610.png") > system("convert tmp/47u5m1256902610.ps tmp/47u5m1256902610.png") > system("convert tmp/57vtf1256902610.ps tmp/57vtf1256902610.png") > system("convert tmp/638yt1256902610.ps tmp/638yt1256902610.png") > system("convert tmp/796qp1256902610.ps tmp/796qp1256902610.png") > system("convert tmp/8fiyp1256902610.ps tmp/8fiyp1256902610.png") > > > proc.time() user system elapsed 1.770 1.600 3.239