Calculate the numerical derivative of posterior quantities/divergence with respect to power-scaling the specified component (prior or likelihood). This is done using importance sampling (and optionally moment matching).
powerscale_gradients(x, ...)# S3 method for default
powerscale_gradients(
x,
log_prior_name = "lprior",
log_lik_name = "log_lik",
...
)
# S3 method for priorsense_data
powerscale_gradients(
x,
variable = NULL,
component = c("prior", "likelihood"),
type = c("quantities", "divergence"),
lower_alpha = 0.99,
upper_alpha = 1.01,
div_measure = "cjs_dist",
measure_args = list(),
moment_match = FALSE,
k_threshold = 0.5,
resample = FALSE,
transform = NULL,
prediction = NULL,
scale = FALSE,
prior_selection = NULL,
likelihood_selection = NULL,
...
)
Maximum of the absolute derivatives above and below alpha = 1.
Model fit or draws object.
Further arguments passed to functions.
Character (case sensitive) specifying name of the variable storing the log prior evaluations
Character (case sensitive) specifying name of the variable storing the log likelihood evaluations
Variables to compute sensitivity of. If NULL (default) sensitivity is computed for all variables.
Component to power-scale (prior or likelihood).
type of sensitivity to measure ("distance", "quantity"). Multiple options can be specified at the same time.
lower power to scale component by, should be < 1 (default is 0.9).
upper power to scale component by, should be > 1 (default is 1.1).
Character (case sensitive) specifying the divergence measure to use. The following methods are implemented:
"cjs_dist"
: Cumulative Jensen-Shannon distance. Default
method. See function cjs_dist
for more details.
"js_dist"
: Jensen-Shannon distance.
"js_div"
: Jensen-Shannon divergence.
"hellinger_dist"
: Hellinger distance.
"kl_dist"
: Kullback-Leibler distance.
"kl_div"
: Kullback-Leibler divergence.
"ks_dist"
: Kolmogorov-Smirnov distance.
"hellinger_dist"
: Hellinger distance.
"ws_dist"
: Wassterstein distance (pass measure_args = list(p = N)
)
for a different order, where N is the order.
Named list of further arguments passed to divergence measure functions.
Logical; Indicate whether or not moment
matching should be performed. Can only be TRUE if is_method
is
"psis".
Threshold value for Pareto k values above which the moment matching algorithm is used. Default is 0.5.
Logical; Indicate whether or not draws should be resampled based on calculated importance weights.
Indicate a transformation of posterior draws to perform before sensitivity analysis. Either "scale" or "whiten".
Function taking the model fit and returning a draws_df of predictions to be appended to the posterior draws
logical scale quantity gradients by base posterior standard deviation.
Numeric vector specifying which priors to consider.
Numeric vector specifying which likelihoods to consider.
ex <- example_powerscale_model()
drw <- ex$draws
powerscale_gradients(drw)
Run the code above in your browser using DataLab