Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
814482a
Updated pkgdown setup with GHA and building in master branch
VisruthSK Jun 13, 2025
72bb3e5
Added favicons, built site
VisruthSK Jun 13, 2025
9e785bc
Added a dependency for vignettes
VisruthSK Jun 13, 2025
743a3cc
Updated dependencies again
VisruthSK Jun 13, 2025
2e472de
Install loo before building vignettes to hopefully resolve some depen…
VisruthSK Jun 13, 2025
e010720
Adding all suggested dependencies
VisruthSK Jun 13, 2025
f15e6dd
Added BH and some params to needs
VisruthSK Jun 13, 2025
94f300b
Added some more dependencies
VisruthSK Jun 13, 2025
f10b83e
Trying to minimize computations and cache results
VisruthSK Jun 13, 2025
a878613
Only run on releases
VisruthSK Jun 13, 2025
4a5110f
Old website
VisruthSK Jun 14, 2025
7235e08
Run dontrun examples
VisruthSK Jun 17, 2025
738f5e6
Deploy dev site alongside release site
VisruthSK Jun 21, 2025
7d23048
Updated CV link
VisruthSK Jun 21, 2025
deb68a7
Don't build site on PRs and removed cache
VisruthSK Aug 26, 2025
7060851
Disable push trigger in pkgdown workflow
VisruthSK Aug 26, 2025
377ee83
Moved to BS5 and used Stan theme
VisruthSK Sep 22, 2025
fe7c6b7
Merge branch 'master' into reformat-packagedown-workflow
VisruthSK Sep 22, 2025
c227bbf
Make sure package gets installed and runs action in a new process.
VisruthSK Sep 22, 2025
46089cb
Typo
VisruthSK Sep 22, 2025
6a16914
Run vignettes by setting environment variable
VisruthSK Sep 23, 2025
cb1aaa9
Correct autocommit of generated files.
VisruthSK Sep 23, 2025
f74670a
Skipping two problematic vignettes; checked in built site.
VisruthSK Sep 23, 2025
56caf30
pkgdown: update docs [skip CI]
VisruthSK Sep 23, 2025
9cebec9
Merge pull request #302 from stan-dev/master
VisruthSK Oct 7, 2025
bdefc8a
Don't skip problem vignettes.
VisruthSK Oct 7, 2025
38b229e
Build site in gh-pages branch automatically
VisruthSK Oct 15, 2025
09a6e8e
Don't delete existing files [ci skip]
VisruthSK Oct 15, 2025
89bdf92
Merge pull request #304 from stan-dev/master
VisruthSK Oct 16, 2025
746e326
Correct DESCRIPTION to point to correct theming repository
VisruthSK Oct 17, 2025
cc3a80a
Fixed template package name
VisruthSK Oct 17, 2025
aab2fe2
Trying to simplify dependencies for build
VisruthSK Oct 18, 2025
3bc53fd
Adding pkgdown-config repo as a remote
VisruthSK Oct 18, 2025
e840f59
Point to pkgdown-config only in GHA
VisruthSK Oct 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ vignettes/loo2-non-factorizable_cache/*

^CRAN-SUBMISSION$
^release-prep\.R$
^_pkgdown\.yml$
^pkgdown$
60 changes: 60 additions & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
# build dev site on merged pushes
push:
branches: [main, master]
# build full site on releases
release:
types: [published]
workflow_dispatch:

name: pkgdown.yaml

concurrency:
group: pages
cancel-in-progress: true

jobs:
pkgdown:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::pkgdown, local::., any::withr, stan-dev/pkgdown-config

# - uses: actions/cache@v4
# with:
# path: vignettes/**/_cache
# key: knitr-${{ runner.os }}-${{ hashFiles('vignettes/**/*.Rmd') }}

- name: Build site
run: |
withr::with_envvar(
c("NOT_CRAN" = "true"), # this should already be set by setup-r@v2? keeping because vignettes don't build otherwise
pkgdown::build_site_github_pages(
lazy = FALSE, # change to TRUE if runner times out.
run_dont_run = TRUE,
new_process = TRUE
)
)
shell: Rscript {0}

- name: Deploy to GitHub pages 🚀
uses: JamesIves/github-pages-deploy-action@v4.5.0
with:
clean: false
branch: gh-pages
folder: docs
129 changes: 129 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
url: https://mc-stan.org/loo/
destination: "docs/"
template:
package: pkgdownconfig
development:
mode: auto

navbar:
title: "loo"

structure:
left: [home, vignettes, functions, pkgs, news, stan]
right: [search, bluesky, twitter, forum, github, lightswitch]

components:
home:
icon: fa-home fa-lg
href: index.html
vignettes:
text: Vignettes
href: articles/index.html
functions:
text: Functions
href: reference/index.html
pkgs:
text: Other Packages
menu:
- text: rstan
href: https://mc-stan.org/rstan
- text: cmdstanr
href: https://mc-stan.org/cmdstanr
- text: rstanarm
href: https://mc-stan.org/rstanarm
- text: bayesplot
href: https://mc-stan.org/bayesplot
- text: shinystan
href: https://mc-stan.org/shinystan
- text: projpred
href: https://mc-stan.org/projpred
- text: rstantools
href: https://mc-stan.org/rstantools
- text: posterior
href: https://mc-stan.org/posterior

