brinckmann / montepython_public

Public repository for the Monte Python Code
MIT License
92 stars 78 forks source link

Obtaining posteriors from single likelihoods. #340

Closed ClaudioNahmad closed 8 months ago

ClaudioNahmad commented 11 months ago

Hello Thejs, and anyone else reading (:

This may be a dumb question or may expose my poor knowledge around Markov Chains but despite, maybe it could help another disoriented spirit around here.

I'm running a series of chains with multiple likelihoods (BAO DR12, DR16 [the ones which don't superimpose], Planck_lite and Pantheon Plus). When the chains are analyzed using the --info flag, we get the posterior distribution after the MCMC explored the parameter space, using all the datasets (or likelihoods) forementioned. My question is: Is there a way to ask MP to calculate the posterior distributions associated with a single dataset (e.g., if i ran BAO,Planck,Pantheon and just want to see the posterior associated with BAO)? Or do i have to run separate markov chains (one with BAO+CMB+SN, one with BAO, one with CMB, one with SN)?

I hope my question is well formulated and understandable.

I understand that MP can compute the individual chi^2 (individual in the sense that each one is associated with a certain dataset/likelihood) when running-run -f 0 --display-each-chi2 at the best fit value. But is it possible to obtain the whole posterior distribution of an individual dataset?

Thanks for all the excellent responses, i've been posting quite a few questions and issues lately. The code is so complex to me that it even excites me to learn each function profoundly!

Best, -Claudio

dchooper commented 8 months ago

Hi,

Unfortunately it's not possible to get the posterior from an individual likelihood when this was used in combination with other likelihoods. At each point in the chain the overall likelihood is calculated and used to decide if the point is accepted/rejected, so then only the sum is really stored.

Using the -run -f 0 --display-each-chi2 argument is usually done on one point only, and requires using the run command in MontePython` - so you essentially rerun the point forcing it to keep the individual chi2 as well.

In conclusion, to get the individual posteriors for each likelihood, you would need to run separate MCMCs for each individual likelihoods.

Cheers, Deanna

brinckmann commented 8 months ago

As a note, this is something I would like to add as it's a really nice feature, even if posteriors beyond the preferred region of the total likelihood would become increasingly unreliable it would still help with debugging and with understanding your results. But from an implementation standpoint we have to be a little careful storing individual likelihood values in the chains files, making sure not to break anything, including the ability to analyze old chains and to analyze new chains with old MontePython versions. But indeed, currently this is unfortunately not an option and the only way is to brute force it as Deanna suggests. Also, apologies, the question got lost in the Summer heat!

Best, Thejs