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(107.3,107.2,107.2,105.7,105.7,104.9,104.8,104,104,103.6,103.6,103.6,103.6,104.2,104.2,104.7,104.7,104.7,106.1,106.1,106.1,106.1,106.1,106.1,106.1,106.1,106.1,106.1,106.1,106.1,106.1,106.1,106.1,106.2,106.4,106.4,106.4,107,107,107,107,106.1,106.3,106.2,106.2,106.3,106.3,106.2,107.1,105.2,103.4,102.4,100.6,100.6,100.6,99.8,100.2,101.4,101,100.6,100) > x <- c(82.1,55.1,60.6,56.5,53.4,58.5,60.7,47.3,53.7,46.9,51.8,55.2,61.6,47.5,46.1,54.3,49.2,62.6,54.7,48.4,42.1,46.6,55,56.7,55.7,52,65.2,51,57.3,60.5,59.2,40.8,39.5,54.6,54.7,53.3,56.7,57.8,57.1,51.1,60.3,58,63.2,54.5,50.3,48.2,51.3,52.6,68,67.5,53.4,65.3,64.9,51.9,60.6,50.5,61.5,74.4,66.4,69.8,96.8) > 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 4.20249254 2 2.17825262 3 2.57022742 4 0.77802803 5 0.55709678 6 0.12056432 7 0.17735424 8 -1.57763891 9 -1.12152278 10 -2.00614616 11 -1.65693225 12 -1.41462056 13 -0.95850443 14 -1.36338528 15 -1.46316068 16 -0.37876189 17 -0.74222943 18 0.21276371 19 1.04974537 20 0.60075605 21 0.15176674 22 0.47247339 23 1.07112581 24 1.19228166 25 1.12101351 26 0.85732138 27 1.79806089 28 0.78605323 29 1.23504254 30 1.46310061 31 1.37045202 32 0.05911815 33 -0.03353044 34 1.14261855 35 1.34974537 36 1.24996996 37 1.49228166 38 2.17067662 39 2.12078891 40 1.69318004 41 2.34884698 42 1.28493024 43 1.85552460 44 1.13549174 45 0.83616553 46 0.78650242 47 1.00743367 48 1.00008226 49 2.99761169 50 1.06197762 51 -1.74290322 52 -1.89481230 53 -3.72331956 54 -4.64980544 55 -4.02977258 56 -5.54958084 57 -4.36563125 58 -2.24627218 59 -3.21641734 60 -3.37410564 61 -2.04986573 > library(lattice) > postscript(file="/var/www/rcomp/tmp/1sbei1257348911.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/2s2q01257348911.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/3cai51257348911.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/48zgv1257348911.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/5flyu1257348911.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/66ytk1257348911.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/7w7u51257348911.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/8chby1257348911.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. 39.50 51.30 55.10 56.76 60.60 96.80 > > #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/93o211257348911.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/10nwjr1257348911.tab") > > system("convert tmp/1sbei1257348911.ps tmp/1sbei1257348911.png") > system("convert tmp/2s2q01257348911.ps tmp/2s2q01257348911.png") > system("convert tmp/3cai51257348911.ps tmp/3cai51257348911.png") > system("convert tmp/48zgv1257348911.ps tmp/48zgv1257348911.png") > system("convert tmp/5flyu1257348911.ps tmp/5flyu1257348911.png") > system("convert tmp/66ytk1257348911.ps tmp/66ytk1257348911.png") > system("convert tmp/7w7u51257348911.ps tmp/7w7u51257348911.png") > system("convert tmp/8chby1257348911.ps tmp/8chby1257348911.png") > > > proc.time() user system elapsed 1.990 1.900 3.531