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(3.8,4.7,4.3,3.9,4,4.3,4.8,4.4,4.3,4.7,4.7,4.9,5,4.2,4.3,4.8,4.8,4.8,4.2,4.6,4.8,4.5,4.4,4.3,3.9,3.7,4,4.1,3.7,3.8,3.8,3.8,3.3,3.3,3.3,3.2,3.4,4.2,4.9,5.1,5.5,5.6,6.4,6.1,7.1,7.8,7.9,7.4,7.5,6.8,5.2,4.7,4.1,3.9,2.6,2.7,1.8,1,0.3,1.3) > x <- c(5.081404365,5.003946306,4.934473933,4.905274778,4.86753445,4.844187086,4.804021045,4.762173935,4.718498871,4.727387819,5.003946306,5.056245805,5.056245805,4.990432587,4.919980926,4.882801923,4.828313737,4.812184355,4.762173935,4.736198448,4.709530201,4.718498871,4.9698133,5.010635294,5.003946306,4.8978398,4.812184355,4.753590191,4.762173935,4.709530201,4.65396035,4.624972813,4.553876892,4.532599493,4.820281566,4.86753445,4.820281566,4.744932128,4.663439094,4.65396035,4.65396035,4.615120517,4.553876892,4.532599493,4.430816799,4.465908119,4.753590191,4.787491743,4.762173935,4.691347882,4.65396035,4.672828834,4.691347882,4.691347882,4.682131227,4.672828834,4.59511985,4.634728988,4.875197323,4.919980926) > 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.01808772 2 0.76045377 3 0.21907140 4 -0.24035144 5 -0.21715632 6 0.03532974 7 0.45358832 8 -0.03157422 9 -0.22045680 10 0.19763298 11 0.76045377 12 1.06688784 13 1.16688784 14 0.23295217 15 0.18957686 16 0.61391432 17 0.50302608 18 0.47020138 19 -0.23157422 20 0.11556339 21 0.26129117 22 -0.02045680 23 0.39099011 24 0.37406645 25 -0.03954623 26 -0.45548228 27 -0.32979862 28 -0.34904289 29 -0.73157422 30 -0.73870883 31 -0.85179836 32 -0.91079054 33 -1.55547698 34 -1.59877835 35 -1.01332009 36 -1.01715632 37 -0.91332009 38 -0.26666281 39 0.26749172 40 0.44820164 41 0.84820164 42 0.86915917 43 1.54452302 44 1.20122165 45 1.99408494 46 2.76549885 47 3.45095711 48 3.01994974 49 3.06842578 50 2.22428855 51 0.54820164 52 0.08660066 53 -0.47571145 54 -0.67571145 55 -1.99446815 56 -1.91339934 57 -2.97154394 58 -3.69093587 59 -3.90156170 60 -2.81042314 > library(lattice) > postscript(file="/var/www/rcomp/tmp/1ztah1256670009.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/2kgdg1256670009.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/3fxdv1256670009.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/42w6a1256670009.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/5une21256670009.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/69yzz1256670009.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/7z2ae1256670009.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/8j4351256670009.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. 4.431 4.670 4.758 4.772 4.877 5.081 > > #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/90nxc1256670009.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/10evwr1256670009.tab") > > system("convert tmp/1ztah1256670009.ps tmp/1ztah1256670009.png") > system("convert tmp/2kgdg1256670009.ps tmp/2kgdg1256670009.png") > system("convert tmp/3fxdv1256670009.ps tmp/3fxdv1256670009.png") > system("convert tmp/42w6a1256670009.ps tmp/42w6a1256670009.png") > system("convert tmp/5une21256670009.ps tmp/5une21256670009.png") > system("convert tmp/69yzz1256670009.ps tmp/69yzz1256670009.png") > system("convert tmp/7z2ae1256670009.ps tmp/7z2ae1256670009.png") > system("convert tmp/8j4351256670009.ps tmp/8j4351256670009.png") > > > proc.time() user system elapsed 1.720 1.410 3.196