Model 1: Presence-Only Gaussian Niche
Source:vignettes/model_presence_only.Rmd
model_presence_only.Rmd1 Ecological Motivation
The fundamental ecological niche of a species (sensu Hutchinson 1957) is the set of environmental conditions under which the species can maintain a viable population. When the niche is modelled as a multivariate normal density in -dimensional environmental space, the problem reduces to estimating the centroid and the shape/orientation matrix from observed presence records.
The presence-only model is the simplest formulation: it treats the occurrence records as an i.i.d. sample from the normal density and estimates by maximum likelihood.
2 Mathematical Specification
2.1 Density
The multivariate normal density in dimensions is
This is Equation 2 of Jimenez et al. (2019), written for a single observation.
2.2 Log-Likelihood
Given presence records, the log-likelihood is
$$ \ell(\mu,\Sigma) = -\frac{n}{2}\log|\Sigma| -\frac{1}{2}\sum_{i=1}^{n} (\mathbf{x}_i-\mu)^\top\Sigma^{-1}(\mathbf{x}_i-\mu) + \text{const.} \tag{2} $$
The constant does not depend on and is dropped in the implementation because it does not affect the optimum.
3 Parameterisation
4 Implementation Call Chain
optimize_niche(likelihood = "presence_only")
└─ niche_obj.cpp::create_niche_obj_ptr()
└─ loglik_niche_math_presence_only_eigen() [C++, lines 65–95]
├─ build_L_cov() [theta → mu, sigma, L_cov]
├─ L_cov.triangularView.solve(diff) [Mahalanobis via forward solve]
└─ 0.5 * n * log_det + 0.5 * sum_q [Eq. 3]
4.1 Key Code (loglik_niche_math_cpp.cpp, lines 65–95)
The C++ kernel:
- Reconstructs
from
via
build_L_cov()(lines 40–59). - Computes by triangular forward solve (line 84).
- Sums squared column norms (line 85).
- Computes (lines 87–89).
- Returns
0.5 * n * log_det + 0.5 * sum_q(line 92), guarded byOPTIM_PENALTYfor NaN/Inf (line 93).
4.2 R Entry Point
loglik_niche_math_presence_only(theta, env_occ, eta = 1, neg = TRUE)This function reconstructs
via cvine_cholesky() in R, then calls
loglik_niche_presence_only_cpp() (the Rcpp-exported
wrapper).
5 Analytical Properties
| Property | Value |
|---|---|
| MLE for | Sample mean |
| MLE for | Sample covariance |
| Likelihood shape | Unimodal (convex negative log-likelihood) |
| Identifiability | Full: and are both identifiable |
| Background data | Not used |
| Dropped constants | — does not affect |
6 When To Use
- Sanity check: The MLE has a closed form, so numerical results should match the sample mean and covariance exactly (up to optimiser tolerance).
-
Warm start:
optimize_niche(warm_start = TRUE)uses the presence-only MLE as the initial point for the more complex weighted models. - No background available: When the accessible area is unknown or the background sample is unreliable.
7 Limitations
Ignores environmental availability. The estimate reflects the observed distribution of presences, which is confounded by the distribution of environments in . If over-represents certain environments, will be biased toward those environments.
No background correction. Unlike the
"weighted"and"ip_weighted"models, no KDE of is used. The resulting niche estimate is the realised niche (or a biased estimate of it), not the fundamental niche.Normality assumption. The niche is assumed to be ellipsoidal. For species with multi-modal or strongly skewed niches, consider
"skew_normal"or"skew_t".