dist_shash
- dist_conditioned
Usage
dist_shash(mu, sigma, eps = 0, delta = 1)
dist_conditioned(marginal, m, s)Reference models return predictive distributions as
distributional
vectors, so cdf(), quantile(), density(), generate(), mean(),
variance(), hilo(), tibble columns, and ggdist layers all work.
Gaussian fits use distributional::dist_normal(); SHASH fits use
dist_shash(); uncertainty = "total" predictions from location-scale
and SHASH fits are equal-weight mixtures over coefficient draws (an
internal dist_shash_draws class, one SHASH parameter set per draw and
observation); history-conditioned forecasts are dist_conditioned(); a
spec with a response transform returns the push-forward of the fitted
distribution onto the response scale (an internal dist_warped class).
Arguments
Section titled “Arguments”| Argument | Description |
|---|---|
mu, sigma, eps, delta |
Location, scale (> 0), skewness, and tail weight (> 0), recycled to a common length. |
marginal |
A distribution vector of marginal predictivedistributions. |
m, s |
Conditional mean and standard deviation (> 0) of the latent normal score, recycled to length(marginal). |
Details
Section titled “Details”dist_shash() follows the mgcv::shash() parameterisation. With
$z = (y-\mu)/(\sigma\delta)$,
$F(y) = \Phi(\sinh(\delta,\mathrm{asinh}(z)-\epsilon))$; eps = 0,
delta = 1 is the Gaussian $N(\mu, \sigma^2)$.
dist_conditioned() maps a marginal predictive distribution through a
conditional normal score: $F_*(y) = \Phi((z(y)-m)/s)$ with
$z(y) = \Phi^{-1}(F(y))$, so m = 0, s = 1 recovers the marginal.
Tail probabilities of every class are evaluated in log space, so scores
for observations 40 standard deviations out remain finite and distinct
(see as_scores()).
A distributional
distribution vector.
Examples
Section titled “Examples”d <- dist_shash(mu = 0.2, sigma = 1.1, eps = 0.3, delta = 0.9)d<distribution[1]>[1] SHASH(0.2, 1.1, 0.3, 0.9)cdf(d, 1.5)[1] 0.7675768quantile(d, c(0.05, 0.5, 0.95))[[1]][1] -1.0904537 0.5361452 2.9544300mean(d)[1] 0.6872512as_scores(d, c(-2, 0, 2))# A tibble: 3 × 8 observed median centile z tail_prob tail_surprisal residual log_density <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>1 -2 0.536 0.00462 -2.60 0.00923 4.69 -2.54 -4.272 0 0.536 0.309 -0.499 0.618 0.482 -0.536 -1.053 2 0.536 0.855 1.06 0.289 1.24 1.46 -1.93dist_conditioned(d, m = 0.4, s = 0.7)<distribution[1]>[1] SHASH(0.2, 1.1, 0.3, 0.9) | N(0.4, 0.7)