Title: Partitioning R2 in GLMMs
Version: 0.9.2
Depends: R (≥ 3.5.0)
Description: Partitioning the R2 of GLMMs into variation explained by each predictor and combination of predictors using semi-partial (part) R2 and inclusive R2. Methods are based on the R2 for GLMMs described in Nakagawa & Schielzeth (2013) and Nakagawa, Johnson & Schielzeth (2017).
License: GPL-2 | GPL-3 [expanded from: GPL (≥ 2)]
URL: https://github.com/mastoffel/partR2
BugReports: https://github.com/mastoffel/partR2/issues
Imports: methods, stats, lme4 (≥ 1.1-21), pbapply (≥ 1.4-2), dplyr (≥ 1.0.0), purrr (≥ 0.3.3), rlang (≥ 0.4.2), tibble (≥ 2.1.3), magrittr (≥ 1.5), ggplot2 (≥ 3.3.0), tidyr (≥ 1.1)
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.2.3
Suggests: testthat, future, furrr, knitr, rmarkdown, patchwork, covr
VignetteBuilder: knitr
NeedsCompilation: no
Packaged: 2024-03-04 13:03:24 UTC; mstoffel
Author: Martin A. Stoffel [aut, cre], Shinichi Nakagawa [aut], Holger Schielzeth [aut]
Maintainer: Martin A. Stoffel <martin.adam.stoffel@gmail.com>
Repository: CRAN
Date/Publication: 2024-03-04 13:20:02 UTC

partR2: Partitioning R2 in generalized linear mixed models

Description

The partR2 package provides a simple way to estimate R2 in mixed models fitted with lme4 as well as part (semi-partial) R2 for specific predictors and combinations of predictors, among other several other statistics. Here is an overview:

Details

The package has one main function partR2 which takes a fitted model from lme4. At the moment, Gaussian, Poisson and binomial models are supported. For Poisson and non-binary binomial models, partR2 adds an observational level random effect to model additive overdispersion (if an olre is not fitted already).

The summary.partR2 function provides an extended summary with R2s, semi-partial R2s, model estimates and structure coefficients. The forestplot function provides a means of plotting the results.

References

Nakagawa, S., & Schielzeth, H. (2013). A general and simple method for obtaining R2 from generalized linear mixed-effects models. Methods in Ecology and Evolution, 4(2), 133-142.

Nakagawa, S., Johnson, P. C., & Schielzeth, H. (2017). The coefficient of determination R2 and intra-class correlation coefficient from generalized linear mixed-effects models revisited and expanded. Journal of the Royal Society Interface, 14(134), 20170213.


Pipe operator

Description

See magrittr::%>% for details.

Usage

lhs %>% rhs

BeetlesBody dataset

Description

BeetlesBody dataset

Details

This is an simulated dataset which was used as a toy example for a different purpose (Nakagawa & Schielzeth 2013). It offers a balanced dataset with rather simple structure, sizable effects and decent sample size, just right for demonstrating some features of partR2. Sufficient sample size is required in particular for the non-Gaussian traits, because those tend to be more computationally demanding and less rich in information per data point than simple Gaussian traits.

In brief the imaginary sampling design of the simulated dataset is as follows. Beetle larvae were sampled from 12 populations ('Population') with samples taken from two discrete microhabitats at each location ('Habitat'). Samples were split in equal proportion and raised in two dietary treatments ('Treatment'). Beetles were sexed at the pupal stage ('Sex') and pupae were kept in sex-homogeneous containers ('Container'). The phenotype in this dataset is body length ('BodyL').

References

Nakagawa, S. & Schielzeth, H. (2013) A general and simple method for obtaining R2 from generalized linear mixed-effects models. Methods in Ecology and Evolution 4: 133-142.


BeetlesFemale dataset

Description

BeetlesFemale dataset

Details

This is an simulated dataset which was used as a toy example for a different purpose (Nakagawa & Schielzeth 2013). It offers a balanced dataset with rather simple structure, sizable effects and decent sample size, just right for demonstrating some features of partR2. Sufficient sample size is required in particular for the non-Gaussian traits, because those tend to be more computationally demanding and less rich in information per data point than simple Gaussian traits.

In brief the imaginary sampling design of the simulated dataset is as follows. Beetle larvae were sampled from 12 populations ('Population') with samples taken from two discrete microhabitats at each location ('Habitat'). Samples were split in equal proportion and raised in two dietary treatments ('Treatment'). Beetles were sexed at the pupal stage ('Sex') and pupae were kept in sex-homogeneous containers ('Container'). The phenotype in this dataset is the number of eggs laid by female beetles ('Egg').

