Closed veronicadiaz176 closed 1 year ago
Thanks for posting this!
Could you provide some code that produces this error so I can reproduce it?
Sure, I'd be happy to help you reproduce the error. However, I should mention that I was just following your example, so I may have made a mistake along the way. In any case, here is the code that I used:
library(cbcTools)
profiles <- cbc_profiles( price = c(1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5), freshness = c('Poor', 'Average', 'Excellent'), type = list( "Fuji" = list( price = c(2, 2.5, 3) ), "Gala" = list( price = c(1, 1.5, 2) ), "Honeycrisp" = list( price = c(2.5, 3, 3.5, 4, 4.5, 5), freshness = c("Average", "Excellent") ) ) )
design_db_eff <- cbc_design( profiles = profiles, n_resp = 900, # Number of respondents n_alts = 3, # Number of alternatives per question n_q = 6, # Number of questions per respondent priors = list( price = c(-0.1), type = c(0.1, 0.2), freshness = c(0.1, 0.2) ) )
Thanks!
Yes I can reproduce the error with this code. It seems the error occurs when using a restricted subset of profiles, as I do in this example. There appear to be a few other issues with the code when trying to obtain a Bayesian D-efficient design, as noted in issue #10. In addressing them, I will probably also address this issue.
I believe this is now fixed. Could you try installing the version on this branch with this code:
remotes::install_github("jhelvy/cbcTools@dupe-checks")
Then you can run your test code again with:
library(cbcTools)
profiles <- cbc_profiles(
price = c(1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5),
freshness = c('Poor', 'Average', 'Excellent'),
type = list(
"Fuji" = list(
price = c(2, 2.5, 3)
),
"Gala" = list(
price = c(1, 1.5, 2)
),
"Honeycrisp" = list(
price = c(2.5, 3, 3.5, 4, 4.5, 5),
freshness = c("Average", "Excellent")
)
)
)
#Bayesian D-efficient designs
design_db_eff <- cbc_design(
profiles = profiles,
n_resp = 900, # Number of respondents
n_alts = 3, # Number of alternatives per question
n_q = 6, # Number of questions per respondent
priors = list(
price = c(-0.1),
type = c(0.1, 0.2),
freshness = c(0.1, 0.2)
)
)
The issue was fundamentally the same as the root issue in #10.
Thanks for letting me know that the issue has been fixed. I tried the new code and it works perfectly fine now.
I have been encountering an error when trying to run the code provided for generating a Bayesian D-efficient design. The error message that I receive is as follows: "Error in [.data.frame(des, c("profileID", varnames)) : undefined columns selected."
I was wondering if you could help me with this issue. Is there a way to fix this error or a workaround that I can use to generate a Bayesian D-efficient design with the CBCTools package?
Thanks!