Model 7: Skew-t Weighted Niche
Source:vignettes/model_skew_t_weighted.Rmd
model_skew_t_weighted.Rmd1 Ecological Motivation
This is the most general model in the xnicher hierarchy.
It combines all three extensions:
- Background weighting (from Models 2/5): corrects for non-uniform environmental availability in via a KDE .
- Skewness (from Models 4/5): allows asymmetric environmental tolerances via the skewness vector .
- Heavy tails (from Model 6): allows persistence at extreme environmental values via the degrees-of-freedom parameter .
Use this model when both asymmetric tolerances and heavy tails are ecologically plausible, and the observation process is confounded by environmental availability.
2 Data-Generating Process
The DGP is the use-availability model with a skew-t niche kernel:
where is the skew-t density (Model 6, Eq. 2).
3 Mathematical Specification
3.1 Negative Log-Likelihood
where:
- with (occurrence Mahalanobis distance),
- and are the same at background point ,
- and are the GaussβLaguerre quadrature integrals (Model 6, Eq. 6),
- is the precomputed KDE of the background.
3.2 Structure of the Denominator
The denominator integrand for background point is:
This is proportional to evaluated in log space β the discrete approximation to the denominator integral in Eq. (1).
4 Implementation Call Chain
optimize_niche(likelihood = "skew_t_weighted")
ββ niche_obj.cpp::create_niche_obj_ptr()
ββ loglik_niche_math_skew_t_weighted_eigen() [C++, lines 829β910]
ββ build_L_cov() [theta β mu, sigma, L_cov]
ββ alpha = Map(theta + 2*p + n_v, p) [line 854]
ββ log_r = theta[3*p + n_v]; r = exp() [lines 855β856]
β
β // Occurrence side
ββ Mahalanobis q_occ, z_occ [lines 864β868]
ββ For each i:
β A_i = 1 + q_occ(i)/r [line 873]
β sum_log_A_occ += log(A_i) [line 874]
β sum_log_I_occ += log_skew_t_integral [line 875]
β
β // Denominator side
ββ Mahalanobis q_den, z_den [lines 880β884]
ββ log_w_den = clamp(w_den).log() [line 885]
ββ For each j:
β A_j = 1 + q_den(j)/r [line 889]
β log_I_j = log_skew_t_integral() [line 890]
β log_terms(j) = log_w_den - half_kpr*log(A_j) + log_I_j [line 891]
ββ logsumexp(log_terms) [lines 893β895]
β
ββ log_w_occ = clamp(w_occ).log() [line 897]
ββ prior_penalty_value(has_alpha=true) [lines 899β900]
ββ neg_log = half_kpr*sum_log_A_occ
- sum_log_I_occ
- log_w_occ.sum()
+ n*lse + penalty [lines 902β906]
4.1 Key Code (loglik_niche_math_cpp.cpp, lines 829β910)
The C++ kernel:
- Reconstructs , maps and (lines 850β857).
-
Occurrence side (lines 863β876): computes
Mahalanobis distances, skew scores, and accumulates
and
via
log_skew_t_integral(). - Denominator side (lines 878β895): for each background point, computes , , and the full integrand . Applies logsumexp across all background points.
- Combines all terms (lines 902β906) and returns the guarded negative log-likelihood.
4.2 Computational Cost
Each evaluation requires
calls to log_skew_t_integral() per data point (once for
occurrence, once for background). For
presence points and
background points, this is
evaluations per log-likelihood call.
4.3 R Entry Point
optimize_niche(env_occ, env_m, likelihood = "skew_t_weighted",
prior_log_sigma_lambda = 1.0,
prior_alpha_lambda = 1.0)5 When To Use
- When the full model is warranted: species with asymmetric, heavy-tailed tolerances in a region with heterogeneous environmental availability.
- As the most complex candidate in an AIC/BIC model-selection exercise. If the data do not justify the extra parameters (, ), simpler models will be preferred.
- When robustness to outliers is desired: the heavy tails of the skew-t down-weight extreme presence records that would strongly influence a Gaussian or skew-normal fit.
6 Limitations
Highest parameter count. parameters. For , this is 26 parameters.
Slowest model. The double loop over occurrence + background with quadrature nodes makes this the most computationally expensive model. Consider using
num_starts = 1for initial exploration and increasing for the final fit.Patil & Ord drift (shared with Models 2/5). The ridge prior on is essential.
Quadrature accuracy. Same caveat as Model 6: is validated for .
Not all extensions are independent. Skewness and heavy tails can interact in unexpected ways. Always compare with simpler nested models.