diff --git a/R/design.R b/R/design.R index 2b09095..c5b1948 100644 --- a/R/design.R +++ b/R/design.R @@ -39,8 +39,8 @@ #' choice set given the sample from the prior preference distribution. #' Defaults to `FALSE`. #' @param method Which method to use for obtaining a Bayesian D-efficient -#' design, `"Modfed"` or `"CEA"`? Defaults to `"Modfed"`. See `?idefix::Modfed` -#' and `?idefix::CEA` for more details. +#' design, `"CEA"` or `"Modfed"`? Defaults to `"CEA"`. See `?idefix::CEA` +#' and `?idefix::Modfed` for more details. #' @param max_iter A numeric value indicating the maximum number allowed #' iterations when searching for a Bayesian D-efficient design. The default is #' 50. @@ -89,20 +89,18 @@ #' ) #' #' # Make a Bayesian D-efficient design with a prior model specified -#' # Note that by default method = "Modfed" and parallel = TRUE. -#' # This example uses "CEA" because it is faster. +#' # Note that by default parallel = TRUE. #' design_deff <- cbc_design( #' profiles = profiles, -#' n_resp = 30, # Number of respondents -#' n_alts = 2, # Number of alternatives per question -#' n_q = 5, # Number of questions per respondent +#' n_resp = 300, # Number of respondents +#' n_alts = 3, # Number of alternatives per question +#' n_q = 6, # Number of questions per respondent #' n_start = 1, #' priors = list( #' price = -0.1, #' type = c(0.1, 0.2), #' freshness = c(0.1, 0.2) #' ), -#' method = "CEA", #' parallel = FALSE #' ) cbc_design <- function( @@ -118,7 +116,7 @@ cbc_design <- function( priors = NULL, prior_no_choice = NULL, probs = FALSE, - method = "Modfed", + method = "CEA", max_iter = 50, parallel = TRUE ) { @@ -388,15 +386,16 @@ make_design_deff <- function( profiles_restricted <- nrow(expand.grid(lvl.names)) > nrow(profiles) + if (profiles_restricted & (method == "CEA")) { + # "CEA" method only works with unrestricted profile set + method == "Modfed" + warning( + 'The "CEA" algorithm requires the use of an unrestricted set of ', + 'profiles, so "Modfed" is now being used instead.' + ) + } + if (method == "CEA") { - # "CEA" method only works with unrestricted profile set - if (profiles_restricted) { - stop( - 'The CEA algorithm requires the use of an unrestricted set of ', - 'profiles. Set \'method = "Modfed"\', which can use restricted ', - 'profiles, or consider using an unrestricted set of profiles.' - ) - } D <- idefix::CEA( lvls = lvls, coding = coding, diff --git a/man/cbc_design.Rd b/man/cbc_design.Rd index dfe6ce7..007fdb4 100644 --- a/man/cbc_design.Rd +++ b/man/cbc_design.Rd @@ -17,7 +17,7 @@ cbc_design( priors = NULL, prior_no_choice = NULL, probs = FALSE, - method = "Modfed", + method = "CEA", max_iter = 50, parallel = TRUE ) @@ -68,8 +68,8 @@ choice set given the sample from the prior preference distribution. Defaults to \code{FALSE}.} \item{method}{Which method to use for obtaining a Bayesian D-efficient -design, \code{"Modfed"} or \code{"CEA"}? Defaults to \code{"Modfed"}. See \code{?idefix::Modfed} -and \code{?idefix::CEA} for more details.} +design, \code{"CEA"} or \code{"Modfed"}? Defaults to \code{"CEA"}. See \code{?idefix::CEA} +and \code{?idefix::Modfed} for more details.} \item{max_iter}{A numeric value indicating the maximum number allowed iterations when searching for a Bayesian D-efficient design. The default is @@ -128,20 +128,18 @@ design_rand_labeled <- cbc_design( ) # Make a Bayesian D-efficient design with a prior model specified -# Note that by default method = "Modfed" and parallel = TRUE. -# This example uses "CEA" because it is faster. +# Note that by default parallel = TRUE. design_deff <- cbc_design( profiles = profiles, - n_resp = 30, # Number of respondents - n_alts = 2, # Number of alternatives per question - n_q = 5, # Number of questions per respondent + n_resp = 300, # Number of respondents + n_alts = 3, # Number of alternatives per question + n_q = 6, # Number of questions per respondent n_start = 1, priors = list( price = -0.1, type = c(0.1, 0.2), freshness = c(0.1, 0.2) ), - method = "CEA", parallel = FALSE ) }