Skip to content

Commit

Permalink
Merge pull request #875 from stan-dev/avehtari-patch-1
Browse files Browse the repository at this point in the history
Improve Pathfinder doc
  • Loading branch information
jgabry authored Nov 10, 2023
2 parents a6f35c9 + cf75886 commit 1570fd4
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 22 deletions.
24 changes: 16 additions & 8 deletions R/model.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
#' fit_optim <- mod$optimize(data = my_data_file, seed = 123)
#' fit_optim$summary()
#'
#' # Run 'optimize' again with 'jacobian=TRUE' and then draw from laplace approximation
#' # Run 'optimize' again with 'jacobian=TRUE' and then draw from Laplace approximation
#' # to the posterior
#' fit_optim <- mod$optimize(data = my_data_file, jacobian = TRUE)
#' fit_laplace <- mod$laplace(data = my_data_file, mode = fit_optim, draws = 2000)
Expand All @@ -109,6 +109,11 @@
#' fit_pf$summary()
#' mcmc_hist(fit_pf$draws("theta"))
#'
#' # Run 'pathfinder' again with more paths, fewer draws per path,
#' # better covariance approximation, and fewer LBFGSs iterations
#' fit_pf <- mod$pathfinder(data = stan_data, num_paths=10, single_path_draws=40,
#' history_size=50, max_lbfgs_iters=100)
#'
#' # Specifying initial values as a function
#' fit_mcmc_w_init_fun <- mod$sample(
#' data = stan_data,
Expand Down Expand Up @@ -1539,7 +1544,7 @@ optimize <- function(data = NULL,
CmdStanModel$set("public", name = "optimize", value = optimize)


#' Run Stan's laplace algorithm
#' Run Stan's Laplace algorithm
#'
#' @name model-method-laplace
#' @aliases laplace
Expand Down Expand Up @@ -1828,12 +1833,15 @@ CmdStanModel$set("public", name = "variational", value = variational)
#' @description The `$pathfinder()` method of a [`CmdStanModel`] object runs
#' Stan's Pathfinder algorithms. Pathfinder is a variational method for
#' approximately sampling from differentiable log densities. Starting from a
#' random initialization, Pathfinder locates normal approximations to the
#' target density along a quasi-Newton optimization path, with local
#' covariance estimated using the negative inverse Hessian estimates produced
#' by the L-BFGS optimizer. Pathfinder returns draws from the Gaussian
#' approximation with the lowest estimated Kullback-Leibler (KL) divergence to
#' the true posterior. See the
#' random initialization, Pathfinder locates normal approximations
#' to the target density along a quasi-Newton optimization path in
#' the unconstrained space, with local covariance estimated using
#' the negative inverse Hessian estimates produced by the LBFGS
#' optimizer. Pathfinder selects the normal approximation with the
#' lowest estimated Kullback-Leibler (KL) divergence to the true
#' posterior. Finally Pathfinder draws from that normal
#' approximation and returns the draws transformed to the
#' constrained scale. See the
#' [CmdStan User’s Guide](https://mc-stan.org/docs/cmdstan-guide/)
#' for more details.
#'
Expand Down
7 changes: 6 additions & 1 deletion man/CmdStanModel.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion man/cmdstan_model.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion man/cmdstanr-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/model-method-laplace.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion man/model-method-optimize.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 15 additions & 7 deletions man/model-method-pathfinder.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion man/model-method-sample.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion man/model-method-variational.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1570fd4

Please sign in to comment.