Learn R Programming

spaMM (version 2.6.1)

get_ranPars: Operations on lists of parameters

Description

get_ranPars returns various subsets of random-effect 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

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

which

For get_ranPars, the only non-null value is "corrPars", to return correlation parameters of random effects.

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.

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

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"). remove_from_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)).

Examples

Run this code
# NOT RUN {
data("wafers")
m1 <- HLfit(y ~X1+X2+(1|batch),
          resid.model = ~ 1 ,data=wafers,HLmethod="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