utility_pseudo {qslice}R Documentation

Utility for a given target and pseudo-target

Description

Takes a pseudo-target and target (or samples from the target) and evaluates the utility function for the transformed target, which can be one of Area Under the Curve (AUC) and Mean Slice Width (MSW). See Heiner et al. (2024+).

Usage

utility_pseudo(
  pseudo,
  log_target = NULL,
  samples = NULL,
  type = "samples",
  x = NULL,
  nbins = 30,
  plot = TRUE,
  utility_type = "AUC",
  tol_int = 0.001
)

Arguments

pseudo

List containing the following functions with scalar input:

ld: function to evaluate the log density

q: function to evaluate the quantile function

p: function to evaluate the distribution function

log_target

Function to evaluate the log density of the unnormalized target.

samples

Numeric vector of samples from the target distribution.

type

String specifying the input type. One of "function", "samples", or "grid". Default is to use "samples".

Use of "function" requires specification of log_target.

Use of "samples" requires specification of samples.

Use of "grid" requires specification of x.

x

Numeric vector specifying grid (on (0,1)) over which to evaluate the transformed target. Defaults to NULL.

nbins

Number of histogram bins to use (defaults to 30). Must match the length of x if x is supplied.

plot

Logical for whether to generate two plots:

  1. direct comparison of the target and pseudo-target densities, and

  2. transformed target density.

Defaults to TRUE.

utility_type

String identifying utility type, either AUC (default) or MSW.

tol_int

Positive numeric scalar that passes to abs.tol in the call to integrate. Defaults to 1.0e-3.

Details

Optionally plot the target and pseudo-target densities as well as the transformed tartet.

Value

Scalar value of the utility function evaluation.

References

Heiner, M. J., Johnson, S. B., Christensen, J. R., and Dahl, D. B. (2024+), "Quantile Slice Sampling," arXiv preprint arXiv:###.

Examples

pseu <- pseudo_list(family = "logistic", params = list(loc = 0.0, sc = 0.66))
ltarg <- list(ld = function(x) dnorm(x, log = TRUE))
oldpar <- par(mfrow = c(1,2))
utility_pseudo(pseudo = pseu, log_target = ltarg$ld, type = "function",
               nbins = 100, utility_type = "MSW")
samp <- rnorm(10e3)
utility_pseudo(pseudo = pseu, samples = samp, type = "samples", utility_type = "AUC")
utility_pseudo(pseudo = pseu, samples = samp, type = "samples", utility_type = "MSW")
par(oldpar)


[Package qslice version 0.3.1 Index]