9
$\begingroup$

I am dealing with a multilevel model with gaussian error distribution that has ~21,000 observations and 5000 clusters. The model is of the simple form:

lmer(y ~ a + b + a:b + (1|z), weights=b)

and has weights applied in proportion to the variable b.

The behavior I'm encountering occurs when calculating confidence intervals of the fixed effects parameters with the following:

confint(mod, method="Wald")
confint(mod, method="profile") 
confint(mod1, method="boot", nsim=1000, parm="beta_")

The results from bootstrapping give confidence intervals that are ~3 times wider than the Wald results. The profile results throw a number of warnings such as:

1: In profile.merMod(object, which = parm, signames = oldNames, ...) : non-monotonic profile for (Intercept)

6: In confint.thpr(pp, level = level, zeta = zeta) : bad spline fit for (Intercept): falling back to linear interpolation

I have searched through many old threads that compare these methods, and I do expect the results from these methods to be different. However previous posts (and my own experience) suggests that usually these methods produce results that are not quite so far apart. I am looking for some intuition as to why this might occur and whether I am right to think that the bootstrapped results are probably more realistic (I suppose this means I should be skeptical of the SEs reported in summary() as well?).

I apologize for not providing a reproducible example, as I am not able to share the original data and my attempts to simulate the same issue only lead to situations in which the Wald and bootstrapped CIs were similar.

EDIT: Plot of profile:

enter image description here

Edit #2: In response to Ben Bolker's comment below, the following code (stolen from elsewhere on the internet) simulates data for a mixed model and demonstrates that confint(..., method="profile") fails when weights are included as well as some differences in CIs from the different methods.

library(mvtnorm)
set.seed(2345)

N <- 150
unit.df <- data.frame(unit = c(1:N), a = rnorm(N))
unit.df <-  within(unit.df, {
  E.alpha.given.a <-  1 - 0.15 * a
  E.beta.given.a <-  3 + 0.3 * a
})

q = 0.2
r = 0.9
s = 0.5
cov.matrix <- matrix(c(q^2, r * q * s, r * q * s, s^2), nrow = 2,
                     byrow = TRUE)
random.effects <- rmvnorm(N, mean = c(0, 0), sigma = cov.matrix)
unit.df$alpha <- unit.df$E.alpha.given.a + random.effects[, 1]
unit.df$beta <- unit.df$E.beta.given.a + random.effects[, 2]

J <- 300
M = J * N  #Total number of observations
x.grid = seq(-4, 4, by = 8/J)[0:30]
within.unit.df <-  data.frame(unit = sort(rep(c(1:N), J)), j = rep(c(1:J),N), x =rep(x.grid, N))
flat.df = merge(unit.df, within.unit.df)

flat.df <-  within(flat.df, y <-  alpha + x * beta + 0.75 * rnorm(n = M))
simple.df <-  flat.df[, c("unit", "a", "x", "y")]
simple.df$wht <- rpois(n = dim(simple.df)[1], lambda = 5)+1

my.lmer <-  lmer(y ~ x + a + x * a + wht + (1 | unit), data = simple.df, weights = wht)
summary(my.lmer)

confint(my.lmer, method="Wald")
confint(my.lmer, method="profile")
confint(my.lmer, method="boot", nsim=100)

$\endgroup$
15
  • $\begingroup$ Would it be appropriate to cross-post after already posting here? Plotting the profiles yields the following output: $\endgroup$
    – TKraft
    Commented Jan 15, 2020 at 15:51
  • 1
    $\begingroup$ OK, I should have been more clear about the plotting. pp <- profile(mod); lattice::xyplot(pp) (you'll want to save the profile object, as it's pretty slow to compute) $\endgroup$
    – Ben Bolker
    Commented Jan 15, 2020 at 16:09
  • 1
    $\begingroup$ I actually tried that first using code from one of your posts, but got the following error: "Error in data.frame(y = r[[".zeta"]], x = r[[n]]) : arguments imply differing number of rows: 49, 0 " -- the other plotting methods for class "thpr" objects also throw errors. Any advice? $\endgroup$
    – TKraft
    Commented Jan 15, 2020 at 16:20
  • 1
    $\begingroup$ That worked. Does it seems like something is going wonky near the boundaries? $\endgroup$
    – TKraft
    Commented Jan 15, 2020 at 16:59
  • 1
    $\begingroup$ As long as the simulation code is not horribly long, editing your question to include it would be great. If it is super-long, maybe post it elsewhere (as a gist or something) and link to it ... $\endgroup$
    – Ben Bolker
    Commented Jan 16, 2020 at 18:53

