The glm.CMP
function is used to fit a COM-Poisson double generalized
linear model with a log-link for the mean (mu
) and the dispersion
parameter (nu
).
glm.CMP(
formula.mu,
formula.nu,
init.beta = NULL,
init.delta = NULL,
data,
weights,
subset,
na.action,
maxiter_series = 1000,
tol = 0,
offset,
opts = NULL,
model.mu = TRUE,
model.nu = TRUE,
x = FALSE,
y = TRUE,
z = FALSE
)
glm.CMP
returns an object of class "glm_CMP"
. The
function summary
can be used to obtain or print a
summary of the results. An object of class "glm_CMP"
is a list
containing at least the following components:
coefficients
a named vector of coefficients.
residuals
the residuals, that is response minus fitted values.
fitted.values
the fitted mean values.
linear.predictors
the linear fit on link scale.
call
the matched call.
offset
the offset vector used.
weights
the weights initially supplied,
a vector of 1s
if none were.
y
if requested (the default) the y vector used.
matrix.mu
if requested, the mu model matrix.
matrix.nu
if requested, the nu model matrix.
model.mu
if requested (the default) the mu model frame.
model.nu
if requested (the default) the nu model frame.
nloptr
an object of class "nloptr"
with the
result returned by the optimizer nloptr
regression formula linked to log(mu)
regression formula linked to log(nu)
initial values for regression coefficients of beta
.
initial values for regression coefficients of delta
.
an optional data frame, list or environment (or object coercible
by as.data.frame
to a data frame) containing the
variables in the model. If not found in data, the variables are taken from
environment(formula)
, typically the environment from which
glm.CMP
is called.
an optional vector of ‘prior weights’ to be used in the
fitting process. Should be NULL
or a numeric vector.
an optional vector specifying a subset of observations to be used in the fitting process.
a function which indicates what should happen when the data
contain NAs
. The default is set by the na.action
setting of
options
, and is na.fail
if that is
unset. The ‘factory-fresh’ default is
na.omit
. Another possible value is
NULL
, no action. Value na.exclude
can
be useful.
Maximum number of iterations to perform in the calculation of the normalizing constant.
tolerance with default zero meaning to iterate until additional terms to not change the partial sum in the calculation of the normalizing constant.
this can be used to specify an a priori known component to be
included in the linear predictor during fitting. This should be NULL
or a numeric vector of length equal to the number of cases. One or more
offset
terms can be included in the formula instead or
as well, and if more than one is specified their sum is used. See
model.offset
.
a list with options to the optimizer,
nloptr
, that fits the model. See, the opts
parameter of nloptr
for further details.
a logical value indicating whether the mu model frame should be included as a component of the returned value.
a logical value indicating whether the nu model frame should be included as a component of the returned value.
logical value indicating whether the mu model matrix used in the fitting process should be returned as a component of the returned value.
logical value indicating whether the response vector used in the fitting process should be returned as a component of the returned value.
logical value indicating whether the nu model matrix used in the fitting process should be returned as a component of the returned value.
Fit a COM-Poisson double generalized linear model using as optimizer the
NLOPT_LD_SLSQP algorithm of function nloptr
.
Alan Huang (2017). "Mean-parametrized Conway–Maxwell–Poisson regression models for dispersed counts", Statistical Modelling, 17(6), pp. 359--380.
S. G. Johnson (2018). The nlopt nonlinear-optimization package
## Fit model
Bids$size.sq <- Bids$size^2
fit <- glm.CMP(formula.mu = numbids ~ leglrest + rearest + finrest +
whtknght + bidprem + insthold + size + size.sq + regulatn,
formula.nu = numbids ~ 1, data = Bids)
## Summary of the model
summary(fit)
## To see termination condition of the optimization process
fit$nloptr$message
## To see number of iterations of the optimization process
fit$nloptr$iterations
Run the code above in your browser using DataLab