SeqKL {idefix} | R Documentation |
Sequential Kullback-Leibler based algorithm for the MNL model.
Description
Selects the choice set that maximizes the Kullback-Leibler divergence between the prior parameter values and the expected posterior, assuming a MNL model.
Usage
SeqKL(
des = NULL,
cand.set,
n.alts,
par.draws,
alt.cte = NULL,
no.choice = NULL,
weights = NULL,
allow.rep = FALSE
)
Arguments
des |
A design matrix in which each row is a profile. If alternative
specific constants are present, those should be included as the first
column(s) of the design. Can be generated with |
cand.set |
A numeric matrix in which each row is a possible profile. The
|
n.alts |
Numeric value indicating the number of alternatives per choice set. |
par.draws |
A matrix or a list, depending on |
alt.cte |
A binary vector indicating for each alternative if an alternative specific constant is desired. |
no.choice |
An integer indicating the no choice alternative. The default
is |
weights |
A vector containing the weights of the draws. Default is
|
allow.rep |
Logical value indicating whether repeated choice sets are allowed in the design. |
Details
This algorithm is ideally used in an adaptive context. The algorithm selects the choice set that maximizes the Kullback-Leibler divergence between prior and expected posterior. Otherwisely framed the algorithm selects the choice set that maximizes the expected information gain.
If alt.cte = NULL
, par.draws
should be a matrix in which each
row is a sample from the multivariate parameter distribution. In case that
alt.cte
is not NULL
, a list containing two matrices should be
provided to par.draws
. The first matrix containing the parameter draws
for the alternative specific parameters. The second matrix containing the
draws for the rest of the parameters.
The list of potential choice sets are created using
combn
. The weights
argument can be used when the
par.draws
have
weights. This is for example the case when parameter values are updated using
ImpsampMNL
.
Value
set |
Numeric matrix containing the choice set that maximizes the expected KL divergence. |
kl |
Numeric value which is the Kullback leibler divergence. |
References
Crabbe M, Akinc D, Vandebroek M (2014). “Fast algorithms to generate individualized designs for the mixed logit choice model.” https://www.sciencedirect.com/science/article/pii/S0191261513002178.
Examples
# KL efficient choice set, given parameter draws.
# Candidate profiles
cs <- Profiles(lvls = c(3, 3), coding = c("E", "E"))
m <- c(0.3, 0.2, -0.3, -0.2) # Prior mean (4 parameters).
pc <- diag(length(m)) # Prior variance
set.seed(123)
ps <- MASS::mvrnorm(n = 10, mu = m, Sigma = pc) # 10 draws.
# Efficient choice set to add.
SeqKL(cand.set = cs, n.alts = 2, alt.cte = NULL, par.draws = ps, weights = NULL)
# KL efficient choice set, given parameter draws.
# Candidate profiles
cs <- Profiles(lvls = c(3, 3), coding = c("C", "E"), c.lvls = list(c(5,3,1)))
m <- c(0.7, 0.3, -0.3, -0.2) # Prior mean (4 parameters).
pc <- diag(length(m)) # Prior variance
set.seed(123)
ps <- MASS::mvrnorm(n = 10, mu = m, Sigma = pc) # 10 draws.
sample <- list(ps[ , 1], ps[ , 2:4])
ac <- c(1, 0) # Alternative specific constant.
# Efficient choice set to add.
SeqKL(cand.set = cs, n.alts = 2, alt.cte = ac, par.draws = sample, weights = NULL)