multinomMLE
estimates the coefficients of the multinomial
regression model for grouped count data by maximum likelihood, then
computes a moment estimator for overdispersion and reports standard
errors for the coefficients that take overdispersion into account.
This function is not meant to be called directly by the user. It is
called by multinomRob
, which constructs the various arguments.
multinomMLE(Y, Ypos, Xarray, xvec, jacstack, itmax=100, xvar.labels, choice.labels, MLEonly=FALSE, print.level=0)
NA
values) are not allowed.TRUE
, then only the standard maximum-likelihood MNL model
is estimated---i.e., no overdispersion parameter is estimated.MLEonly==TRUE
.se
; included for backward
compatibility.MLEonly==TRUE
.se
in vector form.se.opg
in vector form.se.hes
in vector form.se.sw
in vector form.coefficients
, vector of coefficient parameters (same as coeffvec
value in list returned by multinomMLE); tvec
, matrix of coefficient
parameters (same as coefficients
value in list returned by multinomMLE);
formation
, inverse Hessian matrix; score
, score (or gradient
element) matrix; LLvals
, list containing log-likelihood value;
convflag
, TRUE/FALSE convergence flag; iters
, number of
iterations done in final Gauss-Newton stage; posdef
, TRUE if Hessian is
positive definite.Y
matrix that was supplied as input, except modified by
having done Y[!Ypos] <- 0
.Ypos
matrix that was supplied as input.jacstack
that was supplied as an input argument.For additional documentation please visit http://sekhon.berkeley.edu/robust/.
# make some multinomial data
x1 <- rnorm(50);
x2 <- rnorm(50);
p1 <- exp(x1)/(1+exp(x1)+exp(x2));
p2 <- exp(x2)/(1+exp(x1)+exp(x2));
p3 <- 1 - (p1 + p2);
y <- matrix(0, 50, 3);
for (i in 1:50) {
y[i,] <- rmultinomial(1000, c(p1[i], p2[i], p3[i]));
}
# perturb the first 5 observations
y[1:5,c(1,2,3)] <- y[1:5,c(3,1,2)];
y1 <- y[,1];
y2 <- y[,2];
y3 <- y[,3];
# put data into a dataframe
dtf <- data.frame(x1, x2, y1, y2, y3);
#Do MLE estimation. The following model is NOT identified if we
#try to estimate the overdispersed MNL.
dtf <- data.frame(y1=c(1,1),y2=c(2,1),y3=c(1,2),x=c(0,1))
summary(multinomRob(list(y1 ~ 0, y2 ~ x, y3 ~ x), data=dtf, MLEonly=TRUE))
Run the code above in your browser using DataCamp Workspace