Skip to content

Commit

Permalink
docs for exogenous processes
Browse files Browse the repository at this point in the history
  • Loading branch information
gregor-schueler committed Feb 24, 2025
1 parent 8b51e84 commit 6a92cf2
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions docs/source/How-To/specify_exogenous_processes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Specifying Exogenous Processes in the DCEGM Module

## Overview

Exogenous processes in the DCEGM module define how state variables evolve over time based on transition probabilities. These transition probabilities must be properly specified to ensure consistency with the model structure. This document outlines how to define exogenous processes and specify them within the model's options.

## Defining an Exogenous Process Function

An exogenous process function takes relevant state variables and model parameters as inputs and returns an ordered list of transition probabilities for each possible next state. Each transition probability must meet the following requirements:

- It must be a float (dtype `float64`).
- It must be non-negative.
- It must sum to 1 across all possible next states.

### Example 1: Health Transition Process

```python
import jax.numpy as jnp

def prob_exog_health_mother(health_father, params):
prob_good_health = (health_father == 0) * 0.7 + (health_father == 1) * 0.3
prob_medium_health = (health_father == 0) * 0.2 + (health_father == 1) * 0.5
prob_bad_health = (health_father == 0) * 0.1 + (health_father == 1) * 0.2

return jnp.array([prob_good_health, prob_medium_health, prob_bad_health])
```

## Specifying Exogenous Processes in Model Options

Each exogenous process should be defined in the `state_space` section of the model options, mapping process names to transition functions and defining possible states.

### Example 2: Specifying Exogenous Processes in `options`

```python
options = {
"state_space": {
"exogenous_processes": {
"health_mother": {
"transition": prob_exog_health_mother,
"states": [0, 1, 2],
},
"job_offer": {
"transition": job_offer_process_transition,
"states": [0, 1],
},
},
},
}
```

## Validating Exogenous Processes

To ensure correctness, the validation function can be used as implemented in the DCEGM module:

```python
from dcegm.interface import validate_exogenous_processes

validate_exogenous_processes(model, params)
```

This function checks for compliance with probability constraints and verifies that transition matrices align with the model's state space. Possible errors and their respective messages include:

- **Non-float transition probabilities**: *"Exogenous process {exog_name} does not return float transition probabilities."*
- **Negative transition probabilities**: *"Exogenous process {exog_name} does not return non-negative transition probabilities."*
- **Probabilities greater than 1**: *"Exogenous process {exog_name} does not return transition probabilities less or equal to 1."*
- **Incorrect number of transitions**: *"Exogenous process {exog_name} does not return the correct number of transitions. Expected {expected}, got {actual}."*
- **Probabilities not summing to 1**: *"Exogenous process {exog_name} transition probabilities do not sum to 1."*

By following this specification, exogenous processes can be correctly integrated into the DCEGM framework, ensuring a consistent and reliable dynamic model setup.

0 comments on commit 6a92cf2

Please sign in to comment.