Learn R Programming

spaMM (version 3.5.0)

get_ranPars: Operations on lists of parameters

Description

get_ranPars returns various subsets of random-effect parameters (correlation or variance parameters), as controlled by its which argument. A distinct documentation exists for get_inits_from_fit which is most useful to extract parameters from a fit in a form suitable to initialize another fit. VarCorr is yet another extractor for dispersion parameters.

remove_from_parlist removes elements from a list of parameters, and from its type attribute.

Usage

get_ranPars(object, which=NULL, ...)
remove_from_parlist(parlist, removand=NULL, rm_names=names(unlist(removand)))

Arguments

object

An object of class HLfit, as returned by the fitting functions in spaMM.

which

NULL or character string. Use which="corrPars" to get the correlation parameters. Use which="lambda" to get variances. see Details for the meaning of this for heteroscedastic models, and Value for other possible which values.

Other arguments that may be needed by some method.

parlist

A list of parameters. see Details.

removand

Optional. A list of parameters to be removed from parlist.

rm_names

Names of parameters to be removed from parlist. Mandatory if removand is not given.

Value

get_ranPars(.,which="corrPars") returns a (possibly nested) list of correlation parameters (or NULL if there is no such parameter). Top-level elements correspond to the different random effects. The list has a "type" attribute having the same nested-list structure and describing whether and how the parameters where fitted: "fix" means they where fixed, not fitted; "var" means they were fitted by HLfit's specific algorithms; "outer" means they were fitted by a generic optimization method.

get_ranPars(.,which="lambda") returns a vector of variance values, one per random effect, including both “outer”- and “inner”-optimized ones.

get_ranPars(.,which="outer_lambda") returns only “outer”-optimized variance parameters, ignoring those fitted by HLfit's specific algorithms.

get_ranPars(. which="ranef_var") (experimental) returns a list with elements

Var

same as get_ranPars(.,which="lambda")

lembda_est

A vector of variance values, one for each level of each random effect

outer

A vector or outer-optimized variance values, as returned by get_ranPars(.,which="outer_lambda")

Other elements, subject to change in later versions.

remove_from_parlist returns a list of model parameters with given elements removed, and likewise for its (optional) type attribute. See Details for context of application.

Details

For heteroscedastic models, such as conditional autoregressive models, the variance parameter “lambda” refers to a common scaling coefficient. For other random-effect models, “lambda” typically refers to the single variance parameter.

remove_from_parlist is designed to manipulate structured lists of parameters, such as a list with elements phi, lambda, and corrPars, the latter being itself a list structured as the return value of get_ranPars(.,which="corrPars"). parlist may have an attribute type, also with elements phi, lambda, and corrPars... If given, removand must have the same structure (but typically not all the elements of parlist); otherwise, rm_names must have elements which match names of unlist(names(parlist)).

See Also

get_inits_from_fit and VarCorr.

Examples

Run this code
# NOT RUN {
data("wafers")
m1 <- HLfit(y ~X1+X2+(1|batch), resid.model = ~ 1, data=wafers, method="ML")
get_ranPars(m1,which="corrPars") # NULL since no correlated random effect     

parlist1 <- list(lambda=1,phi=2,corrPars=list("1"=list(rho=3,nu=4),"2"=list(rho=5)))
parlist2 <- list(lambda=NA,corrPars=list("1"=list(rho=NA))) # values of elements do not matter
remove_from_parlist(parlist1,parlist2) ## same result as:
remove_from_parlist(parlist1,rm_names = names(unlist(parlist2)))
# }

Run the code above in your browser using DataLab