# NOT RUN {
## Examples using the Electricity data set from the mlogit package
library(mlogit)
data("Electricity", package = "mlogit")
Electr <- mlogit.data(Electricity, id.var = "id", choice = "choice",
varying = 3:26, shape = "wide", sep = "")
## Estimate a MIXL model with correlated random parameters
Elec.cor <- gmnl(choice ~ pf + cl + loc + wk + tod + seas| 0, data = Electr,
subset = 1:3000,
model = 'mixl',
R = 10,
panel = TRUE,
ranp = c(cl = "n", loc = "n", wk = "n", tod = "n", seas = "n"),
correlation = TRUE)
## Plot the density of the conditional expectation distribution of loc
plot(Elec.cor, par = "loc", effect = "ce", type = "density", col = "grey")
## Plot the conditional expectation of loc for each individual
plot(Elec.cor, par = "loc", effect = "ce", ind = TRUE, id = 1:30)
## Plot the WTP for cl
plot(Elec.cor, par = "loc", effect = "wtp", wrt = "pf")
# }
Run the code above in your browser using DataLab