[Dream-commits] r24 - in pkg: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri May 7 10:13:55 CEST 2010


Author: felix
Date: 2010-05-07 10:13:54 +0200 (Fri, 07 May 2010)
New Revision: 24

Modified:
   pkg/DESCRIPTION
   pkg/R/dream.R
   pkg/man/dream.Rd
Log:
mostly documentation changes

Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION	2010-04-28 05:09:21 UTC (rev 23)
+++ pkg/DESCRIPTION	2010-05-07 08:13:54 UTC (rev 24)
@@ -2,7 +2,7 @@
 Version: 0.2-0
 Date: 2010-02-19
 Title: DiffeRential Evolution Adaptive Metropolis
-Author: Jasper Vrugt, CJF ter Braak, et al. R port by Joseph Guillaume.
+Author: Jasper Vrugt, CJF ter Braak, et al. (R port by Joseph Guillaume)
 Maintainer: Joseph Guillaume <joseph.guillaume at anu.edu.au>
 Description: Efficient global MCMC even in high-dimensional spaces.
   Based on the original MATLAB code written by Jasper Vrugt.

Modified: pkg/R/dream.R
===================================================================
--- pkg/R/dream.R	2010-04-28 05:09:21 UTC (rev 23)
+++ pkg/R/dream.R	2010-05-07 08:13:54 UTC (rev 24)
@@ -18,7 +18,7 @@
          thin.t=NA,            ## parameter for reduced sample collection
 ### Efficiency improvements
          REPORT = 1000,            ## approximate number of function evaluations between reports. >0. 0=none
-         parallel=c("multicore","snow","foreach"),   ##packages to use for parallel in order of preference: multicore,snow,foreach
+         parallel = "none",   ##packages to use for parallel in order of preference: multicore,snow,foreach
 ### Parameters with auto-set values
          ndim=NA,			 ## number of parameters (automatically set from length of pars)
          DEpairs = NA,          ## Number of DEpairs. defaults to max val floor((nseq-1)/2)
@@ -322,7 +322,7 @@
       CR[,gen.number] <- tmp$CR
 
       ## Now compute the likelihood of the new points
-      tmp<-do.call(CompDensity,list(pars=x.new,control=control,FUN=FUN,func.type=func.type,measurement=measurement,FUN.pars=FUN.pars))
+      tmp <- CompDensity(pars=x.new,control=control,FUN=FUN,func.type=func.type,measurement=measurement,FUN.pars=FUN.pars)
       p.new <- tmp$p
       logp.new <- tmp$logp
 
@@ -433,11 +433,14 @@
 
       counter.report <- counter.report+1
             
