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(97.9,96.6,96.2,95.8,96,96.2,96.5,95.4,96.2,96.8,97,97.1,96.6,95.8,96.2,96,95.9,95.8,96,96.2,96.8,96.9,97.2,98.9,98.9,98.8,99,99.6,99.9,100.1,99.9,100.5,100.7,101.3,101.3,101.7,103,104.7,104.5,104.6,104.2,104.5,104.8,104.7,104.6,104.5,104.7,104.8,106.2,105.6,104.5,104.2,104.1,103.3,103.8,103.3,103.7,103.5,103.7,103.4,102.8) > x <- c(103.5,103.2,103.1,102.9,102.9,102.9,103.2,103,103.7,104.2,104.7,104.8,104.9,104.8,104.6,104.6,105.2,105.2,105.4,106.1,107.6,107.9,107.9,108.8,109.6,109.5,109.4,109.9,110.7,110,110.4,110.7,110.9,111.2,111.9,112.7,114.1,114.3,114.6,115,115.6,115.6,116.2,116,116.2,116.3,116.1,116.6,116.5,115.7,114.8,114.3,115.2,115.2,114.7,113.8,114.2,114.2,114.1,113.8,113.9) > 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.315512287 2 1.232093976 3 0.904287872 4 0.648675665 5 0.848675665 6 1.048675665 7 1.132093976 8 0.176481768 9 0.471124494 10 0.710155013 11 0.549185531 12 0.576991635 13 0.004797739 14 -0.723008365 15 -0.178620572 16 -0.378620572 17 -0.911783950 18 -1.011783950 19 -0.956171743 20 -1.261529017 21 -1.744437461 22 -1.861019150 23 -1.561019150 24 -0.510764217 25 -1.088315387 26 -1.116121491 27 -0.843927595 28 -0.604897076 29 -0.882448247 30 -0.177090973 31 -0.665866558 32 -0.282448247 33 -0.226836039 34 0.156582272 35 -0.348775002 36 -0.526326173 37 -0.237040721 38 1.318571486 39 0.901989798 40 0.713214212 41 -0.119949165 42 0.180050835 43 0.046887457 44 0.091275249 45 -0.153112543 46 -0.325306440 47 0.019081353 48 -0.241888128 49 1.230305768 50 1.207856938 51 0.757602005 52 0.818571486 53 0.068826420 54 -0.731173580 55 0.129795901 56 0.279540968 57 0.390765383 58 0.190765383 59 0.462959279 60 0.379540968 61 -0.292652928 > library(lattice) > postscript(file="/var/www/rcomp/tmp/1el5q1257942751.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/2znun1257942751.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/3ks9j1257942751.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/4gthd1257942751.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/56mjy1257942751.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/6pxj41257942751.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/7rrex1257942751.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/89pb51257942751.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. 102.9 104.9 110.7 110.1 114.6 116.6 > > #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/9vnl31257942751.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/10x6721257942751.tab") > > system("convert tmp/1el5q1257942751.ps tmp/1el5q1257942751.png") > system("convert tmp/2znun1257942751.ps tmp/2znun1257942751.png") > system("convert tmp/3ks9j1257942751.ps tmp/3ks9j1257942751.png") > system("convert tmp/4gthd1257942751.ps tmp/4gthd1257942751.png") > system("convert tmp/56mjy1257942751.ps tmp/56mjy1257942751.png") > system("convert tmp/6pxj41257942751.ps tmp/6pxj41257942751.png") > system("convert tmp/7rrex1257942751.ps tmp/7rrex1257942751.png") > system("convert tmp/89pb51257942751.ps tmp/89pb51257942751.png") > > > proc.time() user system elapsed 1.900 1.800 3.508