References

Nakagawa, S. & Schielzeth, H. (2013) A general and simple method for obtaining R2 from generalized linear mixed-effects models. Methods in Ecology and Evolution 4: 133-142.


BeetlesMale dataset

Description

BeetlesMale dataset

Details

This is an simulated dataset which was used as a toy example for a different purpose (Nakagawa & Schielzeth 2013). It offers a balanced dataset with rather simple structure, sizable effects and decent sample size, just right for demonstrating some features of rptR. Sufficient sample size is required in particular for the non-Gaussian traits, because those tend to be more computationally demanding and less rich in information per data point than simple Gaussian traits.

In brief the imaginary sampling design of the simulated dataset is as follows. Beetle larvae were sampled from 12 populations ('Population') with samples taken from two discrete microhabitats at each location ('Habitat'). Samples were split in equal proportion and raised in two dietary treatments ('Treatment'). Beetles were sexed at the pupal stage ('Sex') and pupae were kept in sex-homogeneous containers ('Container'). The phenotype in this dataset is a binary variable containing the two distinct color morphs of males: dark and reddish-brown ('Colour').

References

Nakagawa, S. & Schielzeth, H. (2013) A general and simple method for obtaining R2 from generalized linear mixed-effects models. Methods in Ecology and Evolution 4: 133-142.


Grasshoppers dataset

Description

Grasshoppers dataset

Details

This is a real dataset from grasshoppers.

This dataset contains data on spatial variation in color morph ratios in a color-polymorphic species of grasshopper (Dieker et al 2018). Individuals of this species occur either in green or a brown color variant and the dataset contains counts of brown and green individuals (seprarated for females and males) from 42 sites sampled in the field. All 'Bio' variables describe various aspects of ecologically relevant climatic conditions (see Karger et al. 2017).

References

Dieker, P., L. Beckmann, J. Teckentrup, and H. Schielzeth (2018) Spatial analyses of two colour polymorphisms in an alpine grasshopper reveal a role of small-scale heterogeneity. Ecology and Evolution, 8, 7273-7284.

Karger, D. N., O. Conrad, J. Bohner, T. Kawohl, H. Kreft, R. W. Soria-Auza, N. E. Zimmermann, H. P. Linder, and M. Kessler (2017) Data descriptor: Climatologies at high resolution for the earth's land surface areas. Scientific Data, 4, 170122.


GuineaPigs dataset

Description

GuineaPigs dataset

Details

This is a real dataset from guinea pigs.

The dataset contains testosterone measurements ('Testo') of 31 male guinea pigs, each measured at 5 time points. (age between 120 and 240 days at 30-day intervals). As covariates the dataset contains the time point of measurement ('Time') and a rank index derived from behavioral observations ('Rank') around the time of measurement (see Mutwill et al. in prep. for details).


Calculate R2

Description

Calculate R2

Usage

R2_pe(mod, expct, overdisp_name, R2_type)

Arguments

mod

merMod object

expct

Expectation

overdisp_name

Name of overdispersion term

R2_type

"marginal" or "conditional"

Value

data.frame with one element, R2


Structure coefficients

Description

Structure coefficients

Usage

SC_pe(mod)

Arguments

mod

merMod object.

Value

data.frame with structure coefficients


Adds columns for CI

Description

Adds columns for CI

Usage

add_CI_cols(df)

Arguments

df

data.frame with point estimates

Value

data.frame with two additional columns for lower and upper CI containing NAs


biomass dataset

Description

biomass dataset

Details

This is an simulated dataset about grassland biodiversity and biomass.

In brief the imaginary sampling design of the simulated dataset is as follows. Invertebrates were sampled once every year over 10 successive years ('Year') from 20 different populations ('Population'). For each sample, the temperature ('Temperature') and ('Precipitation') were measured and overall species diversity ('SpeciesDiversity') and biomass were recorded ('Biomass').


List to data.frame with bootstrap samples per row

Description

List to data.frame with bootstrap samples per row

Usage

boot_to_df(lcol)

Arguments

lcol

A bootstrap list-column

Value

data.frame with bootstrap estimates as list-column


Parametric bootstrapping

Description

Parametric bootstrapping

Usage

bootstrap_all(
  nboot,
  mod,
  R2_type,
  all_comb,
  partition,
  data_mod,
  allow_neg_r2,
  parallel,
  expct,
  overdisp_name
)

Arguments

nboot

