Learn R Programming

stCEG (version 0.1.0)

calculate_area_probabilities: Calculate Area Probabilities in a Chain Event Graph (CEG)

Description

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.

Usage

calculate_area_probabilities(
  path_df,
  unique_values,
  selected_indices,
  last_group,
  shapefile_vals
)

Value

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.

Arguments

path_df

A data frame containing paths and their corresponding products, as returned by the calculate_path_products function.

unique_values

A character vector containing the unique values (e.g., labels or categories) to condition on.

selected_indices

A numeric vector of indices corresponding to the groupings of the unique values.

last_group

A string representing the last group for which the conditional probability is to be calculated.

shapefile_vals

A vector of area names (or other geographical identifiers) from the shapefile data.