Derives stand metrics by site/patch/species/year from tree measurements, filters sites, harmonizes years, optionally aggregates by site.
Usage
makeObsData(
tree_dt,
plotsize,
aggregate_by_site = T,
minNyears = 2,
fix_period_length = NULL,
dbh_growth_thresh = c(-10, 50),
Npatches = NULL,
Nspecies = NULL,
NspeciesQuantile = NULL
)Arguments
- tree_dt
data.table of tree records with siteName, patchName, year, treeName, species_name, dbh,
status(one of "alive", "new", "dead") andliving. Mortality is derived fromstatus; amortcolumn, if present, is ignored.- plotsize
numeric plot area used to scale recruitment.
- aggregate_by_site
logical. Aggregate patches to site level. Default TRUE.
- minNyears
integer or NULL. Keep sites with at least this many years and equal counts across patches. Default 2.
- fix_period_length
integer or NULL. If set, drop sites whose inventory interval differs. Default NULL.
- dbh_growth_thresh
length-2 numeric or NULL. Drop sites where any tree
dbhchange falls outside this range. Defaultc(-10, 50).- Npatches
integer or NULL. If set, keep only sites with exactly this many patches.
- Nspecies
integer or NULL. Cap species to the top N (others merged to "other").
- NspeciesQuantile
numeric in (0,1] or NULL. Choose the smallest N covering this fraction of individuals; overrides
Nspeciesif supplied.
Value
A list with:
obs_dt: observations at site or patch level.growthis the mean relative diameter increment (dbh/dbh_before - 1), andgrowth_nis how many trees that mean rests on. Both matter: means are aggregated across patches TREE-WEIGHTED (bygrowth_n), because that is the quantity the model predicts - it simulatessum(g*trees)/sum(trees)over the whole site, so an unweighted mean of patch means would be a different number.growth_nalso travels with the response sofitcan weight the likelihood by it: 34% of patch-level growth observations rest on a single tree while others average 30+, and the variance of a mean is \(\sigma^2/n\). Mortality comes back as a closed-cohort pair of counts,n_at_risk(trees alive at the start of the interval) andn_died(how many of them were dead at the end), plus the derived ratemort = n_died / n_at_risk(NAwhere no cohort was at risk). The counts are the binomial response; pass them tofitwithmortality = "binomial".tree_dt: input trees with added growth fields and species recode.