Code
grid <- seq(0.1, 6, length.out = 400)
ig_base_sets <- list(
list(label = "Base A", mean = 1.2, shape = 3.0),
list(label = "Base B", mean = 1.5, shape = 4.0),
list(label = "Base C", mean = 1.0, shape = 2.5)
)
example <- ig_base_sets[[1]]This section documents the same inverse Gaussian density as above, but for a single component rather than a mixture: [ f(y,) = ()^{1/2} !(-), y>0. ]
Parameter mapping (math () code): () mean, () shape.
The dInvGaussGpd, pInvGaussGpd, qInvGaussGpd, and rInvGaussGpd functions splice the base inverse Gaussian below (u) with a GPD tail above (u).
Tail mapping (math () code): (u) threshold, () tail_scale, () tail_shape.
[1] 0.6627887
[1] -0.4112991
[1] 0.4974402
[1] 0.5025598
[1] -0.6982799
[1] 0.6732028 1.0038699 1.5093817
[1] 1.5093817 1.0038699 0.6732028
[1] 0.6732028 1.0038699 1.5093817
[1] 0.8095021 2.7192599 0.4547103 0.4691927 1.6313223
df_ig_base <- do.call(rbind, lapply(ig_base_sets, function(ps) {
data.frame(x = grid, density = density_curve(grid, dInvGauss, list(mean = ps$mean, shape = ps$shape)), label = ps$label)
}))
ggplot(df_ig_base, aes(x = x, y = density, color = label)) +
geom_line(linewidth = 1) +
labs(title = "Inverse Gaussian base kernels", x = "x", y = "density") +
theme_minimal() + theme(legend.position = "top")
ig_base_gpd_sets <- list(
list(label = "Base A", mean = 1.5, shape = 2, threshold = 2.0, tail_scale = 0.4, tail_shape = 0.2),
list(label = "Base B", mean = 1.2, shape = 2.5, threshold = 1.8, tail_scale = 0.35, tail_shape = 0.18),
list(label = "Base C", mean = 1.8, shape = 3, threshold = 2.5, tail_scale = 0.5, tail_shape = 0.22)
)
example <- ig_base_gpd_sets[[1]][1] 0.5704499
[1] -0.56133
[1] 0.77182
[1] 0.22818
[1] -0.2590039
[1] 0.6561675 1.1013488 1.8902777
[1] 1.8902777 1.1013488 0.6561675
[1] 0.6561675 1.1013488 1.8902777
df_ig_base_gpd <- do.call(rbind, lapply(ig_base_gpd_sets, function(ps) {
data.frame(x = grid, density = density_curve(grid, dInvGaussGpd, list(mean = ps$mean, shape = ps$shape, threshold = ps$threshold, tail_scale = ps$tail_scale, tail_shape = ps$tail_shape)), label = ps$label)
}))
ggplot(df_ig_base_gpd, aes(x = x, y = density, color = label)) +
geom_line(linewidth = 1) +
labs(title = "Inverse Gaussian base with GPD tail", x = "x", y = "density") +
theme_minimal() + theme(legend.position = "top")