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(244.576,241.572,240.541,236.089,236.997,264.579,270.349,269.645,267.037,258.113,262.813,267.413,267.366,264.777,258.863,254.844,254.868,277.267,285.351,286.602,283.042,276.687,277.915,277.128,277.103,275.037,270.150,267.140,264.993,287.259,291.186,292.300,288.186,281.477,282.656,280.190,280.408,276.836,275.216,274.352,271.311,289.802,290.726,292.300,278.506,269.826,265.861,269.034,264.176,255.198,253.353,246.057,235.372,258.556,260.993,254.663,250.643,243.422,247.105,248.541,245.039,237.080,237.085,225.554,226.839,247.934,248.333,246.969,245.098,246.263,255.765,264.319,268.347,273.046,273.963,267.430,271.993,292.710,295.881) > x <- c(97,105.4,102.7,98.1,104.5,87.4,89.9,109.8,111.7,98.6,96.9,95.1,97,112.7,102.9,97.4,111.4,87.4,96.8,114.1,110.3,103.9,101.6,94.6,95.9,104.7,102.8,98.1,113.9,80.9,95.7,113.2,105.9,108.8,102.3,99,100.7,115.5,100.7,109.9,114.6,85.4,100.5,114.8,116.5,112.9,102,106,105.3,118.8,106.1,109.3,117.2,92.5,104.2,112.5,122.4,113.3,100,110.7,112.8,109.8,117.3,109.1,115.9,96,99.8,116.8,115.7,99.4,94.3,91,93.2,103.1,94.1,91.8,102.7,82.6,89.1) > 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 -23.99276370 2 -21.85997028 3 -24.54208245 4 -31.80708837 5 -26.98534101 6 -9.86038475 7 -2.56157718 8 8.90373103 9 7.45762478 10 -9.47732686 11 -5.81691600 12 -2.31765745 13 -1.20276370 14 5.80914780 15 -6.09777785 16 -13.48015449 17 -4.89483213 18 2.82761525 19 16.65993170 20 28.49028004 21 22.60649254 22 12.33774518 23 12.15924222 24 7.09158104 25 7.86156097 26 11.17696360 27 5.12806985 28 -0.75608837 29 6.75897543 30 8.84471559 31 21.82225637 32 33.63790932 33 25.05979123 34 20.12420800 35 17.32830834 36 12.84428235 37 14.10187150 38 19.58041228 39 8.90987150 40 13.67188333 41 13.50504155 42 14.13956920 43 24.29756689 44 34.61634616 45 21.86193530 46 10.98045241 47 0.34985143 48 5.96894353 49 0.68287741 50 -0.03956174 51 -9.65090417 52 -14.99003048 53 -20.84399858 54 -12.76461732 55 -3.17279791 56 -4.42715680 57 -2.39307885 58 -15.17893838 59 -19.62919462 60 -11.64989825 61 -13.86769989 62 -23.66126897 63 -19.06984628 64 -35.61533509 65 -30.17197851 66 -21.24628673 67 -18.52349923 68 -9.49160779 69 -12.03528312 70 -20.83810844 71 -14.45487587 72 -7.91890185 73 -2.54555120 74 8.20752676 75 3.62081953 76 -4.31868343 77 6.90991755 78 15.33530473 79 22.48120440 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/16la11258912904.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/273q01258912904.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/38po01258912904.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/4qqlj1258912904.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/5fetw1258912904.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/6g9s11258912904.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/7g8ac1258912904.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/8ocpb1258912904.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. 80.90 96.95 102.90 103.50 111.60 122.40 > > #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/97hf61258912904.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/10qd6f1258912904.tab") > > system("convert tmp/16la11258912904.ps tmp/16la11258912904.png") > system("convert tmp/273q01258912904.ps tmp/273q01258912904.png") > system("convert tmp/38po01258912904.ps tmp/38po01258912904.png") > system("convert tmp/4qqlj1258912904.ps tmp/4qqlj1258912904.png") > system("convert tmp/5fetw1258912904.ps tmp/5fetw1258912904.png") > system("convert tmp/6g9s11258912904.ps tmp/6g9s11258912904.png") > system("convert tmp/7g8ac1258912904.ps tmp/7g8ac1258912904.png") > system("convert tmp/8ocpb1258912904.ps tmp/8ocpb1258912904.png") > > > proc.time() user system elapsed 1.661 1.197 2.296