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(2.86,2.55,2.27,2.26,2.57,3.07,2.76,2.51,2.87,3.14,3.11,3.16,2.47,2.57,2.89,2.63,2.38,1.69,1.96,2.19,1.87,1.6,1.63,1.22,1.21,1.49,1.64,1.66,1.77,1.82,1.78,1.28,1.29,1.37,1.12,1.51,2.24,2.94,3.09,3.46,3.64,4.39,4.15,5.21,5.8,5.91,5.39,5.46,4.72,3.14,2.63,2.32,1.93,0.62,0.6,-0.37,-1.1,-1.68,-0.78) > x <- c(4.79,5.95,5.46,5.75,5.15,4.96,5.28,5.73,5.75,5.88,6.3,6.74,6.75,7.34,6.64,6.62,6.32,5.32,5.68,6.18,5.02,2.1,4,3,4.73,5.14,5.81,6.24,4.49,4.22,4.88,5.18,5.19,5.06,4.65,4.83,4.6,4.72,4.33,4.97,5.37,4.19,4.54,5.82,5.49,3.28,5.11,6.24,6.41,6.43,8.42,8.23,3.17,2.72,3,3.47,3.88,3.43,4.06) > par2 = '1' > 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.65106463 2 -0.15363462 3 -0.22466684 4 -0.35834165 5 0.20753728 6 0.78856560 7 0.34209684 8 -0.09981235 9 0.25165835 10 0.46621792 11 0.25710267 12 0.11945812 13 -0.57480653 14 -0.72642080 15 -0.10789539 16 -0.35936609 17 -0.48142663 18 -0.74496175 19 -0.62848911 20 -0.61172155 21 -0.43702229 22 0.53825515 23 -0.24202812 24 -0.22556324 25 -0.97334748 26 -0.86819808 27 -1.00392954 28 -1.16730944 29 -0.31099591 30 -0.14585039 31 -0.46731721 32 -1.09525667 33 -1.08952132 34 -0.95408089 35 -1.02923029 36 -0.71599396 37 0.11209296 38 0.76091717 39 1.07723847 40 1.17430095 41 1.18371500 42 2.43694356 43 2.04768085 44 2.56180581 45 3.29253922 46 4.34502659 47 3.04459587 48 2.63269056 49 1.82019153 50 0.23166223 51 -1.12700287 52 -1.35597454 53 0.41193773 54 -0.70615308 55 -0.84556324 56 -2.01600173 57 -2.92085233 58 -3.30894314 59 -2.67761601 > library(lattice) > postscript(file="/var/www/rcomp/tmp/17nui1256460053.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/2ty331256460053.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/34ihw1256460053.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/4r6yg1256460053.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/5d3lt1256460053.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/6bxvq1256460053.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/7diou1256460053.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/8abkd1256460053.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. 2.100 4.515 5.150 5.170 5.915 8.420 > > #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/9cssr1256460053.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/101dyg1256460053.tab") > > system("convert tmp/17nui1256460053.ps tmp/17nui1256460053.png") > system("convert tmp/2ty331256460053.ps tmp/2ty331256460053.png") > system("convert tmp/34ihw1256460053.ps tmp/34ihw1256460053.png") > system("convert tmp/4r6yg1256460053.ps tmp/4r6yg1256460053.png") > system("convert tmp/5d3lt1256460053.ps tmp/5d3lt1256460053.png") > system("convert tmp/6bxvq1256460053.ps tmp/6bxvq1256460053.png") > system("convert tmp/7diou1256460053.ps tmp/7diou1256460053.png") > system("convert tmp/8abkd1256460053.ps tmp/8abkd1256460053.png") > > > proc.time() user system elapsed 1.63 1.38 3.18