The glm.hP function is used to fit a hyper-Poisson double generalized
linear model with a log-link for the mean (mu) and the dispersion
parameter (gamma).
glm.hP(
formula.mu,
formula.gamma,
init.beta = NULL,
init.delta = NULL,
data,
weights,
subset,
na.action,
maxiter_series = 1000,
tol = 0,
offset,
opts = NULL,
model.mu = TRUE,
model.gamma = TRUE,
x = FALSE,
y = TRUE,
z = FALSE
)glm.hP returns an object of class "glm_hP". The
function summary can be used to obtain or print a
summary of the results.
The generic accessor functions coef,
fitted.values and residuals can
be used to extract various useful features of the value returned by
glm.hP.
weights extracts a vector of weights, one for each case in the fit
(after subsetting and na.action).
An object of class "glm_hP" is a list containing at least the
following components:
coefficientsa named vector of coefficients.
residualsthe residuals, that is response minus fitted values.
fitted.valuesthe fitted mean values.
linear.predictorsthe linear fit on link scale.
callthe matched call.
offsetthe offset vector used.
weightsthe weights initially supplied, a
vector of 1s if none were.
df.residualthe residual degrees of freedom.
df.nullthe residual degrees of freedom for the null model.
yif requested (the default) the y vector used.
matrix.muif requested, the mu model matrix.
matrix.gammaif requested, the gamma model matrix.
model.muif requested (the default) the mu model frame.
model.gammaif requested (the default) the gamma model frame.
nloptran object of class "nloptr" with the
result returned by the optimizer nloptr
an object of class "formula" (or one that can be coerced to that class): a symbolic description of the model to be fitted.
regression formula linked to log(gamma)
initial values for regression coefficients of beta.
initial values for regression coefficients of delta.
an optional data frame, list or environment (or object that can
be coerced 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.hP 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 gamma 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 gamma model matrix used in the fitting process should be returned as a component of the returned value.
Fit a hyper-Poisson double generalized linear model using as optimizer the
NLOPT_LD_SLSQP algorithm of function nloptr.
Antonio J. Saez-Castillo and Antonio Conde-Sanchez (2013). "A hyper-Poisson regression model for overdispersed and underdispersed count data", Computational Statistics & Data Analysis, 61, pp. 148--157.
S. G. Johnson (2018). The nlopt nonlinear-optimization package
## Fit model
Bids$size.sq <- Bids$size ^ 2
fit <- glm.hP(formula.mu = numbids ~ leglrest + rearest + finrest +
whtknght + bidprem + insthold + size + size.sq + regulatn,
formula.gamma = numbids ~ 1, data = Bids)
## Summary of the model
summary(fit)
## To see the termination condition of the optimization process
fit$nloptr$message
## To see the number of iterations of the optimization process
fit$nloptr$iterations
Run the code above in your browser using DataLab