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(102.0,104.7,86.0,92.1,106.9,112.6,101.7,92.0,97.4,97.0,105.4,102.7,98.1,104.5,87.4,89.9,109.8,111.7,98.6,96.9,95.1,97.0,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.0,100.7,115.5,100.7,109.9,114.6,85.4,100.5,114.8,116.5,112.9,102.0,106.0,105.3,118.8,106.1,109.3,117.2,92.5,104.2,112.5,122.4,113.3,100.0,110.7,112.8,109.8,117.3,109.1,115.9,96.0,99.8,116.8,115.7,99.4,94.3,91.0,93.2,103.1,94.1,91.8,102.7,82.6,89.1) > x <- c(70.5,77.7,56.0,56.8,69.2,71.3,79.4,80.8,72.2,69.8,73.0,82.0,76.3,65.3,51.4,60.5,83.0,89.8,78.6,85.8,69.7,69.4,76.6,76.4,77.1,79.0,67.5,60.0,71.7,79.3,66.0,78.1,57.1,49.6,64.0,57.8,61.6,82.4,61.8,62.1,79.5,65.4,72.5,84.6,62.5,65.1,79.0,65.9,66.1,83.3,40.6,58.6,67.3,68.2,59.5,65.7,53.4,39.5,51.7,42.3,45.9,54.7,41.8,48.6,57.1,76.5,62.7,53.9,53.5,47.5,49.3,59.9,49.9,54.5,54.2,46.7,61.2,51.8,37.4,41.1,30.0,34.8,45.9,45.1,42.6,49.0,29.6,46.0) > 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 -2.852864523 2 -1.668699482 3 -15.800141342 4 -9.868567449 5 2.320827900 6 7.578709370 7 -5.026604958 8 -15.021350645 9 -7.810769999 10 -7.705491680 11 0.020803894 12 -4.573989804 13 -7.973953795 14 0.741905169 15 -13.431691230 16 -12.847538191 17 2.315477562 18 2.783855657 19 -7.958178852 20 -11.174013810 21 -9.584438416 22 -7.621278627 23 6.562886415 24 -3.195007059 25 -8.842379902 26 4.757608095 27 -16.821266624 28 -5.842271875 29 8.994496317 30 3.594448305 31 -0.005467674 32 -4.852912535 33 -7.431727239 34 -4.552732490 35 1.215597593 36 0.620899918 37 -4.879124088 38 6.541797142 39 -22.121230614 40 -7.384390404 41 6.452341778 42 2.120851906 43 3.526070211 44 -5.521374651 45 -4.168603458 46 -3.015988304 47 8.857608095 48 -3.184414410 49 5.973479063 50 7.052317772 51 -13.157938791 52 -1.847526188 53 10.620839903 54 12.131360533 55 10.362994442 56 -1.842307884 57 4.747243504 58 6.973647105 59 17.905148981 60 7.184155732 61 9.626238253 62 15.673551081 63 -6.310577951 64 3.957800143 65 10.468272761 66 16.283939678 67 10.089290016 68 -1.358022812 69 9.426190241 70 12.789386040 71 9.410427300 72 14.678781389 73 8.584107720 74 14.415657608 75 -5.421182602 76 -0.042187854 77 13.905088965 78 14.784095717 79 1.515765635 80 -4.363205108 81 -5.326292880 82 -4.136849519 83 3.426238253 84 -5.405335641 85 -7.179004058 86 2.373587090 87 -13.642079827 88 -10.594815010 > library(lattice) > postscript(file="/var/www/html/freestat/rcomp/tmp/13cj01257952822.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/2es4b1257952822.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/3fhdq1257952822.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/4ni9m1257952822.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/5af5t1257952822.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/68vvr1257952822.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/74rcy1257952822.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/8xpo61257952822.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. 29.60 51.63 62.30 62.03 72.62 89.80 > > #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/9v3bs1257952822.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/10ckjx1257952822.tab") > > system("convert tmp/13cj01257952822.ps tmp/13cj01257952822.png") > system("convert tmp/2es4b1257952822.ps tmp/2es4b1257952822.png") > system("convert tmp/3fhdq1257952822.ps tmp/3fhdq1257952822.png") > system("convert tmp/4ni9m1257952822.ps tmp/4ni9m1257952822.png") > system("convert tmp/5af5t1257952822.ps tmp/5af5t1257952822.png") > system("convert tmp/68vvr1257952822.ps tmp/68vvr1257952822.png") > system("convert tmp/74rcy1257952822.ps tmp/74rcy1257952822.png") > system("convert tmp/8xpo61257952822.ps tmp/8xpo61257952822.png") > > > proc.time() user system elapsed 2.664 2.002 3.187