1 Answer 1

3
$\begingroup$

Basically, the Wald statistic is not good and you shouldn't trust it for mixed models. It uses a much cruder approximation to the actual likelihood than you get with the profile and boot.ci methods. If R (and SAS and JMP and...) would have been written today, they would not have bothered implementing Wald stats. That's why the summary.merMod method intentionally omits $p$-values from the fixed effect coefficient output. The computational intensity of profile/bootstrap is at most on the scale of minutes by today's standards, but in the olden days, it would take weeks. So, the analyst was expected to do massive amounts of testing and variable transformation methods so that Wald stat might have good-ish properties.

EDIT: below is a snippet of a conversation between me, David Dahl, and Douglas Bates back in 2010 when I tried to suggest using the Wald $p$-values for xtable.

A user of your lme4 package would like to use xtable on mer objects from lme4. That means defining a function "xtable.mer". He suggests the implementation below. I regrettably am not very familar with lme4. Do you have any suggestions?

I appreciate Adam's suggestion and his providing an implementation. Regrettably, I think that the implementation would be controversial, to say the least, and I would prefer not to be the recipient of the fallout. There is a long-standing issue with lme4 regarding p-values on tests of the fixed-effects parameters. For linear mixed models there is a widespread belief that you can calculate a t-statistic (what is labelled here as a "z value") and convert it to a p-value by the simple expedient of determining an approximate number of degrees of freedom. In fact, SAS PROC MIXED offers several (6, I believe) different, and incompatible, ways of determining such degrees of freedom and the corresponding p-values. The fact that these give different answers doesn't deter people from regarding such approximations as "absolute truth".

In reality the distribution of such a statistic is not a Student's T. It is much more complicated than that and I advocate other ways of calculating confidence intervals or testing hypotheses. In the case of a generalized linear mixed model I do calculate a p-value from the standard normal distribution, not because the approximation is better for GLMMs than for LMMs but because it is worse.

I am writing a book for Springer on lme4 (chapter drafts are available at http://lme4.R-forge.R-project.org/book/) where I describe using likelihood ratio tests for hypothesis tests and techniques based on profiling the LRT statistic to produce confidence intervals on parameters. The examples in that book are based on the development version of the package which uses a different representation of the model. The implementation is not complete, which is why I haven't released it as lme4, but right now I need to concentrate on the writing because the book is going to be used in a seminar which starts next week.

$\endgroup$
7
  • 2
    $\begingroup$ I don't really agree with this. It's true that Wald statistics are inferior to profile and parametric bootstrap statistics, but they're orders of magnitude faster, and in many cases they're good enough. (Typically better for fixed effects than for random-effects parameters [variances & covariances]; for REs they're better on log than on linear scales ... all other things being equal, they're better for larger data sets, which is exactly when you need speed) The trick is knowing when. $\endgroup$
    – Ben Bolker
    Commented Jan 16, 2020 at 1:55
  • 3
    $\begingroup$ And ... summary.merMod omits p-values because denominator dfs are hard, not because Wald intervals are bad. The standard errors quoted in summary are exactly Wald-type estimates ... $\endgroup$
    – Ben Bolker
    Commented Jan 16, 2020 at 1:57
  • $\begingroup$ In relation to this last comment: is there an obvious way to get bootstrapped or profile SEs rather than Wald SEs reported in summary? It's not exactly clear to me why Doug Bates did not want the Wald SEs omitted for the same reason as the p-values. $\endgroup$
    – TKraft
    Commented Jan 16, 2020 at 18:31
  • $\begingroup$ @BenBolker hmm, can you link a reference on denominator dfs? Curious to patch up any misunderstanding on my part. $\endgroup$
    – AdamO
    Commented Jan 16, 2020 at 19:04
  • 1
    $\begingroup$ @TKraft I think what you are looking for is the confint.merMod() function in the lme4 package. $\endgroup$
    – EdM
    Commented Jan 16, 2020 at 19:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.