David Reitter
2013-11-08 20:21:37 UTC
Hi all,
The latest versions of the popular 'lme4' package no longer provide an MCMC sampling function to generate p-values and confidence intervals. You may recall that this was problematic with any bot the most basic random effects structures anyway, and lme4 authors point to random effects with low variance as the culprit. If you use languageR to do your MCMC sampling ("pvals.fnc"), you are affected.
One of their suggestions is to use parametric bootstrapping via "bootMer".
I would like to run the code below by you. Questions: shouldn't the "mySumm2" function just return the fixed effects as the statistic of interest? (This was somewhat blindly taken from the bootMer documentation). I then calculate the t value on the fixed effects models and read a p value from the t distribution. I'm surprised there is no function provided - so, are there any caveats?
Thanks,
David
# straight from the bootMer documentation
mySumm2 <- function(.) {
c(beta=fixef(.),sigma=sigma(.),sig01=unlist(VarCorr(.)))
}
# calculate prob for one-tailed t distribution from sample SAMP
# assuming the effect is in the predicted direction
dr.tfun = function (samp) {pt((mean(samp)-0)/(sd(samp)/sqrt(length(samp))), length(samp)-1, lower.tail=(mean(samp)<0))}
# print P values [and more, without labels - fixme]
dr.boot.print = function (boot) { # print prob
for (row in as.data.frame(boot)) {print(dr.tfun(row))}
}
# bootstrap an lmer or glmer model
dr.bootstrap = function (model) {
# bootstrap, fixed nsim
bm = bootMer(model, mySumm2, nsim=20, .progress="txt")
dr.boot.print(bm);
return(bm)
}
The latest versions of the popular 'lme4' package no longer provide an MCMC sampling function to generate p-values and confidence intervals. You may recall that this was problematic with any bot the most basic random effects structures anyway, and lme4 authors point to random effects with low variance as the culprit. If you use languageR to do your MCMC sampling ("pvals.fnc"), you are affected.
One of their suggestions is to use parametric bootstrapping via "bootMer".
I would like to run the code below by you. Questions: shouldn't the "mySumm2" function just return the fixed effects as the statistic of interest? (This was somewhat blindly taken from the bootMer documentation). I then calculate the t value on the fixed effects models and read a p value from the t distribution. I'm surprised there is no function provided - so, are there any caveats?
Thanks,
David
# straight from the bootMer documentation
mySumm2 <- function(.) {
c(beta=fixef(.),sigma=sigma(.),sig01=unlist(VarCorr(.)))
}
# calculate prob for one-tailed t distribution from sample SAMP
# assuming the effect is in the predicted direction
dr.tfun = function (samp) {pt((mean(samp)-0)/(sd(samp)/sqrt(length(samp))), length(samp)-1, lower.tail=(mean(samp)<0))}
# print P values [and more, without labels - fixme]
dr.boot.print = function (boot) { # print prob
for (row in as.data.frame(boot)) {print(dr.tfun(row))}
}
# bootstrap an lmer or glmer model
dr.bootstrap = function (model) {
# bootstrap, fixed nsim
bm = bootMer(model, mySumm2, nsim=20, .progress="txt")
dr.boot.print(bm);
return(bm)
}
--
Dr. David Reitter
Assistant Professor of Information Sciences and Technology
Penn State University
http://www.david-reitter.com
Dr. David Reitter
Assistant Professor of Information Sciences and Technology
Penn State University
http://www.david-reitter.com