> On 11 Feb 2025, at 04:08, 可可 <
kek3...@gmail.com> wrote:
>
> Thank you for your reply, it gives me a better understanding of 2-dimension numerical integration.
>
> I have another question about calculating the condlike. Assuming that my latent variables are AA and CC, when calculating the condlike do I multiply all P_AA_0X and P_CC_0X directly together? Or do I multiply them separately and calculate condlike_AA and condlike_CC separately?
> My current code calculates condlike by multiplying all P_AA_0X and P_CC_0X directly together:
>
> condprob = models.logit (V, av, choice)
> condlike = P_AA_01 * P_AA_02 * P_AA_03 * P_CC_01 * P_CC_02 * P_CC_03 * condprob
> first_integral = Integrate(condlike * density_1, 'omega_1')
> second_integral = Integrate(first_integral * density_2, 'omega_2')
> loglike = log(second_integral)
Yes, this is correct. "condlike" represents the likelihood, conditional on the random parameters. And the likelihood is the product of the probabilities. So you need to calculate it first, and then integrate.