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

Laplace

Laplace

Laplace mixture kernel

A Laplace (double-exponential) component with location () and scale (b>0) has density [ f(y,b)=!(-),y. ]

A finite Laplace mixture is [ f(y)=_{j=1}^J w_j,(y_j,b_j). ]

Parameter mapping (math () code): (_j) location[j], (b_j) scale[j], (w_j) w[j].

Laplace mixture with GPD tail

The spliced kernel uses the Laplace mixture below (u) and a GPD tail above (u).

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

Without GPD (mixture kernel)

Laplace mixture density \(f(x)=\sum_j w_j\,\text{Laplace}(x\mid \ell_j, b_j)\).

Code
grid <- seq(-4, 4, length.out = 400)
lap_sets <- list(
  list(label = "Mix A", w = c(0.6, 0.3, 0.1), location = c(0.0, 1.0, -2), scale = c(1.0, 0.9, 1.1)),
  list(label = "Mix B", w = c(0.5, 0.3, 0.2), location = c(0.2, 1.2, -0.5), scale = c(0.9, 2, 1.0)),
  list(label = "Mix C", w = c(0.4, 0.35, 0.25), location = c(-0.2, 2, -1.0), scale = c(1.1, 0.95, 1.05))
)

example <- lap_sets[[1]]
Code
dLaplaceMix(0, w = example$w, location = example$location, scale = example$scale)
[1] 0.3622437
Code
dLaplaceMix(0, w = example$w, location = example$location, scale = example$scale, log = TRUE)
[1] -1.015438
Code
pLaplaceMix(0, w = example$w, location = example$location, scale = example$scale)
[1] 0.4412629
Code
pLaplaceMix(0, w = example$w, location = example$location, scale = example$scale, lower.tail = FALSE)
[1] 0.5587371
Code
pLaplaceMix(0, w = example$w, location = example$location, scale = example$scale, log.p = TRUE)
[1] -0.8181144
Code
q_vec(qLaplaceMix, c(0.25, 0.5, 0.75), w = example$w,
      location = example$location, scale = example$scale)
[1] -0.7341261  0.1712536  1.0499993
Code
q_vec(qLaplaceMix, c(0.25, 0.5, 0.75), w = example$w,
      location = example$location, scale = example$scale, lower.tail = FALSE)
[1]  1.0499993  0.1712536 -0.7341261
Code
q_vec(qLaplaceMix, c(log(0.25), log(0.5), log(0.75)), w = example$w,
      location = example$location, scale = example$scale, log.p = TRUE)
[1] -0.7341261  0.1712536  1.0499993
Code
draw_many(rLaplaceMix, list(w = example$w, location = example$location, scale = example$scale))
[1] -0.1457067 -2.5038331 -0.8306819  1.2295621  0.6082867
Code
df_lap <- do.call(rbind, lapply(lap_sets, function(ps) {
  data.frame(x = grid, density = density_curve(grid, dLaplaceMix, list(w = ps$w, location = ps$location, scale = ps$scale)), label = ps$label)
}))

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

With GPD tail

Code
lap_gpd_sets <- list(
  list(label = "Mix A", w = c(0.6, 0.4), location = c(-0.5, 1), scale = c(0.4, 0.6), threshold = 1.5, tail_scale = 0.35, tail_shape = 0.3),
  list(label = "Mix B", w = c(0.5, 0.5), location = c(0, 0.8), scale = c(0.5, 0.5), threshold = 1.2, tail_scale = 0.3, tail_shape = 0.25),
  list(label = "Mix C", w = c(0.7, 0.3), location = c(0.2, 1.5), scale = c(0.35, 0.7), threshold = 1.8, tail_scale = 0.4, tail_shape = 0.22)
)

example <- lap_gpd_sets[[1]]
Code
dLaplaceMixGpd(1, w = example$w, location = example$location, scale = example$scale, threshold = example$threshold, tail_scale = example$tail_scale, tail_shape = example$tail_shape)
[1] 0.3509716
Code
pLaplaceMixGpd(1, w = example$w, location = example$location, scale = example$scale, threshold = example$threshold, tail_scale = example$tail_scale, tail_shape = example$tail_shape)
[1] 0.7929447
Code
q_vec(qLaplaceMixGpd, c(0.5, 0.9), w = example$w, location = example$location, scale = example$scale, threshold = example$threshold, tail_scale = example$tail_scale, tail_shape = example$tail_shape)
[1] -0.1619177  1.4304946
Code
draw_many(rLaplaceMixGpd, example)
[1]  1.67992734  0.81799148 -2.26957369 -0.17111065  0.03529796
Code
df_lap_gpd <- do.call(rbind, lapply(lap_gpd_sets, function(ps) {
  data.frame(x = grid, density = density_curve(grid, dLaplaceMixGpd, list(w = ps$w, location = ps$location, scale = ps$scale, threshold = ps$threshold, tail_scale = ps$tail_scale, tail_shape = ps$tail_shape)), label = ps$label)
}))

ggplot(df_lap_gpd, aes(x = x, y = density, color = label)) +
  geom_line(linewidth = 1) +
  labs(title = "Laplace 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