| PBmodcomp {pbkrtest} | R Documentation |
Model comparison of mixed models using parametric bootstrap methods.
PBmodcomp(largeModel, smallModel, nsim = 1000, ref = NULL, cl = NULL, details = 0)
largeModel |
A linear mixed effects model as fitted with the |
smallModel |
A linear mixed effects model as fitted with the |
nsim |
The number of simulations to form the reference distribution. |
ref |
Vector containing samples from the reference distribution. If NULL, this vector will be generated using PBrefdist(). |
cl |
A vector identifying a cluster; used for calculating the reference distribution using several cores. See examples below. |
details |
The amount of output produced. Mainly relevant for debugging purposes. |
Under the fitted hypothesis (i.e. under the fitted small model)
nsim samples of the likelihood ratio test statistic (LRT) are
generetated.
Then p-values are calculated as follows:
LRT: Assuming that LRT has a chi-square distribution.
PBtest: The fraction of simulated LRT-values that are larger or equal to the observed LRT value.
Bartlett: A Bartlett correction is of LRT is calculated from the mean of the simulated LRT-values
Gamma: The reference distribution of LRT is assumed to be a gamma distribution with mean and variance determined as the sample mean and sample variance of the simulated LRT-values.
This functionality is not thoroughly tested and should be used with care. Please do report bugs etc.
Søren Højsgaard sorenh@math.aau.dk
data(beets)
head(beets)
beet0<-lmer(sugpct~block+sow+harvest+(1|block:harvest), data=beets, REML=FALSE)
beet_no.harv <- update(beet0, .~.-harvest)
PBmodcomp(beet0, beet_no.harv, nsim=20)
## Not run:
(fmLarge <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy))
## removing Days
(fmSmall <- lmer(Reaction ~ 1 + (Days|Subject), sleepstudy))
anova(fmLarge, fmSmall)
PBmodcomp(fmLarge, fmSmall)
## The same test using a restriction matrix
L<-cbind(0,1)
PBmodcomp(fmLarge, L)
## Vanilla
PBmodcomp(beet0, beet_no.harv, nsim=1000)
## Simulate reference distribution separately:
refdist <- PBrefdist(beet0, beet_no.harv, nsim=1000)
PBmodcomp(beet0, beet_no.harv, ref=refdist)
## Do computations with multiple processors:
## Number of cores:
(nc <- detectCores())
## Create clusters
cl <- makeCluster(rep("localhost", nc))
## Then do:
PBmodcomp(beet0, beet_no.harv, cl=cl)
## Or in two steps:
refdist <- PBrefdist(beet0, beet_no.harv, nsim=1000, cl=cl)
PBmodcomp(beet0, beet_no.harv, ref=refdist)
## It is recommended to stop the clusters before quitting R:
stopCluster(cl)
## End(Not run)