Exercise

# Chocolate model with random price coefficient

Okay, we're ready to fit a hierarchical model to the `chocolate`

data. Let's start with the code we had before to estimate a non-hierarchical choice model and modify it to estimate a model where the `Price`

parameter is normally distributed. The `chocolate`

data is still loaded.

Instructions

**100 XP**

- Add the input
`id.var = "Subject"`

to`mlogit.data()`

. This tells`mlogit.data()`

which person answered each question. - Add the
`rpar`

input to`mlogit()`

. It should be equal to`c(Price = "n")`

to indicate that you want the coefficient for`Price`

to be normally distributed. - Add the
`panel = TRUE`

input to`mlogit()`

to tell it that you want to assume each`Subject`

has his or her own`Price`

coefficient. - Plot the the hierarchical model by typing
`plot(choc_m6)`

.