Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog_entry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- bump: minor
changes:
changed:
- Long-term OBR economic growfactors for 2030-10 and onwards.
2 changes: 1 addition & 1 deletion docs/book/assumptions/growthfactors.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Economic assumptions

```{note}
We project economic variables using year-over-year growth rates stored in `parameters/gov/economic_assumptions/yoy_growth.yaml`. We generate index values from these rates to update household variables. We source all values from the OBR's Economic and Fiscal Outlook ([March 2025](https://obr.uk/efo/economic-and-fiscal-outlook-march-2025/)) unless we specify otherwise.
We project economic variables using year-over-year growth rates stored in `parameters/gov/economic_assumptions/yoy_growth.yaml`. We generate index values from these rates to update household variables. We source all values from the OBR's long-term economic determinants and Economic and Fiscal Outlook ([March 2025](https://obr.uk/efo/economic-and-fiscal-outlook-march-2025/)) unless we specify otherwise. The long-term determinants provide extended forecasts beyond the standard forecast horizon.
```

## Consumer price index
Expand Down
47 changes: 47 additions & 0 deletions docs/book/usage/simulations.md
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,53 @@ print(f"Average age: {avg_age:.1f} years")
print(f"Average children per household: {children_per_household:.1f}")
```

## Comparing simulations and analysing dependencies

PolicyEngine UK provides utilities for comparing simulations and understanding variable relationships:

### Fetching variable dependencies

The `get_variable_dependencies` method helps you understand what variables feed into a calculation:

```python
from policyengine_uk import Microsimulation

sim = Microsimulation()

# Get direct dependencies of income tax
deps = sim.get_variable_dependencies("income_tax")
# Returns: ['earned_income_tax', 'savings_income_tax', 'dividend_income_tax', 'CB_HITC', ...]

# Get dependencies up to 3 levels deep to see the full calculation tree
deep_deps = sim.get_variable_dependencies("income_tax", depth=3)
# Returns expanded list including dependencies of dependencies
```

This is particularly useful for debugging unexpected results or understanding the full impact of policy changes.

### Comparing baseline and reformed simulations

The `compare` method creates a DataFrame showing differences between simulations:

```python
baseline = Microsimulation()
reformed = Microsimulation() # Apply your reforms here

# Compare specific variables between simulations
comparison_df = baseline.compare(
reformed,
baseline.get_variable_dependencies("income_tax", depth=1),
2029
)

# The DataFrame has columns for each variable:
# - variable_self: baseline value
# - variable_other: reformed value
# - variable_change: difference between reformed and baseline
```

This makes it easy to trace through exactly how a reform affects different components of the tax and benefit system.

## Performance tips

```{tip}
Expand Down
9 changes: 6 additions & 3 deletions policyengine_uk/data/dataset_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,12 @@ def from_simulation(
if simulation.tax_benefit_system.variables[variable].entity.key
== entity
]
entity_dfs[entity] = simulation.calculate_dataframe(
input_variables, period=fiscal_year
)
if len(input_variables) == 0:
entity_dfs[entity] = pd.DataFrame()
else:
entity_dfs[entity] = simulation.calculate_dataframe(
input_variables, period=fiscal_year
)

return UKSingleYearDataset(
person=entity_dfs["person"],
Expand Down
Loading
Loading