walsNBfitIterate {WALS} | R Documentation |
Iteratively fitting walsNB, internal function for walsNB.formula and walsNB.matrix.
Description
Wrapper around walsNBfit
that allows iteratively
(re-)fitting walsNB
models.
Usage
walsNBfitIterate(
y,
X1,
X2,
link = "log",
na.action = NULL,
weights = NULL,
offset = NULL,
prior = weibull(),
controlInitNB = controlNB(),
keepY = TRUE,
keepX = FALSE,
iterate = FALSE,
tol = 1e-06,
maxIt = 50,
nIt = NULL,
verbose = FALSE,
...
)
Arguments
y |
Count response as vector. |
X1 |
Design matrix for focus regressors. Usually includes a constant
(column full of 1s) and can be generated using |
X2 |
Design matrix for auxiliary regressors. Usually does not include
a constant column and can also be generated using |
link |
specifies the link function, currently only "log" is supported. |
na.action |
Not implemented yet. |
weights |
Not implemented yet. |
offset |
Not implemented yet. |
prior |
Object of class |
controlInitNB |
Controls estimation of starting values for one-step ML,
see |
keepY |
If |
keepX |
If |
iterate |
if |
tol |
Only used if |
maxIt |
Only used if |
nIt |
Only used if |
verbose |
If |
... |
Arguments to be passed to the workhorse function |
Details
The parameter tol
is used to control the convergence of the iterative
fitting algorithm. Let i
be the current iteration step for the
coefficient vector \beta_{i} = (\beta_{i,1}, \ldots, \beta_{i,k})'
,
k > 0
, and dispersion parameter \rho_{i}
. If
\frac{||\beta_{i} - \beta_{i-1}||_{2}}{\sqrt{k}}
= \sqrt{\frac{\sum_{j = 1}^{k} (\beta_{i,j} - \beta_{i-1,j})^{2}}{k}} < \texttt{tol},
and
|\rho_{i} - \rho_{i-1}| < \texttt{tol},
then the fitting process is assumed to have converged and stops.
Value
A list containing all elements returned from walsNBfit
and additionally the following elements:
y |
If |
x |
list. If |
initialFit |
List containing information (e.g. convergence) on the
estimation of the starting values for |
weights |
returns the argument |
offset |
returns the argument |
converged |
Logical. Only relevant if |
it |
Number of iterations run in the iterative fitting algorithm.
|
deviance |
Deviance of the fitted (conditional) NB2 regression model. |
residuals |
Raw residuals, i.e. response - fitted mean. |
See Also
Examples
data("NMES1988", package = "AER")
NMES1988 <- na.omit(NMES1988)
form <- (visits ~ health + chronic + age + insurance + adl + region + gender
+ married + income + school + employed)
X <- model.matrix(form, data = NMES1988)
focus <- c("(Intercept)", "healthpoor", "healthexcellent", "chronic", "age",
"insuranceyes")
aux <- c("adllimited", "regionnortheast", "regionmidwest", "regionwest",
"gendermale", "marriedyes", "income", "school", "employedyes")
X1 <- X[, focus]
X2 <- X[, aux]
y <- NMES1988$visits
str(walsNBfitIterate(y, X1, X2, prior = weibull(), link = "log",
method = "fullSVD", iterate = TRUE))