You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to estimate a random parameters logit model (RPL) in R using the logitr package, replicating results from Ahn & Lusk’s paper on sugar-sweetened beverage policies ([https://doi.org/10.1111/ajae.12134] - The data is in the supplementary material)
Each respondent (total) answers 16 choice tasks (question), and in each task, they choose one option among 6 alternatives (Option). My dataset is structured in long format, where each row is one alternative in a choice task.
However, I keep encountering the following error when running logitr:
Error in checkRepeatedIDs("panelID", panelID, reps) :
The 'panelID' variable provided has repeated ID values.
Even after ensuring panelID appears exactly 6 times per choice task and defining obsID uniquely per alternative, the error persists.
What I’ve Tried So Far
1️⃣ Data Structure
Panel ID (panel_id) should track each respondent across choice tasks. I’ve defined it as:
data$panel_id <- paste0(data$total, "_", data$question)
Observation ID (obs_id) should uniquely identify each alternative in a choice task:
data$obs_id <- paste0(data$total, "_", data$question, "_", data$Option)
Checked that each choice task has exactly 6 alternatives:
table(table(data$panel_id)) # Should return only 6s
any(duplicated(data$obs_id)) # Should return FALSE
duplicated_ids <- data$panel_id[duplicated(data$panel_id)]
table(duplicated_ids) # Should show no unexpected repeats
Key Issue
Despite these checks, logitr still flags panelID as having repeated ID values.
I suspect that logitr expects panelID to be defined differently, but I’m not sure how to fix it while keeping the structure correct.
What I Need Help With:
Is my definition of panelID correct for a panel RPL model?
Are there additional logitr requirements for panel data that I’m missing?
Is there a better way to structure obsID and panelID to avoid this issue?
If anyone has successfully run an RPL model in logitr, could you share how you structured your data?
**Any insights or guidance would be greatly appreciated!
Thanks in advance for your help! 🙌**
The text was updated successfully, but these errors were encountered:
I haven't looked closely yet, but usually this occurs when the panelID or obsID variable has an ID that is not in sequence. They need to be like 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, etc. The panelID should be the same number for each unique person, and the obsID needs to be the same number for each unique observation. Some of the checks you ran may not have caught this. If you post the data, I can also look at it.
Problem Summary
I'm trying to estimate a random parameters logit model (RPL) in R using the logitr package, replicating results from Ahn & Lusk’s paper on sugar-sweetened beverage policies ([https://doi.org/10.1111/ajae.12134] - The data is in the supplementary material)
Each respondent (total) answers 16 choice tasks (question), and in each task, they choose one option among 6 alternatives (Option). My dataset is structured in long format, where each row is one alternative in a choice task.
However, I keep encountering the following error when running logitr:
Even after ensuring panelID appears exactly 6 times per choice task and defining obsID uniquely per alternative, the error persists.
What I’ve Tried So Far
1️⃣ Data Structure
Panel ID (panel_id) should track each respondent across choice tasks. I’ve defined it as:
2️⃣ Running the Model
Ensured no missing values in panel_id:
Checked for unintended duplicates:
Key Issue
Despite these checks, logitr still flags panelID as having repeated ID values.
I suspect that logitr expects panelID to be defined differently, but I’m not sure how to fix it while keeping the structure correct.
What I Need Help With:
**Any insights or guidance would be greatly appreciated!
Thanks in advance for your help! 🙌**
The text was updated successfully, but these errors were encountered: