I am trying to see what people’s willingness to pay is for either nuclear or wind energy (far away or local) through a stated choice preference. I used the multinomial logit model, however when estimating the discreet choice for the different scenarios I keep getting an error:
Error in t.default(x) : argument is not a matrix
While gmnl gives this error, mixl seems to be working fine
Code:
install.packages("gmnl")
install.packages("mlogit")
library("gmnl") # Load gmnl package
library("mlogit") # Load mlogit package
library(readxl)
Example_data <- read_excel("Example data.xlsx")
View(Example_data)
data <- as.data.frame(Example_data)
df01 <- mlogit.data(data,
id.var = "id",
choice = "Choice",
varying = 3:17,
shape = "wide",
sep = "")
lc <- gmnl(Choice ~ MODE + DWELLING + SIZE + COST + DISTANCE | 0 | 0 | 0 | 1 ,
data = df01,
model="lc",
Q = 3,
panel = TRUE,
method = "bhhh")
It could be that there is something wrong with my data. However, when comparing previous works from other people my data is setup in a similar way and I cannot run their calculations either.
From what I have seen with earlier posts, it could also be a package problem. But what can I do to fix it or continue if that is the case.
The picture below shows an example of the data for 2 individuals, which consists of 15 scenarios with 3 options to choose from.
Example_data
Read more here: Source link