R version 2.8.0 (2008-10-20) 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(46,46,41,43,39,36,34,31,27,27,30,28,31,25,26,22,27,38,39,45,48,46,47,55,63,83,100,76,68,63,63,62,62,64,72,67,67,67,69,78,80,85,90,83,84,84,89,82,76,97,82,79,73,72,74,77,78,68,71,68,70,79,78,79,78,77,72,72,84,83,82,78,77,75,77,73,64,64,71,65,68,64,65,56,57,51,52,79,59,54,55,47,52,52,54,49,48,44,47,43,45,40,38,46,51,49,57,61,61,81,97,105,108,113,111,111,110,109,105,97,97) > x <- c(62,64,62,64,64,69,69,65,56,58,53,62,55,60,59,58,53,57,57,53,54,53,57,57,55,49,50,49,54,58,58,52,56,52,59,53,52,53,51,50,56,52,46,48,46,48,48,49,53,48,51,48,50,55,52,53,52,55,53,53,56,54,52,55,54,59,56,56,51,53,52,51,46,49,46,55,57,53,52,53,50,54,53,50,51,52,47,51,49,53,52,45,53,51,48,48,48,48,40,43,40,39,39,36,41,39,40,39,46,40,37,37,44,41,40,36,38,43,42,45,46) > 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 -3.2548667 2 -0.3470468 3 -8.2548667 4 -3.3470468 5 -7.3470468 6 -3.0774970 7 -5.0774970 8 -13.8931368 9 -30.9783264 10 -28.0705065 11 -32.3400562 12 -21.2548667 13 -28.4322363 14 -27.1626866 15 -27.6165965 16 -33.0705065 17 -35.3400562 18 -18.5244164 19 -17.5244164 20 -17.3400562 21 -12.8861463 22 -16.3400562 23 -9.5244164 24 -1.5244164 25 3.5677637 26 14.8443040 27 33.2982139 28 7.8443040 29 7.1138537 30 7.9294935 31 7.9294935 32 -1.7939662 33 4.0216736 34 0.2060338 35 18.3834035 36 4.6599438 37 3.2060338 38 4.6599438 39 3.7521239 40 11.2982139 41 22.0216736 42 21.2060338 43 17.4825741 44 13.3903940 45 11.4825741 46 14.3903940 47 19.3903940 48 13.8443040 49 13.6599438 50 27.3903940 51 16.7521239 52 9.3903940 53 6.2982139 54 12.5677637 55 10.2060338 56 14.6599438 57 14.2060338 58 8.5677637 59 8.6599438 60 5.6599438 61 12.0216736 62 18.1138537 63 14.2060338 64 19.5677637 65 17.1138537 66 23.3834035 67 14.0216736 68 14.0216736 69 18.7521239 70 20.6599438 71 18.2060338 72 12.7521239 73 4.4825741 74 6.8443040 75 4.4825741 76 13.5677637 77 7.4755836 78 1.6599438 79 7.2060338 80 2.6599438 81 1.2982139 82 3.1138537 83 2.6599438 84 -10.7017861 85 -8.2478761 86 -12.7939662 87 -19.0635159 88 13.7521239 89 -9.1556960 90 -8.3400562 91 -8.7939662 92 -26.9713358 93 -10.3400562 94 -13.2478761 95 -15.6096060 96 -20.6096060 97 -21.6096060 98 -25.6096060 99 -34.2408855 100 -33.8791557 101 -36.2408855 102 -42.6947955 103 -44.6947955 104 -41.0565253 105 -28.7869756 106 -33.6947955 107 -24.2408855 108 -21.6947955 109 -11.5174259 110 -0.2408855 111 11.3973846 112 19.3973846 113 32.5747542 114 33.2130244 115 29.7591145 116 23.9434747 117 25.8512946 118 32.1208443 119 26.6669343 120 23.0286642 121 24.4825741 > library(lattice) > postscript(file="/var/www/html/freestat/rcomp/tmp/1enwy1257418557.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/freestat/rcomp/tmp/2qggd1257418557.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/freestat/rcomp/tmp/3yve81257418557.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/freestat/rcomp/tmp/4h6lo1257418557.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/freestat/rcomp/tmp/55r9b1257418557.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/freestat/rcomp/tmp/6hkyk1257418557.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/freestat/rcomp/tmp/7rx9a1257418557.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/freestat/rcomp/tmp/81z9g1257418557.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. 36.00 48.00 52.00 51.09 55.00 69.00 > > #Note: the /var/www/html/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/freestat/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/freestat/rcomp/tmp/9itwz1257418557.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/freestat/rcomp/tmp/103t9u1257418557.tab") > > system("convert tmp/1enwy1257418557.ps tmp/1enwy1257418557.png") > system("convert tmp/2qggd1257418557.ps tmp/2qggd1257418557.png") > system("convert tmp/3yve81257418557.ps tmp/3yve81257418557.png") > system("convert tmp/4h6lo1257418557.ps tmp/4h6lo1257418557.png") > system("convert tmp/55r9b1257418557.ps tmp/55r9b1257418557.png") > system("convert tmp/6hkyk1257418557.ps tmp/6hkyk1257418557.png") > system("convert tmp/7rx9a1257418557.ps tmp/7rx9a1257418557.png") > system("convert tmp/81z9g1257418557.ps tmp/81z9g1257418557.png") > > > proc.time() user system elapsed 2.604 1.972 3.156