Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

importance_sampling.array

Importance sampling of array


Description

Importance sampling of array

Usage

## S3 method for class 'array'
importance_sampling(
  log_ratios,
  method,
  ...,
  r_eff = NULL,
  cores = getOption("mc.cores", 1)
)

Arguments

log_ratios

An array, matrix, or vector of importance ratios on the log scale (for PSIS-LOO these are negative log-likelihood values). See the Methods (by class) section below for a detailed description of how to specify the inputs for each method.

...

Arguments passed on to the various methods.

r_eff

Vector of relative effective sample size estimates containing one element per observation. The values provided should be the relative effective sample sizes of 1/exp(log_ratios) (i.e., 1/ratios). This is related to the relative efficiency of estimating the normalizing term in self-normalizing importance sampling. If r_eff is not provided then the reported PSIS effective sample sizes and Monte Carlo error estimates will be over-optimistic. See the relative_eff() helper function for computing r_eff. If using psis with draws of the log_ratios not obtained from MCMC then the warning message thrown when not specifying r_eff can be disabled by setting r_eff to NA.

cores

The number of cores to use for parallelization. This defaults to the option mc.cores which can be set for an entire R session by options(mc.cores = NUMBER). The old option loo.cores is now deprecated but will be given precedence over mc.cores until loo.cores is removed in a future release. As of version 2.0.0 the default is now 1 core if mc.cores is not set, but we recommend using as many (or close to as many) cores as possible.

  • Note for Windows 10 users: it is strongly recommended to avoid using the .Rprofile file to set mc.cores (using the cores argument or setting mc.cores interactively or in a script is fine).

is_method

The importance sampling method to use. The following methods are implemented:

  • "psis": Pareto-Smoothed Importance Sampling (PSIS). Default method.

  • "tis": Truncated Importance Sampling (TIS) with truncation at sqrt(S), where S is the number of posterior draws.

  • "sis": Standard Importance Sampling (SIS).


loo

Efficient Leave-One-Out Cross-Validation and WAIC for Bayesian Models

v2.4.1
GPL (>= 3)
Authors
Aki Vehtari [aut], Jonah Gabry [cre, aut], Mans Magnusson [aut], Yuling Yao [aut], Paul-Christian Bürkner [aut], Topi Paananen [aut], Andrew Gelman [aut], Ben Goodrich [ctb], Juho Piironen [ctb], Bruno Nicenboim [ctb]
Initial release
2020-12-07

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.