This function calculates the conditional probability of a given last group for each area, based on the
path products and area-specific paths. It leverages the calculate_conditional_prob
function for each area.
calculate_area_probabilities(
path_df,
unique_values,
selected_indices,
last_group,
shapefile_vals
)
A list with area names as keys and their respective conditional probabilities as values.
If no paths are found for a specific area, the probability is returned as NA
.
A data frame containing paths and their corresponding products,
as returned by the calculate_path_products
function.
A character vector containing the unique values (e.g., labels or categories) to condition on.
A numeric vector of indices corresponding to the groupings of the unique values.
A string representing the last group for which the conditional probability is to be calculated.
A vector of area names (or other geographical identifiers) from the shapefile data.