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 |
... |
Further arguments passed to methods. The |
link |
Specifies the model link function. Typically a character string
or an object of class |
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 |
psi |
function. |
initializeY |
function. Preprocesses the response, e.g. in
|
transformY |
function. Transforms the response to |
transformX |
function. Transforms the regressors to |
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 |
g |
function. Computes |
transformY0 |
function. Computes |
t |
function. Computes |
epsilon |
function. Computes |
epsiloninv |
function. Computes |
kappaSum |
function. Computes |
computeAlpha |
function. Computes the log-dispersion parameter
|
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
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