predictInterval and the which option

Viewed 182
multi.sanctions.bust.full.ag <- glmer(allbuster ~ lageutradeshare100 + lnlaggdpp + lagtradeopenP  +                                        colonial + lagtradesharePT + lnlaggdpt  + duration + lndist + nobust +                                     nobustsq + nobustcb + (1 | partnercode) + (1 | caseid),
                                data=sanctions.data.new.scaled, family=binomial(link="logit"),
                                nAGQ=1,control=glmerControl(optimizer="nlminbwrap",
                                optCtrl=list(maxfun=2e5)))

I am working on a model (see the code above), and I have been using the predictInterval function to calculate the predicted probability and prediction intervals. I've gotten the function to work, but I am a bit confused about the "which" option:

plotdf_intraeu <- predictInterval(multi.sanctions.bust.full.ag, newdata = newData, type = "probability", 
            stat = "mean", n.sims = 10000, level = 0.90, which = "all", seed = 234)
plotdf_intraeu <- cbind(plotdf_intraeu, newData)

I've read the documentation and the vignette, but I am a little confused as to the which="all" option. I am not sure what the difference is between the four available options: full, fixed, random, or all. Is there a logic to which option I should use?

Could anyone provide a bit more of an explanation?

1 Answers

predictInterval is in the merTools package (it's worth specifying this when you're asking about functions that are not in the base/recommended packages). (glmer is in lme4, which is also extra, but is more widely used/better known.)

?predictInterval says:

By drawing a sampling distribution for the random and the fixed effects and then estimating the fitted value across that distribution, it is possible to generate a prediction interval for fitted values that includes all variation in the model except for variation in the covariance parameters, theta.

Thus

  • "fixed" means to incorporate only the uncertainty in the fixed-effect parameters;
  • "random" means to incorporate only the uncertainty due to the variation of random-effect groups around the population mean
  • "full" combines these two sources of uncertainty
  • "all" returns a data frame with all three of these values, with an additional column effect that can be "combined" (="full"), equal to any of the random-effects grouping variables (i.e. separating components due to different grouping variables in a model with more than one), or "fixed"

If include.resid.var is TRUE then the residual variance is also included in the uncertainty.

Related