Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider whether exoplanet should use DensityDist rather than Potential #70

Closed
mrtommyb opened this issue Nov 22, 2019 · 6 comments
Closed
Labels
documentation Missing docs or mistakes in existing ones

Comments

@mrtommyb
Copy link
Contributor

PyMC3 recommended way to include a custom likelihood function is with pm.DensityDist, e.g.

loglike = pm.DensityDist('loglike', logp, observed=y)

However in the exoplanet examples, the the GP likelihood is implemented as pm.Potential. The results are the same but it might be sensible to implement the samples using the standard PyMC3 way of doing it. Advantages include clear separating out of the observables. Additionally, some of the nice plotting functions like model_to_graphviz ignore potentials.

Here's an example of what it would look like

pm.DensityDist("loglike", gp.log_likelihood, observed=(y - light_curve - mean))
@mrtommyb mrtommyb added the bug Something isn't working label Nov 22, 2019
@dfm dfm added documentation Missing docs or mistakes in existing ones and removed bug Something isn't working labels Nov 22, 2019
@dfm
Copy link
Member

dfm commented Nov 22, 2019

I think this would be cool, but it would probably be better to separate y from mean + light_curve since that is actually the mean. I've been working on a better GP interface, but who knows how long it will take so I'd love a pull request to dfm/exoplanet-docs that changes the notation.

@mrtommyb
Copy link
Contributor Author

Ok. I will try to work on it.

@dfm
Copy link
Member

dfm commented Jan 3, 2020

@mrtommyb: I implemented this on the flight to AAS. It's on the new_gp branch if you want to take a look: https://github.com/dfm/exoplanet/blob/new_gp/src/exoplanet/gp/celerite.py#L117

The syntax is now something like:

with pm.Model():
    kernel = xo.gp.terms....
    gp = xo.gp.GP(kernel, x, yerr**2, ...)
    gp.marginal("likelihood", observed=y)

@bmorris3
Copy link

Hi @dfm,

I'm working on a model which uses exoplanet to compute a transit+phase curve+eclipse model. I have a derived parameter (an eclipse depth) produced in my phase curve model which is wrapped in pm.Deterministic, and I would like to enforce a prior on this variable (eclipse depth), in order to be consistent with a value in the literature. I was thinking the easiest way to do this would be to run something like:

        pm.Potential('spitzer_depth_potential', pm.Normal.dist(0, 300).logp(spitzer_depth))

where spitzer_depth is the Deterministic, and its measured value is 0 ± 300 [ppm]. Will this work if I'm running gp.marginal later (like you eventually settled on) to create define the likelihood? Or is this a bad idea?

@dfm
Copy link
Member

dfm commented Feb 18, 2021

@bmorris3: There shouldn't be any issue with that syntax, but a simpler one might be:

pm.Normal("spitzer_depth_prior", mu=spitzer_depth, sigma=300, observed=0.0)

Which should work equivalently and I find somewhat more readable. (You can think of this "prior" as, instead, "data" from a previous experiment.)

@bmorris3
Copy link

Thanks for this, that's definitely more readable!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Missing docs or mistakes in existing ones
Projects
None yet
Development

No branches or pull requests

3 participants