# PBmodcomp

##### Model comparison of mixed models using parametric bootstrap methods.

Model comparison of mixed models using parametric bootstrap methods.

##### Usage

```
PBmodcomp(largeModel, smallModel, nsim = 200, ref = NULL, cl = NULL, details = 0)
## S3 method for class 'mer':
PBmodcomp(largeModel, smallModel, nsim = 200, ref = NULL, cl = NULL, details = 0)
makePBcluster(n=2)
stopPBcluster()
```

##### Arguments

- largeModel
- A linear mixed effects model as fitted with the
`lmer()`

function in thelme4 package. This model muse be larger than`smallModel`

(see below). - smallModel
- A linear mixed effects model as fitted with the
`lmer()`

function in thelme4 package. This model muse be smaller than`largeModel`

(see above). - 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.
- n
- Number of clusters to be used in computations; a typical choice of
`n`

would be the number of CPUs available. - details
- The amount of output produced. Mainly relevant for debugging purposes.

##### Details

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.

##### Note

This functionality is not thoroughly tested and should be used with care. Please do report bugs etc.

##### See Also

##### Examples

```
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)
## Vanilla
PBmodcomp(beet0, beet_no.harv)
## Simulate reference distribution separately:
rr <- PBrefdist(beet0, beet_no.harv, nsim=20)
PBmodcomp(beet0, beet_no.harv, ref=rr)
```

*Documentation reproduced from package pbkrtest, version 0.1.0, License: GPL (>= 2)*