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(128.6,128.9,129.06,129.23,129.27,129.33,129.35,129.31,129.4,129.49,129.47,129.46,129.45,129.28,129.2,129.25,129.14,129.11,129.02,129.08,128.99,129.11,129.08,129.19,129.23,129.25,129.31,129.33,129.39,129.55,129.43,129.45,129.57,129.76,129.92,130.08,130.41,130.84,131.24,131.49,131.74,132.34,133.5,134.43,136.5,137.41,138.02,138.15,138.24,138.2,138.31,138.65,139.3,139.8,140.52,141.57,141.77,141.66,141.36,141.17) > x <- c(131.6,132.05,132.4,132.57,133.02,133.47,133.66,133.96,134.19,134.93,134.9,135.05,135.16,135.23,135.15,135.12,137.29,137.41,137.44,137.62,137.78,137.98,138.06,138.16,138.28,138.33,138.43,138.44,138.41,138.55,138.64,138.72,138.9,139.02,139.04,139.15,139.3,140.73,141.84,141.95,142.1,142.36,142.58,142.75,142.85,143.03,143.19,143.62,143.89,144.69,147.51,147.78,148.04,148.21,148.29,148.34,148.33,148.38,148.37,148.37) > 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.9105702 2 2.8419072 3 2.7151694 4 2.7458967 5 2.4172338 6 2.1085709 7 1.9729132 8 1.6871379 9 1.5887102 10 1.0724645 11 1.0770420 12 0.9441544 13 0.8440368 14 0.6166892 15 0.6022293 16 0.6768068 17 -1.2109678 18 -1.3392779 19 -1.4538554 20 -1.5413206 21 -1.7624007 22 -1.8062509 23 -1.9017910 24 -1.8737161 25 -1.9320262 26 -1.9529888 27 -1.9749139 28 -1.9631064 29 -1.8785289 30 -1.8332240 31 -2.0269566 32 -2.0724966 33 -2.0999618 34 -2.0082719 35 -1.8646570 36 -1.7947746 37 -1.5876622 38 -2.3291911 39 -2.8385596 40 -2.6786772 41 -2.5515649 42 -2.1645701 43 -1.1848053 44 -0.3940780 45 1.5939969 46 2.3565317 47 2.8354516 48 2.6131737 49 2.4819759 50 1.7865751 51 -0.4137125 52 -0.2949103 53 0.1420844 54 0.5028118 55 1.1572717 56 2.1663092 57 2.3745017 58 2.2235391 59 1.9317316 60 1.7417316 > library(lattice) > postscript(file="/var/www/rcomp/tmp/1ia5q1257515740.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/2dx611257515740.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/39itj1257515740.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/4et5f1257515740.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/51ovi1257515740.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/6hlgt1257515740.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/70g8f1257515740.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/8j48r1257515740.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. 131.6 135.2 138.6 139.7 142.9 148.4 > > #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/9pvnb1257515740.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/10m6z11257515740.tab") > > system("convert tmp/1ia5q1257515740.ps tmp/1ia5q1257515740.png") > system("convert tmp/2dx611257515740.ps tmp/2dx611257515740.png") > system("convert tmp/39itj1257515740.ps tmp/39itj1257515740.png") > system("convert tmp/4et5f1257515740.ps tmp/4et5f1257515740.png") > system("convert tmp/51ovi1257515740.ps tmp/51ovi1257515740.png") > system("convert tmp/6hlgt1257515740.ps tmp/6hlgt1257515740.png") > system("convert tmp/70g8f1257515740.ps tmp/70g8f1257515740.png") > system("convert tmp/8j48r1257515740.ps tmp/8j48r1257515740.png") > > > proc.time() user system elapsed 1.840 1.700 2.892