-      try(
+      try({
           obj$R.stat[counter.report,] <- c(counter.fun.evals,gelman.diag(
                     as.mcmc.list(lapply(1:NSEQ,function(i) as.mcmc(Sequences[1:(counter-1),1:NDIM,i]))),
                        autoburnin=TRUE)$psrf[,1])
-        )
+          if (counter.report == 1)
+              message(format(colnames(obj$R.stat), width = 5))
+          message(format(obj$R.stat[counter.report,], width = 5, digits = 4))
+      })
       
       if (all(!is.na(obj$R.stat[counter.report,])) &&
           all(obj$R.stat[counter.report,-1]<control$Rthres)) {
@@ -489,8 +492,9 @@
   obj$AR <- obj$AR[1:(counter-1),]
   obj$CR <- obj$CR[1:(counter.outloop-1),]
   
+  ## store number of iterations
+  obj$iterations <- counter.outloop
   ## store number of function evaluations
-  ## store number of iterations
   obj$fun.evals <- counter.fun.evals
   ## store the amount of time taken
   obj$time <- toc

Modified: pkg/man/dream.Rd
===================================================================
--- pkg/man/dream.Rd	2010-04-28 05:09:21 UTC (rev 23)
+++ pkg/man/dream.Rd	2010-05-07 08:13:54 UTC (rev 24)
@@ -1,25 +1,70 @@
 \name{dream}
 \alias{dream}
 \title{DiffeRential Evolution Adaptive Metropolis (DREAM)}
-\usage{dream(FUN, func.type, pars, FUN.pars=list(), INIT=LHSInit,
-INIT.pars=list(), control=list(), measurement)}
+\usage{
+
+dream(FUN, func.type, pars, FUN.pars = list(), INIT = LHSInit,
+      INIT.pars = list(), control = list(), measurement)
+
+}
 \description{
   Efficient global MCMC even in high-dimensional spaces.
   From J.A. Vrugt, C.J.F. ter Braak et al.
 }
 \arguments{
-  \item{FUN}{model function with first argument a vector of parameter values of length ndim}
-  \item{func.type}{type of value FUN returns.
-    one of: posterior.density, logposterior.density,calc.loglik,calc.rmse,calc.weighted.rmse}
-  \item{pars}{a list of variable ranges. Any names will be propagated to output}
-  \item{FUN.pars}{A named list of extra arguments to FUN}
-  \item{INIT}{A function f(pars,nseq,...) returning an nseq x ndim
-    matrix of initial parameter values}
-  \item{INIT.pars}{A named list of extra arguments to INIT}
-  \item{control}{list of settings for dream. see below}
-  \item{measurement}{Required parameter for func.types starting with calc. list with
-    element data, a vector containing observed dependent variable values.
+  \item{FUN}{
+    model function with first argument a vector of parameter values of
+    length ndim.
   }
+  \item{func.type}{
+    type of value \code{FUN} returns. One of:
+    \describe{
+      \item{\code{"posterior.density"}}{
+        \code{FUN} returns the likelihood.
+      }
+      \item{\code{"logposterior.density"}}{
+        \code{FUN} returns the log-likelihood.
+      }
+      \item{\code{"calc.loglik"}}{
+        \code{FUN} returns the residual vector to be compared with
+        \code{measurement}.
+        The exponential power density function of Box and Tiao (1973) is
+        used, based on the parameter \code{control$gamma}, and
+        \code{measurement$N} and \code{measurement$sigma}.
+      }
+      \item{\code{"calc.rmse"}}{
+        \code{FUN} returns the residual vector to be compared with
+        \code{measurement}. The likelihood is calculated as the sum of
+        squared residuals to a power \code{-N}, adjusted by
+        \code{control$gamma}. 
+      }
+      \item{\code{"calc.weighted.rmse"}}{
+        similar to \code{"calc.rmse"} but weighted with
+        \code{measurement$sigma}. 
+      }
+    }
+  }
+  \item{pars}{
+    a list of variable ranges. Any names will be propagated to output.
+  }
+  \item{FUN.pars}{
+    a list of any extra arguments to be passed to \code{FUN}.
+  }
+  \item{INIT}{
+    A function f(pars,nseq,...) returning an \code{nseq x ndim}
+    matrix of initial parameter values. 
+  }
+  \item{INIT.pars}{
+    a list of any extra arguments to be passed to the \code{INIT} function.
+  }
+  \item{control}{
+    list of settings for the DREAM algorithm. see below.
+  }
+  \item{measurement}{
+    Required parameter for \code{func.type}s starting with \code{calc}.
+    A list with element \code{data}, a vector containing observed
+    dependent variable values. 
+  }
 }
 \details{
   Elements of control are:
@@ -37,7 +82,7 @@
     \code{eps} \tab 5e-2 \tab Random error for ergodicity \cr
     \code{outlierTest} \tab 'IQR_test' \tab Test used to detect outlier
     chains.
-    One off: IQR_test, Grubbs_test,Mahal_test \cr
+    One of: IQR_test, Grubbs_test, Mahal_test \cr
     \code{pCR.Update} \tab \code{TRUE} \tab Whether to use adaptive tuning of crossover
     values \cr
     \code{boundHandling} \tab 'reflect' \tab Method used to handle parameter
@@ -64,10 +109,10 @@
     Frequent calculation is likely to slow performance. The summary
     function can use \code{\link{gelman.diag}} to calculate convergence statistic after completion
     \cr
-    \code{parallel} \tab multicore, snow, foreach \tab Character vector
+    \code{parallel} \tab \code{"none"} \tab Character vector
     of packages to
     use for parallelisation of function evaluations, in order of
-    preference. Set to \code{"none"} to not parallelise. For foreach, a backend must be registered from one of the doMC, doMPI,
+    preference. Options are \code{"multicore", "snow", "foreach"}. For foreach, a backend must be registered from one of the doMC, doMPI,
     doSNOW packages. \cr
     \code{ndraw} \tab  1e5 \tab Maximum number of function evaluations. May
     terminate before convergence. \cr
@@ -114,6 +159,9 @@
     1+length(pCR)}
   \item{in.burnin}{Boolean showing whether dream was in the burn-in
     period at termination (see description above)}
+  \item{fun.evals}{Total number of function evaluations.}
+  \item{time}{running time (wall time) in seconds.}
+  \item{EXITMSG}{a message about the stopping condition.}
 }
 
 \seealso{
@@ -128,15 +176,17 @@
   }
 
 \references{
-
-  Accelerating Markov Chain Monte Carlo Simulation by Differential Evolution with Self-Adaptive Randomized Subspace Sampling
-Jasper A. Vrugt, C.J.F. ter Braak, C.G.H. Diks, Bruce A. Robinson, James M. Hyman and Dave Higdon
- International Journal of Nonlinear Sciences and Numerical Simulation
- (in press 2009)
-
- Equifinality of formal (DREAM) and informal (GLUE)
-Bayesian approaches in hydrologic modeling?
-Jasper A. Vrugt, Cajo J. F. ter Braak, Hoshin V. Gupta, Bruce A. Robinson
-Stoch Environ Res Risk Assess (2009) 23:1011\2261026
-DOI 10.1007/s00477-008-0274-y
-  }
\ No newline at end of file
+  
+  Vrugt, J. A., ter Braak, C. J. F., Diks, C. G. H., Robinson, B. A.,
+  Hyman, J. M., Higdon, D., 2009. Accelerating markov chain monte carlo
+  simulation by differential evolution with self-adaptive randomized
+  subspace sampling. \emph{International Journal of Nonlinear Sciences
+  and Numerical Simulation} 10 (3), 273-290. 
+ 
+  Vrugt, J. A., Braak, C. J. F., Gupta, H. V., Robinson, B. A.,
+  2009. Equifinality of formal (DREAM) and informal (GLUE) Bayesian
+  approaches in hydrologic modeling?
+  \emph{Stochastic Environmental Research and Risk Assessment} 23 (7), 1011--1026. 
+  \url{http://dx.doi.org/10.1007/s00477-008-0274-y}
+  
+}



More information about the Dream-commits mailing list