Choice Experiment - Trouble with WTP Calculation in R

23 Views Asked by At

I'm currently working on a research project and facing some challenges with WTP (Willingness to Pay) calculation using R. I would greatly appreciate any guidance or insights you could provide. I recently conducted a choice experiment to explore preferences for a product featuring various attributes associated with sustainable production. I need to calculate WTP for each of these attributes.

Data Structure: The current structure of my raw data is as follows:

| ID    | chosen | ecosust | socialsust | general_sust | price |
|-------|--------|---------|------------|--------------|-------|
| 174   | WAHR   | none    | none       | gensus        | 8.99  |
| 174   | WAHR   | none    | fair       | none          | 8.99  |
| 174   | WAHR   | water   | fair       | none          | 12.99 |
| 174   | FALSCH | energy  | fair       | none          | 12.99 |
| 174   | FALSCH | energy  | gender     | none          | 12.99 |
| 174   | FALSCH | energy  | fair       | none          | 8.99  |
| 174   | FALSCH | water   | none       | none          | 4.99  |
| 174   | FALSCH | none    | gender     | none          | 8.99  |
| 174   | FALSCH | water   | gender     | none          | 12.99 |
| 177   | WAHR   | energy  | gender     | none          | 8.99  |
| 177   | WAHR   | none    | none       | gensus        | 4.99  |
| 177   | WAHR   | water   | fair       | none          | 12.99 |
| 177   | FALSCH | none    | none       | gensus        | 4.99  |
| 177   | FALSCH | energy  | gender     | none          | 8.99  |

First approach: I created a model using the following function:

model <- db %>%     
mutate(     indv = "Interview-Nummer (fortlaufend)"   ) %>%    
glmer(chosen ~ general_sust + ecosust + socialsust + price + (1|indv) + (1|choice), data = ., family = binomial)

I attempted to calculate WTP using the line:

wtp.gmnl(model, wrt = c("general_sust", "ecosust", "socialsust", "price")

However, I encountered the following error:

Error in if (i != posi) { : the condition has length > 1 

Alternative Approach with logitr Package:

my second approach was using the logitr package to create the model and then calculate the WTP from there. however, i kept getting errors when creating the model.

logitr(   data    = db,   outcome = "chosen",   obsID   = "Interview-Nummer (fortlaufend)",   pars    = c("price", "ecosust", "socialsust", "general_sust") )

here, i get this error:

Error in checkRepeatedIDs("obsID", obsID, reps) :    The 'obsID' variable provided has repeated ID values.

this confuses me, since in a paper concering this package, the variable obsID is defined as:

"A sequence of repeated numbers that identifies each unique choice observation. For example, if the first three choice observations had 2 alternatives each, then the first 6 rows of the obsID variable would be 1, 1, 2, 2, 3, 3."

I suspect the issue might be related to the structure of my data, but I'm not sure.

0

There are 0 best solutions below