Rosanne
Rosanne

Reputation: 11

"No Individual Index" Error Mixed Model Mlogit R

I'm estimating a mixed model on data from a discrete choice experiment with an opt-out alternative (alternative C). I define the individual, but I still get the error message "no individual index" and the model is not estimated.

A screenshot of my data:

enter image description here

Each respondent (individual) receives 6 choice tasks, in which he has to make a choice between three alternatives (A, B or C).

My code is the following:

library("mlogit")
private_car$choice <- as.logical(private_car$choice)
private_car$optout <- ifelse(private_car$card_number == "3", "1", "-1")
V2G_data <- mlogit.data(private_car, choice="choice", shape = "long", id.var = "individual", alt.var = "card_number", id = "individual")

V2G_mixed_model <- mlogit(formula = choice ~ price + autonomy + charge + g_autonomy + saving + premie + optout | -1 | 0 ,
                    data = V2G_data,
                    rpar = c(autonomy = 'n', charge = 'n', g_autonomy  = 'n'),
                    R = 100,
                    halton = NA,
                    print.level = 0,
                    panel = TRUE)

Can someone tell me where it goes wrong?

Upvotes: 1

Views: 1331

Answers (2)

Dorien Jacobs
Dorien Jacobs

Reputation: 1

I came across the same problem, but when using your fix, I still get the error... I posted my question here: Error no individual index in mixed logit model using mlogit package in R

Upvotes: 0

Rosanne
Rosanne

Reputation: 11

I think I found the answer, thanks to your help. I had to create an identity index. The code for the mlogit.data formula should be:

V2G_mixed_model <- mlogit.data(private_car, choice = "choice", shape = "long", alt.var = "card_number", idx = c("individual", "card"))

Now it works! Many thanks again for your suggestion!

Upvotes: 0

Related Questions