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(39120,33702,25094,51442,45594,52518,48564,41745,49585,32747,33379,35645,37034,35681,20972,58552,54955,65540,51570,51145,46641,35704,33253,35193,41668,34865,21210,56126,49231,59723,48103,47472,50497,40059,34149,36860,46356,36577,23872,57276,56389,57657,62300,48929,51168,39636,33213,38127,43291,30600,21956,48033,46148,50736,48114,38390,44112,36287,30333) > x <- c(4.573,4.737,4.703,4.643,4.621,4.550,4.563,4.651,4.633,4.586,4.735,4.393,4.561,4.729,4.662,4.690,4.628,4.595,4.612,4.749,4.612,4.700,4.741,4.447,4.610,4.743,4.758,4.727,4.625,4.663,4.657,4.777,4.664,4.694,4.764,4.527,4.646,4.723,4.807,4.730,4.605,4.707,4.726,4.699,4.765,4.692,4.753,4.564,4.603,4.760,4.751,4.599,4.546,4.511,4.535,4.636,4.544,4.520,4.632) > 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 -5113.7742 2 -7483.0724 3 -16723.1203 4 8509.5009 5 2252.5287 6 7856.6639 7 4144.3293 8 -1038.7819 9 6466.6045 10 -11245.1088 11 -7843.2517 12 -11934.9104 13 -7422.8500 14 -5652.7895 15 -21607.2958 16 16493.2143 17 11743.6563 18 21715.1980 19 8061.2219 20 10183.0034 21 3132.2219 22 -6168.8893 23 -7857.7138 24 -11383.0696 25 -1877.9574 26 -6208.5345 27 -19584.6898 28 14755.0312 29 5963.8873 30 17162.2939 31 5430.7560 32 7030.5134 33 7954.8835 34 -1925.4271 35 -6534.1519 36 -8228.8979 37 3479.2699 38 -4868.3274 39 -16011.7972 40 15960.8001 41 12750.0944 42 15914.2383 43 20910.4415 44 7037.5211 45 10503.4377 46 -2385.6064 47 -7674.6380 48 -6274.0810 49 -385.0849 50 -10157.5105 51 -18968.8173 52 4282.5565 53 1412.3053 54 5349.6677 55 3173.8192 56 -4672.6266 57 -660.8740 58 -8932.0255 59 -12803.9852 > library(lattice) > postscript(file="/var/www/rcomp/tmp/1bnhm1256755305.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/277g01256755305.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/3fp7a1256755305.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/48gb81256755305.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/5qiic1256755305.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/619xy1256755305.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/75h8b1256755305.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/8i3281256755305.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. 4.393 4.597 4.651 4.650 4.728 4.807 > > #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/9uxd21256755305.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/1048g51256755305.tab") > > system("convert tmp/1bnhm1256755305.ps tmp/1bnhm1256755305.png") > system("convert tmp/277g01256755305.ps tmp/277g01256755305.png") > system("convert tmp/3fp7a1256755305.ps tmp/3fp7a1256755305.png") > system("convert tmp/48gb81256755305.ps tmp/48gb81256755305.png") > system("convert tmp/5qiic1256755305.ps tmp/5qiic1256755305.png") > system("convert tmp/619xy1256755305.ps tmp/619xy1256755305.png") > system("convert tmp/75h8b1256755305.ps tmp/75h8b1256755305.png") > system("convert tmp/8i3281256755305.ps tmp/8i3281256755305.png") > > > proc.time() user system elapsed 1.790 1.530 3.186