Learn R Programming

idefix (version 0.2.4)

SeqDB: Sequential modified federov algorithm for MNL model.

Description

Selects the choice set that minimizes the DB-error when added to an initial design, given (updated) parameter values.

Usage

SeqDB(des, cand.set, n.alts, par.draws, prior.covar, reduce = TRUE,
  weights = NULL)

Arguments

des

A design matrix in which each row is a profile. Can be generated with Modfed

cand.set

A numeric matrix in which each row is a possible profile. The Profiles function can be used to generate this.

n.alts

Numeric value indicating the number of alternatives per choice set.

par.draws

A matrix in which each row is a sample from the multivariate parameter distribution. See also ImpsampMNL.

prior.covar

Covariance matrix of the prior distribution.

reduce

Logical value indicating whether the candidate set should be reduced or not.

weights

A vector containing the weights of the draws. Default is NULL, See also ImpsampMNL.

Value

set

A matrix representing a DB efficient choice set.

db.error

A numeric value indicating the DB-error of the whole design.

Details

This algorithm is ideally used in an adaptive context. The algorithm will select the next DB-efficient choice set given parameter values and an initial design. In an adaptive context these parameter values are updated after each observed response.

The initial design des can be generated with Modfed. If alternative specific constants are included in the initial design, the algorithm will use the same for selecting the new choice set. Columns of des which contain ".cte" in their name are recognized as alternative specific columns.

The list of potential choice sets are created using combinations. If reduce is TRUE, repeats.allowed = FALSE and vice versa. If no alternative constants are used reduce should always be TRUE. When alternative specific constants are used reduce can be TRUE so that the algorithm will be faster, but the combinations of constants and profiles will not be evaluated exhaustively.

The weights can be used when the par.draws have weights. This is for example the case when parameter values are updated using ImpsampMNL.

References

jumnldes

Examples

Run this code
# NOT RUN {
# DB efficient choice set, given a design and 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 (total = 5 parameters).
pc <- diag(length(m)) # Prior variance
set.seed(123)
ps <- MASS::mvrnorm(n = 10, mu = m, Sigma = pc) # 10 draws.
ac <- c(0, 0) # No alternative specific constants. 
# Initial design.
des <- Modfed(cand.set = cs, n.sets = 6, n.alts = 2, alt.cte = ac, par.draws = ps)$design
# Efficient choice set to add. 
SeqDB(des = des, cand.set = cs, n.alts = 2, par.draws = ps, prior.covar = pc)

# DB efficient choice set, given a design and 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.
ac <- c(1, 0) # Alternative specific constant. 
# Initial design.
des <- Modfed(cand.set = cs, n.sets = 6, n.alts = 2, alt.cte = ac, par.draws = ps)$design
# Efficient choice set to add. 
SeqDB(des = des, cand.set = cs, n.alts = 2, par.draws = ps, prior.covar = pc)
# }

Run the code above in your browser using DataLab