Open
Description
First of all, thank you for developing a fantastic package! I am having and issue implementing clusters. Could you please provide insight into why this error occurs or suggest any adjustments to handle clustering properly? Thank you for your support!
Description
I encountered an issue when running the logitr()
function with the clusterID
parameter specified. While the model runs successfully without clusterID
, adding it results in an error. The error message is:
Error in if (inputs$clusterID == inputs$panelID) { :
argument is of length zero
I created a clusterID
column specifically to ensure the data type in the version column was not the issue. (The scenario columns are not currently in use but may be in the future).
Reproducible Example
Here is a sample structure of my dataset (wtp_risk
):
# A tibble: 180 × 12
version risk loss_value id original_choice scenario_a scenario_b scenario_c alt choice obsID clusterID
<fct> <dbl> <dbl> <chr> <fct> <dbl> <dbl> <dbl> <fct> <dbl> <int> <int>
1 CO1 8 0 R_bf8TOsp… c 2 3 1 a 0 53 1
2 CO1 4 113. R_bf8TOsp… c 2 3 1 b 0 53 1
3 CO1 4 113. R_bf8TOsp… c 2 3 1 c 1 53 1
4 CO1 8 0 R_2tnw7mp… a 1 2 2 a 1 27 2
5 CO1 4 113. R_2tnw7mp… a 1 2 2 b 0 27 2
6 CO1 4 113. R_2tnw7mp… a 1 2 2 c 0 27 2
Code to Reproduce
# Run without clusterID (successful)
mnl_pref <- logitr(
data = wtp_risk,
outcome = "choice",
obsID = "obsID",
pars = c("loss_value", "risk")
)
# Run with clusterID (error)
mnl_pref <- logitr(
data = wtp_risk,
outcome = "choice",
obsID = "obsID",
pars = c("loss_value", "risk"),
clusterID = "clusterID"
)
Observations
- The
wtp_risk
data frame does not containNA
values inobsID
,clusterID
, orversion
. - The
clusterID
was created to ensure correct data type handling. - The error seems related to how
panelID
is internally processed in thelogitr
function, even whenpanelID
is not specified. (This is not panel data). - I have tried setting panelID = NULL specifically and the error still occurs.
Environment
- R version: 4.2.3
- logitr version: 1.1.2
- macOS: 15.0.1
Metadata
Metadata
Assignees
Labels
No labels