Skip to contents

A fit is at the boundary (or singular) when the variance of one or more of its random terms is estimated at, or very close to, zero. This is common with phylogenetic models: for a term (1 | sp__), pglmm() fits both a phylogenetic term (1|sp__) and a non-phylogenetic one (1|sp), and the data often support only one of them, so the other is estimated at zero. Such a fit is not wrong, but the likelihood is maximized on the edge of the parameter space: the term could be dropped without changing the fit, and the usual chi-square reference of a likelihood ratio test of that variance is conservative (see pglmm_profile_LRT(); confint.communityPGLMM() gives a lower limit of zero).

Usage

pglmm_is_singular(x, tol = 1e-04)

Arguments

x

A model fitted by pglmm() or pglmm_compare().

tol

Tolerance: a term is at the boundary when its standard deviation is smaller than tol, relative to the residual standard deviation for gaussian models (on the scale of the link function for the other families). The default, 1e-4, is that of lme4::isSingular().

Value

pglmm_is_singular(): TRUE or FALSE, with the names of the terms at the boundary in the attribute "terms". Always FALSE for models fitted with bayes = TRUE, which have posterior distributions instead.

Details

pglmm() and pglmm_compare() show a message when the fit is at the boundary (with bayes = FALSE), as lme4::lmer() does; use options(phyr.boundary.message = FALSE) to turn it off.

Examples

set.seed(1)
phy <- ape::rcoal(30, tip.label = paste0("sp", 1:30))
d <- expand.grid(sp = phy$tip.label, site = paste0("s", 1:10))
d$y <- rnorm(10)[as.integer(d$site)] + rnorm(nrow(d)) # no variation among species
m <- pglmm(y ~ 1 + (1 | sp__) + (1 | site), data = d, cov_ranef = list(sp = phy))
#> boundary (singular) fit: the variance of 1|sp__ is (close to) zero; see ?pglmm_is_singular
pglmm_is_singular(m)
#> [1] TRUE
#> attr(,"terms")
#> [1] "1|sp__"