mclogit
fits conditional logit models and mixed conditional
logit models to count data and individual choice data,
where the choice set may vary across choice occasions.
Conditional logit models without random effects are fitted by Fisher-scoring/IWLS. The implementation of mixed conditional logit currently is limited to PQL and random intercepts.
mclogit(formula, data=parent.frame(), random=NULL,
subset, weights = NULL, offset=NULL, na.action = getOption("na.action"),
model = TRUE, x = FALSE, y = TRUE, contrasts=NULL,
start=NULL,start.theta=NULL,
control=mclogit.control(…), …)
a model formula: a symbolic description of the model to be fitted. The left-hand side contains is expected to be a two-column matrix. The first column contains the choice counts or choice indicators (alternative is chosen=1, is not chosen=0). The second column contains unique numbers for each choice set.
If individual-level data is used, choice sets correspond to the individuals, if aggregated data with choice counts are used, choice sets may e.g. correspond to covariate classes within clusters.
The right-hand of the formula contains choice predictors. It should be noted that constants are deleted from the formula as are predictors that do not vary within choice sets.
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
is called.
an optional formula that specifies the random-effects structure or NULL.
an optional vector of weights to be used in the fitting
process. Should be NULL
or a numeric vector.
an optional model offset. Currently only supported for models without random effects.
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 NA
s. 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.
an optional numerical vector of starting values for the conditional logit parameters.
an optional numerical vector of starting values for the variance parameters.
a logical value indicating whether model frame should be included as a component of the returned value.
logical values indicating whether the response vector and model matrix used in the fitting process should be returned as components of the returned value.
an optional list. See the contrasts.arg
of model.matrix.default
.
a list of parameters for the fitting process.
See mclogit.control
arguments to be passed to mclogit.control
mclogit
returns an object of class "mclogit", which has almost the
same structure as an object of class "glm". The difference are
the components coefficients
, residuals
, fitted.values
,
linear.predictors
, and y
, which are matrices with
number of columns equal to the number of response categories minus one.
mclogit
tries first to fit the model using the IRLS algorithm of
glm.fit
, which has the advantage that
starting values are not needed in most cases. If convergence
cannot achieved, it tries to minimize the deviance using
optim
with method "BFGS".
# NOT RUN {
data(Transport)
summary(mclogit(
cbind(resp,suburb)~distance+cost,
data=Transport
))
data(electors)
summary(mclogit(
cbind(Freq,interaction(time,class))~econ.left/class+welfare/class+auth/class,
random=~1|party.time,
data=within(electors,party.time<-interaction(party,time))))
# }
Run the code above in your browser using DataLab