[Lme4-commits] r1610 - in pkg/lme4Eigen: R src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Feb 21 23:47:38 CET 2012
Author: bbolker
Date: 2012-02-21 23:47:38 +0100 (Tue, 21 Feb 2012)
New Revision: 1610
Modified:
pkg/lme4Eigen/R/lmer.R
pkg/lme4Eigen/src/optimizer.cpp
Log:
new 'verbose' scheme for Nelder-Mead
Modified: pkg/lme4Eigen/R/lmer.R
===================================================================
--- pkg/lme4Eigen/R/lmer.R 2012-02-21 18:27:26 UTC (rev 1609)
+++ pkg/lme4Eigen/R/lmer.R 2012-02-21 22:47:38 UTC (rev 1610)
@@ -132,8 +132,13 @@
devfun(reTrms$theta) # one evaluation to ensure all values are set
if (devFunOnly) return(devfun)
- if (verbose) control$iprint <- as.integer(verbose)
+ ## FIXME: this code is replicated in lmer/glmer/nlmer ...
+ ## it seems good to have it in R rather than C++ code but maybe it should go within Nelder_Mead() ??
+
+ control$iprint <- switch(as.character(min(verbose,3L)),
+ "0"=0, "1"=20,"2"=10,"3"=1)
+
lower <- reTrms$lower
xst <- rep.int(0.1, length(lower))
opt <- Nelder_Mead(devfun, x0=rho$pp$theta, xst=0.2*xst, xt=xst*0.0001,
@@ -322,7 +327,11 @@
parent.env(rho) <- parent.frame()
devfun <- mkdevfun(rho, 0L) # deviance as a function of theta only
if (devFunOnly && !nAGQ) return(devfun)
+
+
+ ## FIXME: why is bobyqa always used for preliminary fit? document??
control$iprint <- min(verbose, 3L)
+
opt <- bobyqa(rho$pp$theta, devfun, rho$lower, control=control)
rho$nAGQ <- nAGQ
if (nAGQ > 0L) {
@@ -345,6 +354,8 @@
bobyqa(c(rho$pp$theta, rho$beta0), devfun, rho$lower, control=control)
},
NelderMead = {
+ control$iprint <- switch(as.character(min(verbose,3L)),
+ "0"=0,"1"=20,"2"=10,"3"=1)
xst <- c(rep.int(0.1, length(rho$dpars)),
sqrt(diag(environment(devfun)$pp$unsc())))
Nelder_Mead(devfun, x0=with(environment(devfun), c(pp$theta, pp$beta0)),
@@ -409,9 +420,9 @@
rho$u0 <- rho$pp$u0
rho$beta0 <- rho$pp$beta0
rho$tolPwrss <- tolPwrss # Resetting this is intentional. The initial optimization is coarse.
-
-## FIXME: change this to something sensible for NelderMead
- control$iprint <- min(verbose, 3L)
+
+ control$iprint <- switch(as.character(min(verbose,3L)),
+ "0"=0,"1"=20,"2"=10,"3"=1)
lower <- rho$lower
xst <- rep.int(0.1, length(lower))
Modified: pkg/lme4Eigen/src/optimizer.cpp
===================================================================
--- pkg/lme4Eigen/src/optimizer.cpp 2012-02-21 18:27:26 UTC (rev 1609)
+++ pkg/lme4Eigen/src/optimizer.cpp 2012-02-21 22:47:38 UTC (rev 1610)
@@ -98,7 +98,7 @@
nm_status Nelder_Mead::newf(const Scalar& f) {
d_stop.incrEvals();
if (d_verb > 0 && (d_stop.ev() % d_verb) == 0)
- Rcpp::Rcout << "f = " << value() << " at " << d_x.adjoint() << std::endl;
+ Rcpp::Rcout << "(NM) " << d_stop.ev() << ": " << "f = " << value() << " at " << d_x.adjoint() << std::endl;
if (d_stop.forced()) return nm_forced;
if (f < d_minf) {
d_minf = f;
More information about the Lme4-commits
mailing list