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

update manuals for Laplace approximation, optimization allows Jacobian adjustment #606

Merged
merged 11 commits into from
Jan 3, 2023

Conversation

mitzimorris
Copy link
Member

@mitzimorris mitzimorris commented Dec 21, 2022

Submission Checklist

  • Builds locally
  • New functions marked with `r since("VERSION")`
  • Declare copyright holder and open-source license: see below

Summary

Updated the CmdStan and Reference Manual to reflect changes made in PRs stan-dev/cmdstan#1134, stan-dev/stan#3148, and stan-dev/stan#3152

Issues: #596 and #595

Copyright and Licensing

Please list the copyright holder for the work you are submitting (this will be you or your assignee, such as a university or company): Columbia University

By submitting this pull request, the copyright holder is agreeing to license the submitted work under the following licenses:

@mitzimorris
Copy link
Member Author

Do we need a citation for Laplace approx for Ref manual, and if so, what's a good one?

The `laplace` method produces a sample from a Laplace approximation
centered at the mode of a distribution.
If the mode is a maximum a posteriori (MAP) estimate,
the samples provides an estimate of the standard deviation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to explicitly mention here the effect of the constraints. If there are constrained parameters, the Laplace approximation works best in the unconstrained space. The normal approximation is then centered at the mode in the unconstrained space, but the implemented method transforms the normal approximation sample to the constrained space before writing them to csv. Due to the transformation, the samples can provide more than just the standard deviation estimate.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this discussion should go in the reference manual algorithms section, and we should link to that from here.

I'm confused by what you say - the laplace_sample algorithm always computes on the unconstrained space, and outputs on the constrained scale - that is the way that all the Stan inference algorithms work, so why mention this?

Due to the transformation, the samples can provide more than just the standard deviation estimate.

what additional inforamation is provided? a better estimate of the mode as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apologies - my confusion here is that while the stan::services method laplace_sample takes its inputs on the unconstrained scale, the CmdStan interface takes its inputs on the constrained scale, and then does the unconstrain before calling the laplace_sample method. this is an implementation detail that the user doesn't need to know about.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added discussion of this to the Laplace section in the reference manual.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would still change this also here, e.g.
"The laplace method produces a sample from a normal approximation
centered at the mode of a distribution in the unconstrained space.
If the mode is a maximum a posteriori (MAP) estimate,
the samples provide an estimate of the mean and standard deviation
of the posterior distribution."

In case of constraints, in general the posterior mode in the unconstrained space doesn't correspond to the mean (nor mode) in the constraint space, and thus the sample is needed also to infer the mean.

src/cmdstan-guide/laplace_sample_config.Rmd Outdated Show resolved Hide resolved
src/cmdstan-guide/laplace_sample_config.Rmd Outdated Show resolved Hide resolved
src/cmdstan-guide/laplace_sample_config.Rmd Show resolved Hide resolved
src/cmdstan-guide/optimize_config.Rmd Outdated Show resolved Hide resolved
src/cmdstan-guide/optimize_config.Rmd Outdated Show resolved Hide resolved
src/reference-manual/analysis.Rmd Outdated Show resolved Hide resolved
@mitzimorris
Copy link
Member Author

thanks for the careful review - changes made - ready for re-review

@mitzimorris mitzimorris requested a review from avehtari December 31, 2022 21:33
The `laplace` method produces a sample from a Laplace approximation
centered at the mode of a distribution.
If the mode is a maximum a posteriori (MAP) estimate,
the samples provides an estimate of the standard deviation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would still change this also here, e.g.
"The laplace method produces a sample from a normal approximation
centered at the mode of a distribution in the unconstrained space.
If the mode is a maximum a posteriori (MAP) estimate,
the samples provide an estimate of the mean and standard deviation
of the posterior distribution."

In case of constraints, in general the posterior mode in the unconstrained space doesn't correspond to the mean (nor mode) in the constraint space, and thus the sample is needed also to infer the mean.

src/cmdstan-guide/laplace_sample_config.Rmd Outdated Show resolved Hide resolved
src/reference-manual/analysis.Rmd Outdated Show resolved Hide resolved
src/reference-manual/laplace.Rmd Outdated Show resolved Hide resolved
src/reference-manual/optimization.Rmd Outdated Show resolved Hide resolved
@mitzimorris
Copy link
Member Author

made all suggested changes.

Copy link
Contributor

@avehtari avehtari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were two cases with both old and new text lines, but otherwise looks good

src/cmdstan-guide/laplace_sample_config.Rmd Outdated Show resolved Hide resolved
src/reference-manual/analysis.Rmd Outdated Show resolved Hide resolved
Copy link
Contributor

@avehtari avehtari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to merge

@mitzimorris mitzimorris merged commit aaa7b46 into master Jan 3, 2023
@WardBrian WardBrian deleted the cmdstan-laplace-log-prob branch March 23, 2023 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants