check_and_prepare_data_for_fit()
| check_and_prepare_data_for_fit | R Documentation |
Check and Prepare Data for Model Fitting
Description
Cleans and prepares community, abiotic, and coordinate data for HMSC model fitting, with optional age subsetting.
Usage
check_and_prepare_data_for_fit(
data_community = NULL,
data_abiotic = NULL,
data_coords = NULL,
subset_age = NULL
)
Arguments
data_community
|
A data frame of community data in wide format, with sample names as row names in the format "dataset_name__age". |
data_abiotic
|
A data frame of abiotic data with sample names as row names in the format "dataset_name__age", and abiotic variables as columns. |
data_coords
|
A data frame of spatial coordinates with dataset names as row names and columns for longitude and latitude. |
subset_age
|
Optional numeric value specifying a single age to subset the data. If NULL (default), all ages are included. |
Details
Drops NA values, optionally subsets by age, and finds the intersection of samples across community, abiotic, and coordinate data to ensure all inputs are aligned before model fitting.
Value
A list with four elements: ‘data_community_to_fit’, ‘data_abiotic_to_fit’, ‘data_coords_to_fit’, and ‘scale_attributes’. All data frames are aligned to the intersecting set of datasets and ages. ‘scale_attributes’ is a named list of centering and scaling attributes for each abiotic variable.
See Also
[make_hmsc_model()]