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(101,101,98.7,96.4,95.6,95.4,98.7,98.7,98.7,99.3,99.5,99.6,100.8,100.8,100.8,101,101.6,102.3,102.3,102.3,102.3,102.4,102.4,102.4,102.4,102.4,102.4,102.4,101.6,102.2,102.2,102.2,102.2,102.2,102.2,102.2,102.2,102.2,102.2,102.2,102.2,102.2,102.2,102.2,102.2,102.2,102.2,102.2,102.1,102.1,102.1,102.1,100.7,100.7,100.7,100.7,100.7,100.7,100.7,100.7) > x <- c(101,100.3,100.1,99.8,99.9,99.9,100.2,99.7,100.4,100.9,101.3,101.4,101.3,100.9,100.9,100.9,101.1,101.1,101.3,101.8,102.9,103.2,103.3,104.5,105,104.9,104.9,105.4,106,105.7,105.9,106.2,106.4,106.9,107.3,107.9,109.2,110.2,110.2,110.5,110.6,110.8,111.3,111.1,111.2,111.2,111.1,111.5,112.1,111.4,110.4,110,110.4,110,110,109.3,109.7,109.6,109.6,109.4) > 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 0.807645611 2 0.950477168 3 -1.308713816 4 -3.547500291 5 -4.367904800 6 -4.567904800 7 -1.329118324 8 -1.227095783 9 -1.369927340 10 -0.871949881 11 -0.753567913 12 -0.673972421 13 0.546432087 14 0.628050119 15 0.628050119 16 0.828050119 17 1.387241103 18 2.087241103 19 2.046432087 20 1.944409546 21 1.719959957 22 1.758746432 23 1.738341924 24 1.493487827 25 1.391465286 26 1.411869794 27 1.411869794 28 1.309847254 29 0.387420205 30 1.048633729 31 1.007824713 32 0.946611189 33 0.905802173 34 0.803779632 35 0.722161599 36 0.599734551 37 0.334475945 38 0.130430864 39 0.130430864 40 0.069217340 41 0.048812831 42 0.008003815 43 -0.094018725 44 -0.053209709 45 -0.073614217 46 -0.073614217 47 -0.053209709 48 -0.134827742 49 -0.357254790 50 -0.214423234 51 -0.010378152 52 0.071239880 53 -1.410378152 54 -1.328760120 55 -1.328760120 56 -1.185928563 57 -1.267546596 58 -1.247142087 59 -1.247142087 60 -1.206333071 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/1nhvd1257938758.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/20whm1257938758.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/39wwg1257938758.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/4ve0c1257938758.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/5qy2m1257938758.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/6r3py1257938758.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/7w8bm1257938758.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/8mx0k1257938758.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. 99.7 101.2 106.0 105.9 110.0 112.1 > > #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/96y0p1257938758.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/10j3pk1257938758.tab") > > system("convert tmp/1nhvd1257938758.ps tmp/1nhvd1257938758.png") > system("convert tmp/20whm1257938758.ps tmp/20whm1257938758.png") > system("convert tmp/39wwg1257938758.ps tmp/39wwg1257938758.png") > system("convert tmp/4ve0c1257938758.ps tmp/4ve0c1257938758.png") > system("convert tmp/5qy2m1257938758.ps tmp/5qy2m1257938758.png") > system("convert tmp/6r3py1257938758.ps tmp/6r3py1257938758.png") > system("convert tmp/7w8bm1257938758.ps tmp/7w8bm1257938758.png") > system("convert tmp/8mx0k1257938758.ps tmp/8mx0k1257938758.png") > > > proc.time() user system elapsed 1.699 1.224 9.586