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(1.69,1.44,1.21,1.96,1.44,2.25,1.21,1.69,2.25,1.21,1.96,1.69,2.25,2.56,2.89,1.21,2.56,1.69,2.89,2.56,2.89,3.61,3.24,3.61,2.56,2.25,2.56,2.56,2.89,4,4,3.61,2.89,3.24,3.61,2.89,4,4.41,5.76,6.25,6.25,6.76,4.84,6.25,7.84,7.84,8.41,9,9.61,8.41,7.29,4.84,6.25,5.29,6.76,5.29,4.84,3.24,3.24) > x <- c(2,2.1,2.1,2.5,2.2,2.3,2.3,2.2,2.2,1.6,1.8,1.7,1.9,1.8,1.9,1.5,1,0.8,1.1,1.5,1.7,2.3,2.4,3,3,3.2,3.2,3.2,3.5,4,4.3,4.1,4,4.1,4.2,4.5,5.6,6.5,7.6,8.5,8.7,8.3,8.3,8.5,8.7,8.7,8.5,7.9,7,5.8,4.5,3.7,3.1,2.7,2.3,1.8,1.5,1.2,1) > 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 -1.03934694 2 -1.35755015 3 -1.58755015 4 -1.11036301 5 -1.42575337 6 -0.68395658 7 -1.72395658 8 -1.17575337 9 -0.61575337 10 -1.24653408 11 -0.63294051 12 -0.83473729 13 -0.41114372 14 -0.03294051 15 0.22885628 16 -1.17833086 17 0.51268521 18 -0.22090836 19 0.77448200 20 0.17166914 21 0.36526271 22 0.67604342 23 0.23784020 24 0.19862091 25 -0.85137909 26 -1.29778552 27 -0.98778552 28 -0.98778552 29 -0.86239516 30 -0.09341124 31 -0.29802088 32 -0.55161445 33 -1.20341124 34 -0.92161445 35 -0.61981767 36 -1.54442731 37 -1.18466268 38 -1.38849161 39 -0.78872698 40 -0.91255591 41 -1.04896234 42 -0.26614948 43 -2.18614948 44 -0.91255591 45 0.54103766 46 0.54103766 47 1.24744409 48 2.24666338 49 3.47049231 50 3.08893089 51 2.85557269 52 0.95119841 53 2.77041770 54 2.08323056 55 3.82604342 56 2.69705949 57 2.45166914 58 1.05627878 59 1.19268521 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/1l9fk1256660831.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/2mmc61256660831.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/32csp1256660831.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/4lfqw1256660831.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/5inph1256660831.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/6p1cq1256660831.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/74whr1256660831.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/8r83w1256660831.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. 0.800 1.900 3.000 3.756 4.500 8.700 > > #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/9bbrs1256660831.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/1021om1256660831.tab") > > system("convert tmp/1l9fk1256660831.ps tmp/1l9fk1256660831.png") > system("convert tmp/2mmc61256660831.ps tmp/2mmc61256660831.png") > system("convert tmp/32csp1256660831.ps tmp/32csp1256660831.png") > system("convert tmp/4lfqw1256660831.ps tmp/4lfqw1256660831.png") > system("convert tmp/5inph1256660831.ps tmp/5inph1256660831.png") > system("convert tmp/6p1cq1256660831.ps tmp/6p1cq1256660831.png") > system("convert tmp/74whr1256660831.ps tmp/74whr1256660831.png") > system("convert tmp/8r83w1256660831.ps tmp/8r83w1256660831.png") > > > proc.time() user system elapsed 1.623 1.196 5.388