I am doing a choice experiment using a random parameter logit model using the mixlogit command "mixlogit choice price no, rand(a b) group(group) id(id)", how do I calculate the marginal effects?
I tried the following command and the result seems to be incorrect, the RPL coefficient is positive, but the marginal effect calculated with this command is negative.Any help will be much appreciated.
preserve
set seed 12345
gen rnd = runiform()
bysort id groupid (rnd): gen alt=_n
replace a = 0 if alt==1
mixlpred p0, nrep(500)
replace a=1 if alt==1
mixlpred p1, nrep(500)
gen p_diff = p1-p0
sum p_diff if alt==1
restore