Skip to contents

Fits a logistic regression to predict whether a donor will fund a recipient in year t+1 based on features prepared by prepare_opportunity_dataset().

Usage

analysis_fit_opportunity_model(
  features,
  min_year = NULL,
  donor_name = NULL,
  recipient_name = NULL
)

Arguments

features

Dataframe produced by analysis_prepare_opportunity_dataset().

min_year

Minimum year to use for training (filters older data).

donor_name

Optional donor name to highlight in the plot.

recipient_name

Optional recipient name to highlight in the plot.

Value

A glm object (binomial) and the training frame (list with components model, data, plot).

Details

Label construction: response = 1 if total_amount > 0 in year t+1 for same donor-recipient.

Examples

features <- analysis_prepare_opportunity_dataset(flows)$data
model_results <- analysis_fit_opportunity_model(features, min_year = NULL, donor_name = "Germany")
print(model_results$plot)