Learn R Programming

spaMM (version 4.5.0)

llm.fit: Link-linear regression models (LLMs)

Description

Some “family” objects in spaMM describe models with non-GLM response families, such as the negbin1 or beta_resp families already widely considered in previous works and other packages. These models are characterized by a linear predictor, a link function, and a distribution for residual variation that does not belong to the exponential family from which GLMs are defined.

These family objects are conceived for use with spaMM's fitting functions. They cannot generally be used as argument to the glm function, except when this function is highjacked by use of the method="llm.fit" argument, where llm stands for Link-Linear (as in “log-linear”, say) regression Model.

Mixed-effect models fitted by such methods cannot use expected-Hessian approximations, in contrast to GLM response families. negbin2 is a family object for a GLM response family (strictly speaking, only for fixed shape and untruncated version) but implemented as an LL-family, in particular using only the observed Hessian matrix.

Usage

# glm(..., method="llm.fit")
## See also 'beta_resp', 'negbin1', 'betabin', and possibly later additions.

Arguments

Details

These family objects are lists, formally of class c("LLF", "family"). Compared to a family object, they have additional elements, not documented here.

As stats:: GLM family objects do, they provide deviance residuals through the dev.resids member function. There are various definitions of deviance residuals for non-GLM families in the literature. Here they are defined as “2*(saturated_logLik - logLik)”, where the likelihood for the saturated model is the likelihood maximized wrt to the mean parameter \(\mu\) for each observation y independently. The maximizing \(\mu\) is not equal to the observation, in contrast to the standard result for GLMs.

Examples

Run this code
data(scotlip)

### negbin1 response:

# Fixed-effect model
#
(var_shape <- fitme(cases~I(prop.ag/10)+offset(log(expec)),family=negbin1(), 
                    data=scotlip))

# Highjacking glm(): the family parameter must be given 
#
fitted_shape <- residVar(var_shape,which="fam_parm")
glm(cases~I(prop.ag/10)+offset(log(expec)),family=negbin1(shape=fitted_shape), 
    method="llm.fit", data=scotlip)

### Similar exercice with Beta response family: 

set.seed(123)
beta_dat <- data.frame(y=runif(100),grp=sample(2,100,replace = TRUE))
  
# Fixed-effect model
(var_prec <- fitme(y ~1, family=beta_resp(), data= beta_dat))
  
# Highjacking glm(): 
fitted_prec <- residVar(var_prec,which="fam_parm")
glm(y ~1, family=beta_resp(prec=fitted_prec), data= beta_dat, method="llm.fit") 

Run the code above in your browser using DataLab