Confidence interval for relative contribution of random effect variance
Dear all, based on Bens suggestion (and it has come up again in another post) I made a first try in using bootMer and boot.ci.
[... snip]
Now, apart from this aspect, can confint be tweaked to calculate not only the confidence interval of the 'raw' parameters but also for some function of the parameters? If not, do I need to move to an implementation using MCMC methods (MCMCglmm, Bugs-type of approaches, STAN or Laplaces-Demon) to reach my aim or do you have another (simpler) suggestion?
You can compute parametric bootstrap confidence intervals of any quantity you want by applying boot.ci() to the results of bootMer() (bootMer()'s second argument is the summary function, which you can define however you like). This is computationally expensive, though (even more expensive than MCMC-type computations).
Ok. The latter may not be such an issue. This sounds doable and I will be looking into it! (And I can report back on my success ...)
I first defined a function that calculates the quotient of the within-subject variance (given by the variable 'ID' in my typical models) relative to the summed within-subject variance (subject is on the highest nesting level in the nested random effects that I currently use):
withinVar.fn <- function (mer.obj, subj= 'ID') {
vars <- as.data.frame (VarCorr (mer.obj))
vars [vars [, 'grp'] == subj, 'vcov'] / sum (vars [vars [, 'grp'] != subj, 'vcov'])
}
Then you can run the bootstrap and calculate the confidence interval:
HHbT.boot <- bootMer (HHbT.fin.lmer, withinVar.fn, nsim= 1000, parallel= 'multicore', ncpus= 2)
boot.ci (HHbT.boot, type= 'perc')
I was a bit worried about the distribution of my variable of interest being a quotient and also tried log-ing the division. At least in this example, the distribution seems even worse with the transformation and the results of the percentile confidence interval using the non-transformed quotient seems to give quite reasonable results.
Any hints to where I may have been (too) na?ve in my approach are appreciated.
Many thanks again. Regards, Lorenz