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: patch
changes:
fixed:
- Zero out fuel spending for households without fuel consumption
2 changes: 2 additions & 0 deletions docs/imputations.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ LCFS 2-week diaries undercount fuel purchasers (58%) compared to actual vehicle

4. **At FRS imputation time**: Compute `has_fuel_consumption` directly from `num_vehicles` (already calibrated to NTS targets)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good addition - the documentation clearly explains what happens and why.

5. **Zero non-fuel households**: After imputation, set `petrol_spending` and `diesel_spending` to zero for households where `has_fuel_consumption = 0`

This ensures fuel duty incidence aligns with actual vehicle ownership (~70% of households = 78% vehicles × 90% ICE) rather than LCFS diary randomness.

---
Expand Down
6 changes: 6 additions & 0 deletions policyengine_uk_data/datasets/imputations/consumption.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,12 @@ def impute_consumption(dataset: UKSingleYearDataset) -> UKSingleYearDataset:
for column in output_df.columns:
dataset.household[column] = output_df[column].values

# Zero out fuel spending for households without fuel consumption
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick verification: has_fuel_consumption is computed earlier in this function (around line 336-340) and is a numpy array that persists in scope. The == 0 comparison is correct for boolean-like integers. This looks good.

# This ensures only ICE vehicle owners contribute to fuel duty
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This direct assignment to a subset of dataset.household[...] works because the household dict stores numpy arrays. The boolean mask indexing correctly updates only the non-fuel households in place.

no_fuel = has_fuel_consumption == 0
dataset.household["petrol_spending"][no_fuel] = 0
dataset.household["diesel_spending"][no_fuel] = 0

dataset.validate()

return dataset