powerscale_derivative: Derivative with respect to power-scaling

View source: R/powerscale_derivative.R

powerscale_derivativeR Documentation

Derivative with respect to power-scaling

Description

Calculate the analytical derivative of a quantity with respect to power-scaling prior or likelihood.

Usage

powerscale_derivative(x, log_component, quantity = "mean", ...)

Arguments

x

Posterior draws.

log_component

Log likelihood or log prior values.

quantity

Character specifying quantity of interest (default is "mean"). Options are "mean", "sd", "var".

...

unused

Value

Derivative of the quantity with respect to log2 of the power-scaling factor (alpha).

Examples

example_model <- example_powerscale_model()
draws <- example_model$draws
log_prior <- log_prior_draws(draws, joint = TRUE)
posterior::summarise_draws(
    posterior::subset_draws(draws, variable = c("mu", "sigma")),
    mean,
    mean_sens = ~powerscale_derivative(.x, log_prior, quantity = "mean")
)

n-kall/priorsense documentation built on Nov. 4, 2024, 10:30 p.m.