ecometric_model_qual {commecometrics} | R Documentation |
Run an ecometric model for qualitative environmental variables
Description
Builds an ecometric trait space for qualitative environmental variables, estimating the most probable category and the probability of each category at each trait bin combination. Also calculates prediction accuracy and anomalies for each point.
Usage
ecometric_model_qual(
points_df,
category_col,
grid_bins_1 = NULL,
grid_bins_2 = NULL,
min_species = 3
)
Arguments
points_df |
Output first element of the list from |
category_col |
Name of the column containing the categorical trait. |
grid_bins_1 |
Number of bins for the first trait axis. If |
grid_bins_2 |
Number of bins for the second trait axis. If |
min_species |
Minimum number of species with trait data per point (default = 3). |
Value
A list containing:
points_df |
Filtered input data frame with the following added columns:
|
eco_space |
Raster-format data frame representing trait space bins with estimated environmental categories. |
diagnostics |
Summary stats about bin usage and data coverage. |
settings |
Metadata including the modeled trait. |
prediction_accuracy |
Overall percentage of correct predictions. |
Examples
# Load internal data
data("geoPoints", package = "commecometrics")
data("traits", package = "commecometrics")
data("spRanges", package = "commecometrics")
# Step 1: Summarize trait values at sampling points
traitsByPoint <- summarize_traits_by_point(
points_df = geoPoints,
trait_df = traits,
species_polygons = spRanges,
trait_column = "RBL",
species_name_col = "sci_name",
continent = FALSE,
parallel = FALSE
)
# Step 2: Run ecometric model using land cover class as qualitative variable
modelResult <- ecometric_model_qual(
points_df = traitsByPoint$points,
category_col = "vegetation",
min_species = 3
)
# View the percentage of correctly predicted categories
print(modelResult$prediction_accuracy)