Dear all,

I have an issue with update.merMod function. I would like to call it within a function and to send some extra parameters to it.
The code below fails with an error:

updateModel <- function(model, reml, l)
{

  nfit <- update(object=model, formula.=as.formula(paste(".~."))
                 , REML=reml ,contrasts=l, evaluate=FALSE)
  env <- environment(formula(model))
  nfit <- eval(nfit, envir = env)
  #nfit <- eval.parent(nfit)
  #nfit <- eval(nfit, parent.frame())
}


m <- lmer(Reaction ~ Days +(1|Subject), data=sleepstudy)
updateModel(m, FALSE, "contr.SAS")

Error in model.matrix.default(fixedform, fr, contrasts) : object 'l' not found

eval.parent(nfit) fails as well.


If I use evaluate=TRUE, then there is no problem, but I need to use evaluate=FALSE


> sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=Danish_Denmark.1252  LC_CTYPE=Danish_Denmark.1252    LC_MONETARY=Danish_Denmark.1252 LC_NUMERIC=C
[5] LC_TIME=Danish_Denmark.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] lme4_1.1-2   Matrix_1.1-0

loaded via a namespace (and not attached):
[1] grid_3.0.2        lattice_0.20-23   MASS_7.3-29       minqa_1.2.1       nlme_3.1-111      numDeriv_2012.9-1 splines_3.0.2
[8] tools_3.0.2



Is there some way to overcome this problem/bug?



Thank you in advance for any suggestion!

With best regards,
Alexandra

	[[alternative HTML version deleted]]

