pbkrtest (version 0.1.0)

PBrefdist: Calculate reference distribution using parametric bootstrap

Description

Calculate reference distribution of likelihood ratio statistic in mixed effects models using parametric bootstrap

Usage

PBrefdist(largeModel, smallModel, nsim = 200, cl = NULL, details = 0)
## S3 method for class 'mer':
PBrefdist(largeModel, smallModel, nsim = 200, cl = NULL, details = 0)

Arguments

largeModel
A linear mixed effects model as fitted with the lmer() function in the lme4 package. This model muse be larger than smallModel (see below).
smallModel
A linear mixed effects model as fitted with the lmer() function in the lme4 package. This model muse be smaller than largeModel (see above).
nsim
The number of simulations to form the reference distribution.
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.

Value

  • A numeric vector

See Also

PBmodcomp, makePBcluster, stopPBcluster, KRmodcomp

Examples

Run this code
data(beets)
head(beets)
beet0<-lmer(sugpct~block+sow+harvest+(1|block:harvest), data=beets, REML=FALSE)
beet_no.harv <- update(beet0, .~.-harvest)
rr <- PBrefdist(beet0, beet_no.harv, nsim=20)
rr

## Note clearly many more than 10 simulations must be made in practice.

## Computations can be made in parallel using several processors:
library(snow)
cl <- makeSOCKcluster(rep("localhost", 4))
clusterEvalQ(cl, library(lme4))
clusterSetupSPRNG(cl)
rr <- PBrefdist(beet0, beet_no.harv, nsim=20)
stopCluster(cl)
## Above, 4 cpu's are used and 5 simulations are made on each cpu.

Run the code above in your browser using DataLab