familyWALS {WALS}R Documentation

Extended Family Objects for Models

Description

Objects of class "familyWALS" inherit from "family" and extend those with (transformation) functions required for walsGLM and walsNB.

Usage

familyWALS(object, ...)

poissonWALS(link = "log")

binomialWALS(link = "logit")

negbinFixedWALS(scale, link)

negbinWALS(scale, link)

## S3 method for class 'walsGLM'
familyWALS(object, ...)

Arguments

object

The function familyWALS() extracts the family objects stored in "walsGLM" objects.

...

Further arguments passed to methods.

The negbinWALS() family currently only accepts "log", while negbinFixedWALS() supports both "log" and "canonical".

link

Specifies the model link function. Typically a character string or an object of class "link-glm" generated by make.link. See family for more details. Currently, only a limited number of links are supported. See below for more details.

scale

dispersion parameter of NB2 to be used, always larger than 0.

Details

familyWALS() is a generic function that extracts the family used in "walsGLM" objects.

negbinFixedWALS() creates the "familyWALS" object for negative binomial distribution type 2 (NB2) with fixed dispersion parameter. It extends negativeBinomial.

negbinWALS() creates objects of the specialized class "familyNBWALS" which inherits from "familyWALS" and "family". It constructs the "familyNBWALS" object for the negative binomial distribution type 2 (NB2) with variable dispersion parameter by extending negativeBinomial and negbinFixedWALS with functions required in walsNB. negbinWALS should only be used in walsNBfit and not in walsGLM because the NB2 with variable dispersion parameter is not a GLM!

Supported links

Currently, binomialWALS() and poissonWALS() only support their canonical links, i.e. "logit" and "log", respectively. negbinFixedWALS() supports both, the "canonical" link and the "log" link, however, the first is not recommended due to numerical difficulties in the fitting process. In contrast, negbinWALS() only supports the "log" link.

Value

An object of class "familyWALS" to be used in walsGLM that inherits from "family". This is a list that contains elements returned from the corresponding family function that it extends. Additionally, the following elements are available:

theta.eta

function. Derivative of the canonical parameter \theta with respect to the linear link \eta, i.e. d \theta / d \eta.

psi

function. \psi defined on p. 3 of (De Luca et al. 2018).

initializeY

function. Preprocesses the response, e.g. in binomialWALS() it transforms factors to numeric 0s and 1s.

transformY

function. Transforms the response to \bar{y}. See eq. (5) in (De Luca et al. 2018) for GLMs and (Huynh 2024a) for negbinWALS() used in walsNB.

transformX

function. Transforms the regressors to \bar{X}_1 and \bar{X}_2, respectively. See eq. (5) in (De Luca et al. 2018) for GLMs and (Huynh 2024a) for negbinWALS() used in walsNB.

density

function. The probability density/mass function of the family.

poissonWALS() and negbinFixedWALS() return objects of class "familyWALScount" that inherit from "familyWALS" and "family". These are lists that contain the same elements as "familyWALS" objects described above.

negbinWALS() creates an object of class "familyNBWALS" (only used internally in walsNB) that inherits from "familyWALScount", "familyWALS" and "family". This is a list that contains all elements returned from negbinFixed and the elements described above for objects of class "familyWALS". Additionally contains the following elements with functions required in walsNB that are described in (Huynh 2024a):

q

function. Computes \bar{q}.

g

function. Computes \bar{g}.

transformY0

function. Computes \bar{y}_0.

t

function. Computes \bar{t}.

epsilon

function. Computes \bar{\epsilon}.

epsiloninv

function. Computes \bar{\epsilon}^{-1}.

kappaSum

function. Computes \bar{\kappa}^{\top} \mathbf{1}.

computeAlpha

function. Computes the log-dispersion parameter \log(\rho) given (model-averaged) estimates of the regression coefficients of the transformed regressors \gamma_{1} and \gamma_{2}.

References

De Luca G, Magnus JR, Peracchi F (2018). “Weighted-average least squares estimation of generalized linear models.” Journal of Econometrics, 204(1), 1–17. doi:10.1016/j.jeconom.2017.12.007.

Huynh K (2024a). “Weighted-Average Least Squares for Negative Binomial Regression.” arXiv 2404.11324, arXiv.org E-Print Archive. doi:10.48550/arXiv.2404.11324.

See Also

family, walsGLM.

Examples

## Use in walsGLM():
data("NMES1988", package = "AER")
NMES1988 <- na.omit(NMES1988)
fitPoisson <- walsGLM(emergency ~ health + chronic + age + gender |
                       I((age^2)/10) + married + region, family = poissonWALS(),
                      data = NMES1988, prior = laplace())
summary(fitPoisson)

## Plot derivatives of binomialWALS() with default 'logit' link:
bi <- binomialWALS()
plot(bi$mu.eta, from = -10, to = 10)
plot(bi$theta.eta, from = -10, to = 10) # constant. logit is canonical link


[Package WALS version 0.2.5 Index]