Number of parametric bootstrap iterations for confidence interval estimation (defaults to NULL, i.e. no bootstrapping). Larger numbers of bootstraps give a better asymptotic CI, but may be time-consuming. Bootstrapping can be switched on by setting nboot = 1000.

mod

merMod object, lme4 fit

R2_type

"marginal" or "conditional" R2. With "marginal", the variance explained by fixed effects is calculated. With "conditional", the variance explained by both fixed and random effects is calculated.

all_comb

list of predictor combinations

partition

TRUE or FALSE

data_mod

Data for model

allow_neg_r2

Calculating part R2 involves fitting two models, one with and one without the predictor of interest. In cases where the predictor has little association with the response, the resulting part R2 value can become negative. By default we set negative values to 0, but by setting this parameter to TRUE, R2 values can become negative.

parallel

If TRUE, computation uses future within furrr::map which allows parallelisation. However, it is necessary to specify a plan before running partR2(). To see which options you have, check ?future::plan and have a look at our vignette for details. When running RStudio, usually plan(multisession, workers = 4) is a good choice, when you want to use 4 cores. To detect how many cores you have, use parallel::detectCores(). If no plan is specified, partR2 will simply run sequentially.

expct

A string specifying the method for estimating the expectation in Poisson models with log link and in Binomial models with logit link (in all other cases the argument is ignored). The only valid terms are 'meanobs', 'latent', 'none' (and 'liability for binary and proportion data). With the default 'meanobs', the expectation is estimated as the mean of the observations in the sample. With 'latent', the expectation is estimated from estimates of the intercept and variances on the link scale. While this is a preferred solution, it is susceptible to the distribution of fixed effect covariates and gives appropriate results typically only when all covariances are centered to zero. With 'liability' estimates follow formulae as presented in Nakagawa & Schielzeth (2010). With 'none', R2 is calculated without distribution specific variance in the denominator.

overdisp_name

Name of overdispersion term

Value

Bootstrap samples for all statistics, plus associated warnings


Calculates CI from bootstrap replicates

Description

Calculates CI from bootstrap replicates

Usage

calc_CI(x, CI)

Arguments

x

numeric vector

CI

CI level, e.g. 0.95

Value

data.frame with two columns for lower and upper CI


Get tidy summary of fixed effect estimates

Description

Get tidy summary of fixed effect estimates

Usage

fixef_simple(mod, intcp = FALSE)

Arguments

mod

merMod object

intcp

include intercept in summary? Defaults to FALSE

Value

tibble with two columns: term and estimate


Calculate fixed effect variance from a reduced model

Description

Calculate fixed effect variance from a reduced model

Usage

fixvar_of_red_mod(partvar, mod, dat, expct, overdisp_name, R2_type)

Arguments

partvar

One or more fixed effect variables which are taken out of the model.

mod

merMod object.

dat

Data.frame to fit the model

expct

Expectation

overdisp_name

Name of overdispersion term

R2_type

"marginal" or "conditional"

Value

R2 of reduced model.


Plot a partR2 object

Description

Forestplot of the partR2 results

Usage

forestplot(
  x,
  type = c("R2", "BW", "SC", "IR2", "Ests"),
  line_size = 0.5,
  text_size = 12,
  point_size = 3
)

Arguments

x

A partR2 object.

type

Plot either "R2" or "SC" or "Ests" for R2s, structure coefficients or model estimates.

line_size

Controls size of all lines in the forestplot. Defaults to 0.5 which usually looks good.

text_size

Base text size, default is 12.

point_size

Point size, default is 3.


Get beta weights

Description

Get beta weights

Usage

get_bw(mod)

Arguments

mod

merMod object.

Value

data.frame with bw instead of raw estimates


Get numerator dfs for reduced models

Description

Get numerator dfs for reduced models

Usage

get_ndf(partvar, mod, dat)

Arguments

partvar

One or more fixed effect variables which are taken out of the model.

mod

merMod object.

dat

Data.frame to fit the model

Value

Numeric vector, giving numerator degrees of freedom


Extracts random effect variances

Description

This function computes the sum of random effect variances where one or more of the random effects are random slopes. It uses Paul Johnson' method to compute the average group variance across the levels of a covariate. This function extracts only grouping factors, no residual or overdispersion.

Usage

get_ran_var(mod, overdisp_name = NULL)

Arguments

mod

An lme4 model object.

overdisp_name

name of overdispersion term


Extract variance components from merMod.

Description

Extract variance components from merMod.

Usage

get_var_comps(mod, expct, overdisp_name)

Arguments

mod

A merMod object.

expct

expectation.

overdisp_name

name of overdispersion term

Value

Fixed, random and residual variance


Create list of combination of variables.

Description

Create list of combination of variables.

Usage

make_combs(partvars, partbatch, max_level)

Arguments

partvars

Character vector specifying the predictors (fixed effects) for which to partition the R2. Can be main effects like c("Var1", "Var2") and interactions ("Var1:Var2"). Predictors specified in partvars have to be named precisely like the terms in the formula to fit the model.

partbatch

List of character vectors with predictors that should be fitted and removed together. For example, partbatch = list(batch1 = c("V1", "V2", "V3"), batch2 = c("V4", "V5", "V6")) would calculate part R2 only for combinations of predictors which contain the variables V1, V2, V3 together or/and V4,V5,V6 together. This is useful when the number of potential subsets gets too large to be computationally practical, for example when dummy coding is used. See our vignette for details. This feature is still experimental and should be used with caution.

max_level

Level up to which shared semi-partial R2s are calculated. The number of sets for which to calculate R2 increases exponentially, i.e. for 10 variables 2^10 - 1 R2s can be calculated. If you are only interested in the unique but not the shared effects, use max_level = 1. If interested in unique effects and combinations of two terms, use max_level = 2 etc.

Value

list with all combinations of predictors specified in partvars/partbatch


Merge partR2 objects to combine R2s for main effects and interactions

Description

The function merges partR2 object based on a full model with interactions with a partR2 object based on a reduced model without interaction. The reduced model is used to infer main effect semi-partial R2s. This function essentially takes over the complete partR2 object for the full model and adds semi-partial R2s which have been calculated based on the reduced model and are not already present in the full model partR2 object (which can be main effects). The function also combines the bootstrap estimates, accessible with partR2_obj$R2_boot.

Usage

mergeR2(R2_full, ...)

Arguments

R2_full

partR2 object for the full model, with the interaction (but not the main effects) in partvars.

...

other partR2 objects, which do not contain the interaction so that the semi-partial R2s for the main effects could be calculated.

Details

This function is experimental and should be used with caution. See vignette or paper on how to use it to obtain semi-partial R2s for main effects which are also involved in interactions.

Value

Returns an object of class partR2, which takes most components from the full model except for semi-partial R2s.

Examples


data(biomass)
library(lme4)

# scale data
biomass[] <- lapply(biomass, function(x) if (is.double(x)) scale(x) else x)

# Full model
mod_full <- lmer(Biomass ~  Year + Temperature * Precipitation + SpeciesDiversity + (1|Population),
            data = biomass)
# Semi-partial R2 for interaction and all other predictors of interest
(R2_full <- partR2(mod_full, partvars = c("Temperature:Precipitation", "SpeciesDiversity", "Year"),
data = biomass))

# model without interaction to get main effect semi-partial R2s
mod_noIA <- lmer(Biomass ~  Year + Temperature + Precipitation + SpeciesDiversity + (1|Population),
            data = biomass)
(R2_noIA <- partR2(mod_noIA, partvars = c("Temperature", "Precipitation"), data = biomass))

# combine both
(R2_comb <- mergeR2(R2_full, R2_noIA))


Modify term names if partbatch is a named list

Description

Modify term names if partbatch is a named list

Usage

mod_names_partbatch(partbatch, part_names)

Arguments

partbatch

list with batches

part_names

character vector with names of terms (and their combinations)

Value

Modified names for partvars, where partvar combinations are replaced with partbatch names.


Adds an observational level random effect to a model, if applicable.

Description

Adds an observational level random effect to a model, if applicable.

Usage

model_overdisp(mod, dat, olre)

Arguments

mod

merMod object.

dat

The underlying data.frame

Value

list with three elements: merMod object with added OLRE, data.frame with added OLRE variable, and name of OLRE.


Partitioning R2 (R-square) in mixed models

Description

R2, semi-partial (part) R2 for predictors and their combinations as well as inclusive R2, structure coefficients and beta weights for Gaussian, Poisson and binomial mixed models.

Usage

partR2(
  mod,
  partvars = NULL,
  data = NULL,
  R2_type = "marginal",
  max_level = NULL,
  nboot = NULL,
  CI = 0.95,
  parallel = FALSE,
  expct = "meanobs",
  olre = TRUE,
  partbatch = NULL,
  allow_neg_r2 = FALSE
)

Arguments

mod

Fitted lme4 model (a merMod object).

partvars

Character vector specifying the predictors (fixed effects) for which to partition the R2. Can be main effects like c("Var1", "Var2") and interactions ("Var1:Var2"). Predictors specified in partvars have to be named precisely like the terms in the formula to fit the model.

data

The data.frame used to fit the lme4 model. If not provided, partR2 will try to fetch it.

R2_type

"marginal" or "conditional" R2. With "marginal", the variance explained by fixed effects is calculated. With "conditional", the variance explained by both fixed and random effects is calculated.

max_level

Level up to which shared semi-partial R2s are calculated. The number of sets for which to calculate R2 increases exponentially, i.e. for 10 variables 2^10 - 1 R2s can be calculated. If you are only interested in the unique but not the shared effects, use max_level = 1. If interested in unique effects and combinations of two terms, use max_level = 2 etc.

nboot

Number of parametric bootstrap iterations for confidence interval estimation (defaults to NULL, i.e. no bootstrapping). Larger numbers of bootstraps give a better asymptotic CI, but may be time-consuming. Bootstrapping can be switched on by setting nboot = 1000.

CI

Width of the required confidence interval between 0 and 1 (defaults to 0.95).

parallel

If TRUE, computation uses future within furrr::map which allows parallelisation. However, it is necessary to specify a plan before running partR2(). To see which options you have, check ?future::plan and have a look at our vignette for details. When running RStudio, usually plan(multisession, workers = 4) is a good choice, when you want to use 4 cores. To detect how many cores you have, use parallel::detectCores(). If no plan is specified, partR2 will simply run sequentially.

expct

A string specifying the method for estimating the expectation in Poisson models with log link and in Binomial models with logit link (in all other cases the argument is ignored). The only valid terms are 'meanobs', 'latent', 'none' (and 'liability for binary and proportion data). With the default 'meanobs', the expectation is estimated as the mean of the observations in the sample. With 'latent', the expectation is estimated from estimates of the intercept and variances on the link scale. While this is a preferred solution, it is susceptible to the distribution of fixed effect covariates and gives appropriate results typically only when all covariances are centered to zero. With 'liability' estimates follow formulae as presented in Nakagawa & Schielzeth (2010). With 'none', R2 is calculated without distribution specific variance in the denominator.

olre

Logical, defaults to TRUE. This argument allows the user to prevent the automatic fitting of an observation level random effect (by setting it to FALSE) in Poisson and binomial models. The OLRE is used to account for overdispersion.

partbatch

List of character vectors with predictors that should be fitted and removed together. For example, partbatch = list(batch1 = c("V1", "V2", "V3"), batch2 = c("V4", "V5", "V6")) would calculate part R2 only for combinations of predictors which contain the variables V1, V2, V3 together or/and V4,V5,V6 together. This is useful when the number of potential subsets gets too large to be computationally practical, for example when dummy coding is used. See our vignette for details. This feature is still experimental and should be used with caution.

allow_neg_r2

Calculating part R2 involves fitting two models, one with and one without the predictor of interest. In cases where the predictor has little association with the response, the resulting part R2 value can become negative. By default we set negative values to 0, but by setting this parameter to TRUE, R2 values can become negative.

Value

Returns an object of class partR2 that is a a list with the following elements:

call

model call

R2_type

Marginal or conditional R2

R2

R2 and confidence intervals for full model and semi-partial R2 for predictors and their combinations

SC

Structure coefficients and confidence intervals. SC are the correlation between a predictor and the predicted response.

IR2

Inclusive R2. This is SC^2 * R2_full.

BW

Standardised model estimates (beta weights) for fixed effects. Beta weights for Gaussian models are calculated as beta * sd(x)/sd(y), with beta being the estimated slope of a fixed effect for predictor x and response y. Beta weight for Non-Gaussian models are calculated as beta * sd(x). Beta weights for interactions or polynomial terms are not informative at the moment and we recommend users to standardise variables themselves before fitting the model and to look at the model estimates (Ests) instead of beta weights (BW) in the partR2 output. See vignette for details.

Ests

Model estimates and confidence intervals.

R2_boot

Parametric bootstrap samples for R2 for full model and partitions

SC_boot

Parametric bootstrap samples for structure coefficients

IR2_boot

Parametric bootstrap samples for inclusive R2 values

BW_boot

Parametric bootstrap samples for beta weights

Ests_boot

Parametric bootstrap samples for model estimates

partvars

Predictors to partition

CI

Coverage of the confidence interval as specified by the CI argument.

boot_warnings

Potential warnings from estimating partial R2s during parametric bootstrapping

boot_message

Potential messages from estimating partial R2s during parametric bootstrapping. Common are for example singularity messages in lme4.

References

Nakagawa, S., & Schielzeth, H. (2013). A general and simple method for obtaining R2 from generalized linear mixed-effects models. Methods in Ecology and Evolution, 4(2), 133-142.

Nakagawa, S., Johnson, P. C., & Schielzeth, H. (2017). The coefficient of determination R2 and intra-class correlation coefficient from generalized linear mixed-effects models revisited and expanded. Journal of the Royal Society Interface, 14(134), 20170213.

Examples


data(biomass)
library(lme4)

# scale data
biomass[] <- lapply(biomass, function(x) if (is.double(x)) scale(x) else x)

# Gaussian data
mod <- lmer(Biomass ~ Year + Temperature + Precipitation + SpeciesDiversity + (1 | Population),
  data = biomass)

# R2
(R2_1 <- partR2(mod))

# R2 with CI
(R2_2 <- partR2(mod, R2_type = "marginal", nboot = 15, CI = 0.95))

# Part (semi-partial) R2s with CIs
(R2_3 <- partR2(mod,
  partvars = c("SpeciesDiversity", "Temperature", "Precipitation"),
  R2_type = "marginal", nboot = 10, CI = 0.95
))

Calculate part R2

Description

Calculate part R2

Usage

part_R2s(
  mod,
  expct,
  overdisp_name,
  R2_type,
  all_comb,
  partition,
  data_mod,
  allow_neg_r2
)

Arguments

mod

merMod object

expct

Expectation

overdisp_name

Name of overdispersion term

R2_type

"marginal" or "conditional"

all_comb

variable combinations to remove to calculate R2

partition

check if R2 partitioning is needed

data_mod

data.frame

allow_neg_r2

TRUE or FALSE

Value

R2, atm data.frame with one element


Print a partR2 object

Description

Displays the results a partR2object (i.e. the result of a partR2 function call) in a nice form.

Usage

## S3 method for class 'partR2'
print(x, round_to = 4, ...)

Arguments

x

partR2 object returned from one of the partR2 functions

round_to

defaults to 4 (decimals)

...

Additional arguments; none are used in this method.

Value

No return value, prints concise results of partR2 calculation.


sim_data dataset

Description

sim_data dataset

Details

Simulated dataset to test random slope models. Source: https://stats.stackexchange.com/questions/162553/how-to-simulate-a-random-slope-model


Complete summary of a partR2 object

Description

Displays extended results of partR2, including R2, part (semi-partial) R2, inclusive R2, structure coefficients and beta weights.

Usage

## S3 method for class 'partR2'
summary(object, round_to = 4, ests = FALSE, ...)

Arguments

object

partR2 object returned from one of the partR2 functions

round_to

Defaults to 4 (decimals)

ests

Defaults to FALSE, if TRUE, also prints raw model estimates.

...

Additional arguments; not used at the moment

Value

No return value, prints extended summary of partR2 calculation.


Get variance components for binomial model with binary response.

Description

Get variance components for binomial model with binary response.

Usage

var_comps_binary(mod, expct)

Arguments

mod

merMod object with binomial family and binary response.

expct

"latent", "meanobs" of "liability"

Value

Fixed, random and residual variance


Get variance components for gaussian model.

Description

Get variance components for gaussian model.

Usage

var_comps_gaussian(mod, ...)

Arguments

mod

merMod object with gaussian family.

Value

Fixed, random and residual variance


Get variance components for merMod with poisson response.

Description

Get variance components for merMod with poisson response.

Usage

var_comps_poisson(mod, expct, overdisp_name)

Arguments

mod

merMod object with poisson family.

expct

"meanobs" or "latent". "latent" recommended.

overdisp_name

name of overdispersion term

Value

Fixed, random and residual variance


Get variance components for binomial model with proportion response.

Description

Get variance components for binomial model with proportion response.

Usage

var_comps_proportion(mod, expct, overdisp_name)

Arguments

mod

merMod object with binomial family and binary response.

expct

"latent", "meanobs" of "liability"

Value

Fixed, random and residual variance


Captures and suppresses (still to find out why) warnings of an expression

Description

This function is used within partR2 to capture lme4 model fitting warnings in the bootstrap and permutation procedures.

Usage

with_warnings(expr)

Arguments

expr

An expression, such as the sequence of code used by rptR to calculate bootstrap or permutation estimates

Value

List of warnings.