ll_vclogit | R Documentation |
Computes the observed log likelihood for a multinomial logit with varying
choice sets and weights. ll_vclogit
implements by Rcpp. ll_vclogit_R
implements in R, and is slower.
ll_vclogit(par, y_j, zeta_k, m_j)
par |
The parameter of interest. A (L)-length vector of mlogit coefficients for cluster k and office j. The coefficient for the reference category, corresponding to abstention, is abbreviated here. That coefficient is constrained to be 0. Therefore, the log likelihood appends 0 to the beginning each time. |
y_j |
N length vector of outcomes |
zeta_k |
N-length vector of posterior for membership in cluster k |
m_j |
N by (L + 1) matrix of missingness indicators |
When used via optim
, the par
command returns the MLE
parameter. See example.
# fit data from mlogit and compare
fit <- optim(par = c(1, -2, 1),
fn = ll_vclogit,
y_j = canada_mlogit_y,
zeta_k = canada_mlogit_w,
m_j = canada_mlogit_m,
method = 'BFGS')
fit$par
# mlogit replication ----
## Not run:
library(mlogit)
data("ModeCanada")
MC_mlogit <- mlogit.data(ModeCanada,
chid.var = "case",
alt.var = "alt",
drop.index = TRUE)
fit_mlogit_pkg <- mlogit(choice ~ 1,
data = MC_mlogit,
weights = dist,
reflevel = "train")
coef(fit_mlogit_pkg)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.