CausalMixGPD
  • Home
  • Roadmaps
    • Website roadmap
    • Package roadmap
  • Start
    • Start Hub
    • Roadmap
    • Usage Diagrams
    • Start Here
    • Basic Compile and Run
    • Backends and Workflow
    • Troubleshooting
  • Tracks
    • Quickstart
    • Modeling (1-arm)
    • Causal
    • Clustering
    • Kernels & tails
    • Customization
  • Examples
  • Kernels
  • Advanced
  • Developers
  • Reference
    • Reference hub
    • Function reference by job
  • News
  • Cite
  • Coverage
  • API Reference

Normal

Normal

Normal mixture kernel

A normal component is parameterized by () and (>0): [ f(y,)=!(-). ]

A finite normal mixture with (J) components has density [ f(y)=_{j=1}^J w_j,(y_j,j^2), {j=1}^J w_j=1. ]

Parameter mapping (math () code): (_j) mean[j], (_j) sd[j], (w_j) w[j].

Normal mixture with GPD tail

In the spliced version, the bulk distribution is the normal mixture below (u), and a GPD tail is attached above (u). The tail parameters are (>0) and (), applied to exceedances (x-u).

Tail mapping (math () code): (u) threshold, () tail_scale, () tail_shape.

Without GPD (mixture kernel)

Code
grid <- seq(-4, 5, length.out = 400)
normal_sets <- list(
  list(label = "Mix A", w = c(0.6, 0.3, 0.1), mean = c(-1, 0.5, 2), sd = c(2, 0.6, 1.1)),
  list(label = "Mix B", w = c(0.5, 0.3, 0.2), mean = c(-1.2, 0.3, 1.5), sd = c(0.9, 0.7, 1.0)),
  list(label = "Mix C", w = c(0.4, 0.35, 0.25), mean = c(-0.5, 2, 2.5), sd = c(0.7, 0.6, 1.2))
)

example <- normal_sets[[1]]
Code
dNormMix(0, w = example$w, mean = example$mean, sd = example$sd)
[1] 0.2535206
Code
dNormMix(0, w = example$w, mean = example$mean, sd = example$sd, log = TRUE)
[1] -1.37231
Code
pNormMix(0, w = example$w, mean = example$mean, sd = example$sd)
[1] 0.4790278
Code
pNormMix(0, w = example$w, mean = example$mean, sd = example$sd, lower.tail = FALSE)
[1] 0.5209722
Code
pNormMix(0, w = example$w, mean = example$mean, sd = example$sd, log.p = TRUE)
[1] -0.7359966
Code
q_vec(qNormMix, c(0.25, 0.5, 0.75), w = example$w, mean = example$mean,
      sd = example$sd)
[1] -1.42337727  0.08046623  0.94945934
Code
q_vec(qNormMix, c(0.25, 0.5, 0.75), w = example$w, mean = example$mean,
      sd = example$sd, lower.tail = FALSE)
[1]  0.94945934  0.08046623 -1.42337727
Code
q_vec(qNormMix, c(log(0.25), log(0.5), log(0.75)), w = example$w,
      mean = example$mean, sd = example$sd, log.p = TRUE)
[1] -1.42337727  0.08046623  0.94945934
Code
draw_many(rNormMix, list(w = example$w, mean = example$mean, sd = example$sd))
[1] -1.6524667  1.0808085  2.4561056 -2.6409368  0.3231677
Code
df_norm <- do.call(rbind, lapply(normal_sets, function(ps) {
  data.frame(x = grid, density = density_curve(grid, dNormMix, list(w = ps$w, mean = ps$mean, sd = ps$sd)), label = ps$label)
}))

ggplot(df_norm, aes(x = x, y = density, color = label)) +
  geom_line(linewidth = 1) +
  labs(title = "Normal mixtures (bulk)", x = "x", y = "density") +
  theme_minimal() + theme(legend.position = "top")

With GPD tail

Spliced density uses the same mixture for \(x<u\) and attaches \(f_{GPD}\) above \(u\) with continuity. CDF combines mixture CDF up to \(u\) and GPD exceedance beyond \(u\); quantiles invert this spliced CDF; RNG draws bulk vs tail by the CDF mass at \(u\).

Code
normal_gpd_sets <- list(
  list(label = "Mix A", w = c(0.6, 0.4), mean = c(-1, 2), sd = c(0.5, 0.8), threshold = 1.8, tail_scale = 0.4, tail_shape = 0.25),
  list(label = "Mix B", w = c(0.5, 0.5), mean = c(0, 1), sd = c(0.6, 0.6), threshold = 1.5, tail_scale = 0.3, tail_shape = 0.2),
  list(label = "Mix C", w = c(0.7, 0.3), mean = c(0.5, 2.5), sd = c(0.4, 1.0), threshold = 2.0, tail_scale = 0.5, tail_shape = 0.15)
)

example <- normal_gpd_sets[[1]]
Code
dNormMixGpd(2, w = example$w, mean = example$mean, sd = example$sd, threshold = example$threshold, tail_scale = example$tail_scale, tail_shape = example$tail_shape)
[1] 0.3322395
Code
pNormMixGpd(2, w = example$w, mean = example$mean, sd = example$sd, threshold = example$threshold, tail_scale = example$tail_scale, tail_shape = example$tail_shape)
[1] 0.8504922
Code
q_vec(qNormMixGpd, c(0.5, 0.9), w = example$w, mean = example$mean, sd = example$sd, threshold = example$threshold, tail_scale = example$tail_scale, tail_shape = example$tail_shape)
[1] -0.5173894  2.1903912
Code
draw_many(rNormMixGpd, example)
[1]  3.9237227  3.3651944  1.0818744 -1.1496076 -0.8738883
Code
df_norm_gpd <- do.call(rbind, lapply(normal_gpd_sets, function(ps) {
  data.frame(x = grid, density = density_curve(grid, dNormMixGpd, list(w = ps$w, mean = ps$mean, sd = ps$sd, threshold = ps$threshold, tail_scale = ps$tail_scale, tail_shape = ps$tail_shape)), label = ps$label)
}))

ggplot(df_norm_gpd, aes(x = x, y = density, color = label)) +
  geom_line(linewidth = 1) +
  labs(title = "Normal mixtures with GPD tail (different thresholds)", x = "x", y = "density") +
  theme_minimal() + theme(legend.position = "top")

Prereqs

  • Required packages and data for this page are listed in the setup chunks above.

Outputs

  • This page renders model fits, diagnostics, and summary artifacts generated by package APIs.

Interpretation

  • Canonical concept page: Introduction With Gpd Kernel
  • Treat this page as an application/example view and use the canonical page for core definitions.

Next

  • Continue to the linked canonical concept page, then return for implementation-specific details.
(c) CausalMixGPD - Bayesian semiparametric modeling for heavy-tailed data
- - Cite - API - GitHub