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(3922,3759,4138,4634,3995,4308,4143,4429,5219,4929,5755,5592,4163,4962,5208,4755,4491,5732,5731,5040,6102,4904,5369,5578,4619,4731,5011,5299,4146,4625,4736,4219,5116,4205,4121,5103,4300,4578,3809,5526,4247,3830,4394,4826,4409,4569,4106,4794,3914,3793,4405,4022,4100,4788,3163,3585,3903,4178,3863,4187) > x <- c(4.357591848,4.208683161,4.140099325,4.473384771,4.408087257,4.463833288,4.422950781,4.350325564,4.432070927,4.254548077,4.272537777,4.294113356,4.296336055,4.266678465,4.029302594,4.504552412,4.469910338,4.537894618,4.434009709,4.427096433,4.374583393,4.259044094,4.238748439,4.260190683,4.322115879,4.240099746,3.97160052,4.493095407,4.424080883,4.486444648,4.412611726,4.399673721,4.411249219,4.310013199,4.271562825,4.310140802,4.394031192,4.296972159,4.105101245,4.499219552,4.478725179,4.477396221,4.504253321,4.412057147,4.4287016,4.305458855,4.250151535,4.312177356,4.352529815,4.192344395,4.06103759,4.40563659,4.3818368,4.443826031,4.418218403,4.31209269,4.357153176,4.279393143,4.229707433,4.301811023) > 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 -652.188026 2 -761.033723 3 -357.091525 4 17.701031 5 -597.551923 6 -304.825337 7 -454.957409 8 -142.545464 9 617.725826 10 392.286374 11 1211.743977 12 1040.897487 13 -388.910852 14 420.874860 15 753.202429 16 127.366153 17 -124.035406 18 1092.240440 19 1129.020740 20 440.534923 21 1521.632581 22 365.651286 23 838.032300 24 1039.234301 25 57.713682 26 199.540864 27 577.187207 28 675.532774 29 -452.368398 30 3.951486 31 141.802643 32 -370.492134 33 522.298152 34 -351.884881 35 -421.901458 36 546.068713 37 -287.440089 38 25.857813 39 -673.363613 40 900.305578 41 -371.241139 42 -787.757831 43 -233.525076 44 232.004329 45 -191.048835 46 13.771418 47 -429.114716 48 236.328070 49 -658.347094 50 -721.091729 51 -61.338782 52 -569.660678 53 -483.005299 54 182.450794 55 -1433.236363 56 -972.641139 57 -671.028493 58 -367.749145 59 -664.679716 60 -366.901958 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/1x0b71256751602.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/212b61256751602.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/3vuhw1256751602.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/4amm61256751602.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/5arav1256751602.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/643zc1256751602.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/7uii41256751602.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/8lv901256751602.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. 3.972 4.270 4.355 4.340 4.427 4.538 > > #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/9n2rr1256751602.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/10f8hu1256751602.tab") > > system("convert tmp/1x0b71256751602.ps tmp/1x0b71256751602.png") > system("convert tmp/212b61256751602.ps tmp/212b61256751602.png") > system("convert tmp/3vuhw1256751602.ps tmp/3vuhw1256751602.png") > system("convert tmp/4amm61256751602.ps tmp/4amm61256751602.png") > system("convert tmp/5arav1256751602.ps tmp/5arav1256751602.png") > system("convert tmp/643zc1256751602.ps tmp/643zc1256751602.png") > system("convert tmp/7uii41256751602.ps tmp/7uii41256751602.png") > system("convert tmp/8lv901256751602.ps tmp/8lv901256751602.png") > > > proc.time() user system elapsed 1.616 1.183 1.925