articles:
- title: Getting started
desc: |
These vignettes demonstrate how to use the **loo** package to perform approximate leave-one-out cross-validation or exact K-fold cross-validation for Bayesian models fit using MCMC, compare models on estimated predictive performance on new data, and weight models for averaging predictive distributions.
contents:
- loo2-example
- loo2-weights
- loo2-with-rstan
- loo2-elpd
- title: Additional topics
desc: |
These vignettes demonstrate how to use the **loo** package for more complicated scenarios including models with non-factorized likelihoods, forecasting models, models fit to very large datasets, and more.
contents:
- loo2-non-factorized
- loo2-lfo
- loo2-large-data
- loo2-moment-matching
- loo2-mixis
- title: Frequently asked questions
contents:
- faq

external-articles:
- name: faq
title: Cross-validation FAQ
description: Answers to frequently asked questions about cross-validation and the **loo** package (links to external site).
href: https://users.aalto.fi/~ave/CV-FAQ.html

reference:
- title: Package description, glossary, and included data sets
contents:
- loo-package
- loo-glossary
- loo-datasets
- title: Approximate LOO-CV
desc: |
Approximate LOO-CV, Pareto smoothed importance sampling (PSIS), and diagnostics.
contents:
- loo
- loo_subsample
- loo_approximate_posterior
- loo_moment_match
- loo_moment_match_split
- E_loo
- psis
- ap_psis
- tis
- sis
- importance_sampling
- weights.importance_sampling
- pareto-k-diagnostic
- title: Model comparison weighting/averaging
desc: |
Functions for comparing models and computing model weights via stacking of predictive distributions or pseudo-BMA weighting.
contents:
- loo_compare
- loo_model_weights
- stacking_weights
- pseudobma_weights
- title: Helper functions for K-fold CV
contents:
- kfold_split_random
- kfold_split_stratified
- kfold_split_grouped
- kfold
- elpd
- title: Other functions
contents:
- loo_predictive_metric
- crps
- elpd
- waic
- extract_log_lik
- pointwise
- relative_eff
- gpdfit
- starts_with("example_loglik")
- print.loo
- nobs.psis_loo_ss
- obs_idx
- update.psis_loo_ss
- title: Deprecated functions
contents:
- compare
- psislw
97 changes: 1 addition & 96 deletions man/figures/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed man/figures/stanlogo.png
Binary file not shown.
Binary file added pkgdown/favicon/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pkgdown/favicon/favicon-96x96.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pkgdown/favicon/favicon.ico
Binary file not shown.
3 changes: 3 additions & 0 deletions pkgdown/favicon/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions pkgdown/favicon/site.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "",
"short_name": "",
"icons": [
{
"src": "/web-app-manifest-192x192.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "maskable"
},
{
"src": "/web-app-manifest-512x512.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "maskable"
}
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
}
Binary file added pkgdown/favicon/web-app-manifest-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pkgdown/favicon/web-app-manifest-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions vignettes/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 30 additions & 9 deletions vignettes/loo2-moment-matching.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,20 @@ Next we fit the model in Stan using the __rstan__ package:
data(roaches, package = "rstanarm")
roaches$roach1 <- sqrt(roaches$roach1)
y <- roaches$y
x <- roaches[,c("roach1", "treatment", "senior")]
offset <- log(roaches[,"exposure2"])
x <- roaches[, c("roach1", "treatment", "senior")]
offset <- log(roaches[, "exposure2"])
n <- dim(x)[1]
k <- dim(x)[2]

standata <- list(N = n, K = k, x = as.matrix(x), y = y, offset = offset, beta_prior_scale = 2.5, alpha_prior_scale = 5.0)
standata <- list(
N = n,
K = k,
x = as.matrix(x),
y = y,
offset = offset,
beta_prior_scale = 2.5,
alpha_prior_scale = 5.0
)

# Compile
stanmodel <- stan_model(model_code = stancode)
Expand Down Expand Up @@ -239,7 +247,9 @@ __rstan__ objects, the functions look like this:
.create_skeleton <- function(pars, dims) {
out <- lapply(seq_along(pars), function(i) {
len_dims <- length(dims[[i]])
if (len_dims < 1) return(0)
if (len_dims < 1) {
return(0)
}
return(array(0, dim = dims[[i]]))
})
names(out) <- pars
Expand All @@ -254,7 +264,7 @@ post_draws_stanfit <- function(x, ...) {
# compute a matrix of log-likelihood values for the ith observation
# matrix contains information about the number of MCMC chains
log_lik_i_stanfit <- function(x, i, parameter_name = "log_lik", ...) {
loo::extract_log_lik(x, parameter_name, merge_chains = FALSE)[, , i]
loo::extract_log_lik(x, parameter_name, merge_chains = FALSE)[,, i]
}

# transform parameters to the unconstraint space
Expand All @@ -272,13 +282,24 @@ unconstrain_pars_stanfit <- function(x, pars, ...) {

# compute log_prob for each posterior draws on the unconstrained space
log_prob_upars_stanfit <- function(x, upars, ...) {
apply(upars, 1, rstan::log_prob, object = x,
adjust_transform = TRUE, gradient = FALSE)
apply(
upars,
1,
rstan::log_prob,
object = x,
adjust_transform = TRUE,
gradient = FALSE
)
}

# compute log_lik values based on the unconstrained parameters
log_lik_i_upars_stanfit <- function(x, upars, i, parameter_name = "log_lik",
...) {
log_lik_i_upars_stanfit <- function(
x,
upars,
i,
parameter_name = "log_lik",
...
) {
S <- nrow(upars)
out <- numeric(S)
for (s in seq_len(S)) {
Expand Down
6 changes: 6 additions & 0 deletions vignettes/loo2-non-factorized_cache/html/__packages
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
knitr
loo
Rcpp
brms
bayesplot
ggplot2
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading