Is it possible to estimate a cjbart for a conjoint outcome for non-binary outcomes, e.g. continuous/likert scale?
library(cjbart)
subjects <- 250
rounds <- 5
profiles <- 2
obs <- subjects*rounds*profiles
fake_data <- data.frame(A = sample(c("a1","a2","a3"), obs, replace = TRUE),
B = sample(c("b1","b2","b3"), obs, replace = TRUE),
C = sample(c("c1","c2","c3"), obs, replace = TRUE),
D = sample(c("d1","d2","d3"), obs, replace = TRUE),
E = sample(c("e1","e2","e3"), obs, replace = TRUE),
covar1 = rep(runif(subjects, 0 ,1),
each = rounds),
covar2 = rep(sample(c(1,0),
subjects,
replace = TRUE),
each = rounds),
id1 = rep(1:subjects, each=rounds),
stringsAsFactors = TRUE)
fake_data$Y <- ifelse(fake_data$E == "e2",
rbinom(obs, 1, fake_data$covar1),
sample(c(1,2,3,4,5), obs, replace = TRUE))
Note that the outcome is an integer between 1 and 5 instead of a binary outcome of 0 or 1.
cj_model <- cjbart::cjbart(data = fake_data,
Y = "Y",
id = "id1")
het_effects <- cjbart::IMCE(data = fake_data,
model = cj_model,
attribs = c("A","B","C","D","E"),
ref_levels = c("a1","b1","c1","d1","e1"),
cores = 1)
Calculating OMCEs for attribute: A [1/5]
Error in quantile.default(var_z[, data[[id]] == s], intvl) :
missing values and NaN's not allowed if 'na.rm' is FALSE
I've noticed that if I rescale the five levels to values between 0 and 1, the algorithm works, e.g. using c(0, 0.25, 0.5, 0.75, 1)
when sampling to generate Y
the algorithm works. What does this imply for the estimation? Is this a valid approach for use with non-binary outcomes? It seems that the package was not designed for non-binary outcomes.