Learn R Programming

spaMM (version 4.7.0)

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

Description

Some “family” objects in spaMM describe models with non-GLM distribution 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 approximations based on the expected information matrix, in contrast to GLM distribution families.

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 from the unit deviances “2*(saturated_logLik - logLik)\(_i\)” for each observation \(i\) (provided by the dev.resids function defined by the family), where the likelihood for the saturated model is the likelihood maximized wrt to the mean parameter \(\mu_i\) for each observation \(y_i\) independently. The maximizing \(\mu_i\) is not equal to the observation \(y_i\), in contrast to the standard result for GLMs.

llm.fit provides the deviance (the sum of the above unit deviances), but not the null deviance provided by stats::glm.fit. The latter is the deviance of an intercept-only (or offset only) model. There, the intercept estimate is the mean response value for GLMs, so that the null deviance is immediately obtained; but this is not generally so for other families.

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 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