Skip to contents

Converts occurrence environmental data into the list format required by the Stan presence-only model. The function validates inputs and builds a data-adaptive prior on the niche centroid.

Usage

prepare_niche_data(env_occ, eta = 1, sigma_rate = 0.1)

Arguments

env_occ

Data frame or matrix of environmental values at presence points (rows = points, columns = environmental variables).

eta

LKJ shape parameter for correlation matrix prior (default 1, uniform over correlation matrices).

sigma_rate

Rate parameter for exponential prior on standard deviations (default 0.1).

Value

A named list suitable for passing to fit_niche or directly to CmdStan. Contains:

N_occ

Number of occurrence points

P

Number of environmental dimensions

occ

Occurrence data matrix

mu_prior

Prior mean for centroid (data-adaptive, equal to column means of env_occ)

sigma_prior

Prior SD for centroid (data-adaptive, equal to 10 times column SDs of env_occ)

sigma_rate

Rate for exponential prior on sigma (default 0.1)

eta

LKJ shape parameter (default 1, uniform over correlation matrices)

Examples

if (FALSE) { # \dontrun{
# Simulate some 2D environmental data
set.seed(42)
occ <- data.frame(
  bio01 = rnorm(50, 20, 3),   # annual mean temperature
  bio12 = rnorm(50, 800, 100) # annual precipitation
)

# Prepare for Stan
stan_data <- prepare_niche_data(occ)
str(stan_data)
} # }