-
-
Notifications
You must be signed in to change notification settings - Fork 256
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
Bayesian copula estimation example notebook #257
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
View / edit / reply to this conversation on ReviewNB OriolAbril commented on 2021-12-18T11:42:16Z I would use the filename also as target to reference the notebook so it's not necessary to open the notebook and look at the source to know what target to use.
I also looked at the raw text and saw you are using an html figure to format the image and caption. You should use https://myst-parser.readthedocs.io/en/latest/syntax/optional.html#markdown-figures. This mimimizes html needed which makes sphinx recognize the image, copy it to the drbenvincent commented on 2021-12-19T12:00:32Z Thanks. Have done these things now.
I also simplified the logos. Rather than 2 separate files in a markdown table, I just have a single image with both logos now and no markdown table. Should avoid any strange table rendering issues. OriolAbril commented on 2021-12-19T16:45:55Z The |
View / edit / reply to this conversation on ReviewNB OriolAbril commented on 2021-12-18T11:42:17Z I need to add a huge warning to the jupyter style guide about this, but never use html links to refer to other notebooks or to other documentation pages. They much more prone to breaking and can't by design respect the version of the documentation being read, they will always point to latest. The binning uses
{ref}
to generate a link with text here pointing to the binning notebook drbenvincent commented on 2021-12-19T12:03:43Z This should hopefully be fixed now. OriolAbril commented on 2021-12-19T16:48:34Z The ref won't work like this. reviewnb messed up the formatting, but you need 3 things, the reference type (ref), the text to be shown (here) and the target where the link should point to (awkward_binning). See https://docs.readthedocs.io/en/stable/guides/cross-referencing-with-sphinx.html#the-ref-role for more details |
View / edit / reply to this conversation on ReviewNB OriolAbril commented on 2021-12-18T11:42:18Z Line #6. np.random.seed(seed=42) this should use From numpy docs: https://numpy.org/doc/stable/reference/random/legacy.html#legacy
This class should only be used if it is essential to have randoms that are identical to what would have been produced by previous versions of NumPy.
which I don't think is the case here. drbenvincent commented on 2021-12-19T12:11:24Z Thanks, I didn't know SciPy distributions took |
View / edit / reply to this conversation on ReviewNB OriolAbril commented on 2021-12-18T11:42:18Z Is something in the computation of
drbenvincent commented on 2021-12-19T12:17:38Z I'm not sure I follow this question. Is this about lines 14, 15, 16? That computation could be done before, outside of the model as ericmjl commented on 2021-12-19T15:18:32Z Some notes from talking with Oriol:
|
View / edit / reply to this conversation on ReviewNB OriolAbril commented on 2021-12-18T11:42:19Z how does this differ from the drbenvincent commented on 2021-12-19T12:42:52Z As far as I can tell, we could use
Doing this results in
But it's not immediately obvious to me how to iterate over the ericmjl commented on 2021-12-19T15:22:57Z Possibly a transpose. (Just leaving a note from calling Oriol.)
ericmjl commented on 2021-12-20T00:37:51Z @drbenvincent I think a transpose is what we can do. For an array that is of shape (2, 2, 4000), I think a transpose using OriolAbril commented on 2021-12-20T00:48:39Z I did some xarray+arviz black magic and updated all the calculations to use the full posterior, which does seem to give the same result. Feel free to use all or parts of that. If doing the transposition here however, do it with xarray and take the values after that. You can use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why the readthedocs build is failing, will try to look into it at some point.
Thanks. Have done these things now.
I also simplified the logos. Rather than 2 separate files in a markdown table, I just have a single image with both logos now and no markdown table. Should avoid any strange table rendering issues. View entire conversation on ReviewNB |
This should hopefully be fixed now. View entire conversation on ReviewNB |
Thanks, I didn't know SciPy distributions took View entire conversation on ReviewNB |
I'm not sure I follow this question. Is this about lines 14, 15, 16? That computation could be done before, outside of the model as View entire conversation on ReviewNB |
Might need input from Eric here to double check View entire conversation on ReviewNB |
As far as I can tell, we could use
Doing this results in
But it's not immediately obvious to me how to iterate over the View entire conversation on ReviewNB |
Thanks @OriolAbril. I've dealt with all of those points except for two questions. FYI. Also need some review (when @ericmjl is able) before we merge this. Could you tag his as a reviewer? I don't seem to be able to request reviewers. |
I don't understand why the graphviz images aren't displaying. |
Some notes from talking with Oriol:
View entire conversation on ReviewNB |
Possibly a transpose. (Just leaving a note from calling Oriol.)
View entire conversation on ReviewNB |
The View entire conversation on ReviewNB |
The ref won't work like this. reviewnb messed up the formatting, but you need 3 things, the reference type (ref), the text to be shown (here) and the target where the link should point to (awkward_binning). See https://docs.readthedocs.io/en/stable/guides/cross-referencing-with-sphinx.html#the-ref-role for more details View entire conversation on ReviewNB |
Don't trust reviewnb preview, always check the readthedocs preview to see if things look good or not. reviewnb messes up quite often, and even in the case it did work, what readers will actually see is readthedocs, so this is what we need to double check. |
@drbenvincent I think a transpose is what we can do. For an array that is of shape (2, 2, 4000), I think a transpose using View entire conversation on ReviewNB |
I did some xarray+arviz black magic and updated all the calculations to use the full posterior, which does seem to give the same result. Feel free to use all or parts of that. If doing the transposition here however, do it with xarray and take the values after that. You can use View entire conversation on ReviewNB |
Thanks @OriolAbril. That last commit cleans everything up, and uses your recommended way of getting the posterior data of |
View / edit / reply to this conversation on ReviewNB OriolAbril commented on 2021-12-27T21:56:31Z The drbenvincent commented on 2021-12-28T10:43:31Z Extra comma now removed.
|
View / edit / reply to this conversation on ReviewNB OriolAbril commented on 2021-12-27T21:56:31Z This is using point estimates only for computations that are not commutative with the expectation. I did try using the whole posterior here then averaging to get
In my opinion there are two options here:
Note: I have several ideas that hopefully will crystalize in a small package extending xarray for linear algebra and statistical computation. I have a note to come back here once that is available to simplify the code using this while using the whole posterior
ericmjl commented on 2021-12-28T00:58:25Z I think the spelling of transform is incorrect. Should be
drbenvincent commented on 2021-12-28T10:43:10Z Typo fixed.
I will add some text (shortly) to mention why we are using point estimates. drbenvincent commented on 2021-12-28T12:05:15Z In fact, we've already got a note about point estimates under the heading "PyMC models for copula and marginal estimation"
ericmjl commented on 2021-12-28T19:38:33Z Copying Oriol's point from the discussion to keep the discussion a bit easier to follow:
The note is about simultaneous estimation or fitting marginal and covariance models independently, but doesn't address marginalizing before or after the transformation between observed and multivariate spaces. The marginalization after transforming is one if the things I tried and did give the same result, but the two approaches giving the same result isn't straightforward (to me at least) as the operations don't commute with the expectation.
I think I see where Oriol's point - if the expectation of a distribution is E(dist), then exp(E(dist)) is not necessarily equal to E(exp(dist)).
However, we're doing an exp(logcdf(E(dist))) here, not exp(E(dist)). Oriol, I'll readily admit to being ignorant here, but does that change anything? ericmjl commented on 2022-01-17T16:21:16Z Copying Oriol's point from the GitHub PR tracker to keep the discussion easier to follow:
The thing is that even if the evaluation of the logcdf are the observations and thus not a random variable, it's parameters are, so I think it's something like E(probit(exp(logcdf(x|dist)))) or probit(exp(logcdf(x|E(dist)))) which doesn't seem like they must be the same
Upon thinking about your point, Oriol, I think it is easiest for now to leave a not on why we're not using the whole posterior. I think I get your point, and it makes sense, though I'm also aware that we should close things out before they get dragged on too long, and it's easiest to add a comment than to try to change the logic of the code.
Ben, please be on the lookout for a few more textual changes to push! |
View / edit / reply to this conversation on ReviewNB OriolAbril commented on 2021-12-27T21:56:32Z This title is a level 1 title and should be level 2 title to preserve the right hierarchy. It should probably be updated too now that sample_posterior_predictive is not being used. Something about comparing inference and truths is probably more fitting drbenvincent commented on 2021-12-28T10:42:38Z Fixed |
I think the spelling of transform is incorrect. Should be
View entire conversation on ReviewNB |
Fixed View entire conversation on ReviewNB |
Typo fixed.
I will add some text (shortly) to mention why we are using point estimates. View entire conversation on ReviewNB |
Housekeeping done. Ready to try to get this over the finish line... |
Took me a while to fix some issues - waiting for docs to build etc. But notebook looks good now :) |
View / edit / reply to this conversation on ReviewNB twiecki commented on 2023-11-30T00:14:54Z *a value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
requesting one change to make sure we don't break any cross-references, after that ready to merge
Thanks for the comments @ricardoV94. Not sure how it happened, but the comments were to an old version where many of those issues were resolved. But I did change |
This pull request adds a new example notebook for Bayesian copula estimation. Work done by myself and @ericmjl.
cores=1
to avoid anEOFError