svy2relmer: Linear mixed models with correlated random effects

View source: R/svy2relmat.R

svy2relmerR Documentation

Linear mixed models with correlated random effects

Description

Fits linear mixed models by maximising the profile pairwise composite likelihood. Allows for correlated random effects, eg, for genetic relatedness (QTL) models

Usage

svy2relmer(formula, design, sterr=TRUE, return.devfun=FALSE, relmat=NULL,
 all.pairs=FALSE, subtract.margins=FALSE )

Arguments

formula

Model formula as in the lme4 package, or with terms like (1|id) for correlated random effects together with the relmat argument.

design

A survey design object produced by survey::svydesign. The pairwise weights will be computed from this design, which must have separate probabilities or weights for each stage of sampling.

sterr

Estimate standard errors for fixed effects? Set to FALSE for greater speed when using resampling to get standard errors.

return.devfun

If TRUE, return the deviance function as a component of the object. This will increase the memory use substantially, but allows for bootstrapping.

relmat

Specifies a list of relatedness matrices that corresponds to one or more random-effect groupings (eg (1|id) in the formula together with relmat=list(id=Phi) implies a covariance matrix of Phi for the random effects before scaling). See Details and the vignettes.

all.pairs

Use all pairs rather than just correlated pairs?

subtract.margins

If TRUE and all.pairs=TRUE, compute with all pairs by the faster algorithm involving subtraction from the marginal likelihood

Details

This function is very similar to svy2lme and only the differences are described here.

Formula parsing and starting values use code based on the lme4qtl package.

In svy2lme and lme4::lmer, the model is based on independent standard Normal random effects that are transformed to give random coefficients that might be correlated within observation but are either identical or independent between observations. In this function, the basic random effects in a term are multiplied by a square root of the relmat matrix for that term, giving basic random effects whose covariance between observations proportional to the relmat matrix. For example, in a quantitative trait locus model in genetics, the matrix would be a genetic relatedness matrix.

The relmat matrices must have dimnames for matching to the id variable. It is permissible for the relmat matrices to be larger than necessary – eg, containing related units that are not in the sample – since the dimnames will be used to select the relevant submatrix.

There can be only one random-effect term for each relmat term. If you need more, make a copy of the term with a different name.

The return.devfun=TRUE option is useful if you want to examine objects that aren't returned as part of the output. For example, get("ij", environment(object$devfun)) is the set of pairs used in computation.

Value

svy2relmer returns an object with print, coef, and vcov methods.

Author(s)

Thomas Lumley

References

Ziyatdinov, A., Vázquez-Santiago, M., Brunel, H. et al. lme4qtl: linear mixed models with flexible covariance structure for genetic studies of related individuals. BMC Bioinformatics 19, 68 (2018). https://bmcbioinformatics.biomedcentral.com/articles/10.1186/s12859-018-2057-x

Examples

data(milk_subset)
herd_des<- svydesign(id = ~herd + id, prob = ~one + one2, data = milk_subset)

svy2lme(sdMilk ~ lact + log(dim) + (1|herd), design=herd_des, method="general")

svy2relmer(sdMilk ~ lact + log(dim) + (1|id) + (1|herd), design=herd_des,
    relmat = list(id = A_gen))



tslumley/svylme documentation built on Feb. 10, 2024, 11:01 p.m.