I am trying to calculate a multinomial model in R with the logitr package. I have discrete choice experiment data set.
CHOICE ID_resp alt price amadori aia fileni smarket bio aperto terra
1 1 1 1 8.9 1 0 0 0 1 0 0
2 0 1 2 13.9 0 1 0 0 0 1 0
3 0 1 3 18.9 0 0 1 0 0 0 1
4 0 1 4 23.9 0 0 0 1 0 0 0
5 0 1 5 0.0 0 0 0 0 0 0 0
6 0 1 1 23.9 1 0 0 0 0 0 0
standard
1 0
2 0
3 0
4 1
5 0
6 1
The structure of the data is:
'data.frame': 26200 obs. of 12 variables:
$ CHOICE : Factor w/ 2 levels "0","1": 2 1 1 1 1 1 2 1 1 1 ...
$ ID_resp : int 1 1 1 1 1 1 1 1 1 1 ...
$ alt : Factor w/ 5 levels "1","2","3","4",..: 1 2 3 4 5 1 2 3 4 5 ...
$ price : num 8.9 13.9 18.9 23.9 0 23.9 8.9 13.9 18.9 0 ...
$ amadori : int 1 0 0 0 0 1 0 0 0 0 ...
$ aia : int 0 1 0 0 0 0 1 0 0 0 ...
$ fileni : int 0 0 1 0 0 0 0 1 0 0 ...
$ smarket : int 0 0 0 1 0 0 0 0 1 0 ...
$ bio : int 1 0 0 0 0 0 1 0 0 0 ...
$ aperto : int 0 1 0 0 0 0 0 1 0 0 ...
$ terra : int 0 0 1 0 0 0 0 0 1 0 ...
$ standard: int 0 0 0 1 0 1 0 0 0 0 ...
the formula for the model is:
mnl_model <- logitr(
data = model_df,
outcome = "CHOICE",
obsID = "ID_resp",
pars = c("price", "amadori","aia","fileni","smarket","bio","aperto"
,"terra" ,"standard")
)
However, I receive the following error Error in sum(x) : invalid 'type' (character) of argument