Skip to content

Phase 2 Scenario runs - #30

Open
eglucas wants to merge 34 commits into
devfrom
scenarios_phase_2
Open

Phase 2 Scenario runs#30
eglucas wants to merge 34 commits into
devfrom
scenarios_phase_2

Conversation

@eglucas

@eglucas eglucas commented Feb 18, 2025

Copy link
Copy Markdown
Contributor

Description

The new file analysis/phase_2_scenarios.py models levy reform approaches and writes results to Excel for the following scenarios:

  • Status quo with current support
  • Rebalancing RO + FiT to gas with current support
  • Rebalancing with triple WHD revenue, support via flat rebate or unit discount
  • Rebalancing with triple WHD revenue then scaled to WFP eligibility group size, support via flat rebate or unit discount
  • Rebalancing with triple WHD revenue then scaled to UC eligibility group size, support via flat rebate or unit discount
  • Rebalancing with triple WHD revenue then scaled to CB eligibility group size, support via flat rebate or unit discount
  • Rebalancing with triple WHD revenue then scaled to WFP+CB eligibility group size, support via flat rebate or unit discount

In the same order as I've listed above, the code takes each scenario and does the following:

  1. Create a new LevyCollection with the updated WHD revenue
  2. Create new Tariffs with the updated LevyCollection
  3. Create a scenario base ConsumerCollection with the updated Tariffs
  4. Creates a new ConsumerCollection with flat rebate for eligible households by applying social support adjustment to the base ConsumerCollection
  5. Create a new ConsumerCollection with unit discount for eligible households by applying social support adjustment to the base ConsumerCollection

There are two Excel files that are generated and saved in outputs/data:

  • {datetime}_phase_2_scenarios.xlsx contains raw results data in tidy format for all levies, tariffs, cost ratios, consumers and support mechanisms (i.e. new WHD revenues, core spends, support base, unit discount values) across all scenarios.
  • {datetime}_phase_2_scenarios_flourish.xlsx contains pivoted consumer results in a format compatible with making Flourish charts.

Instructions for Reviewer

For this PR, please could you review the new code in general and check that the results saved in both Excel files are what you would expect.

Please pay special attention to how WHD revenue, core spend and unit discounts are calculated in each scenario. These are calculated using the eligible group sizes given in the CSE archetypes model, so I'd like to check whether you also think it's reasonable to be using the eligible group sizes in each archetype in this way.

Once you're happy with it, I don't think there is an immediate need to merge as I anticipate we will need to run more scenarios for phase 2.

Checklist:

  • I have refactored my code out from notebooks/
  • I have checked the code runs
  • I have tested the code
  • I have run pre-commit and addressed any issues not automatically fixed
  • I have merged any new changes from dev
  • I have documented the code
    • Major functions have docstrings
    • Appropriate information has been added to READMEs
  • I have explained this PR above
  • I have requested a code review

@eglucas
eglucas requested a review from danlewis85 February 18, 2025 17:33
@eglucas eglucas self-assigned this Feb 18, 2025

@danlewis85 danlewis85 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I've reviewed and run your code and it produced the anticiapted outputs.

As discussed, I've implemented the following changes:

  1. Added a scenario for cold weather payments.
  2. Changed the WHD revenue calculations so that the revenue is always: 3x core spending on whd scaled to the eligible group + the ring-fenced non-core spending.

Please check the diff and ensure you're happy with the changes.

@eglucas

eglucas commented Feb 20, 2025

Copy link
Copy Markdown
Contributor Author

I've reviewed the changes and am happy with all of them.

For ease of further processing of results, I've updated the scenario descriptions and added new code that pickles the summary dataframes.

@eglucas eglucas changed the title Phase 2 Set 1 Scenario runs Phase 2 Scenario runs Feb 26, 2025
@eglucas

eglucas commented Feb 26, 2025

Copy link
Copy Markdown
Contributor Author

@danlewis85 Please have a look at the new code added in this commit.

The main changes are:

  • Renamed the file for the first set of scenarios from phase_2_scenarios.py to phase_2_scenarios_set_1.py.
  • Amended the master_archetypes_data.pkl to add columns for 95th percentile electricity and gas consumption values for each archetype.
  • Added two new files phase_2_scenarios_set_2_mean.py and phase_2_scenarios_set_2_95pct.py for running set 2 scenarios at mean consumption and 95th percentile consumption values. Each saves results to Excel with respective file names for mean and 95th percentile.
  • Added a new file phase_2_scenarios_set_2_histograms.py that ingests outputs from the scenario run files and generates two Excel files with a table for each scenario, shaped for making a histogram in Flourish.

Please check that all the scenarios have been set up correctly, and that the outputs are as you expect.

Once we've merged the new EII levy and price cap update changes to dev, I'll get those changes and run everything to get our final set of results.

@danlewis85

Copy link
Copy Markdown
Contributor

@danlewis85 Please have a look at the new code added in this commit.

The main changes are:

  • Renamed the file for the first set of scenarios from phase_2_scenarios.py to phase_2_scenarios_set_1.py.
  • Amended the master_archetypes_data.pkl to add columns for 95th percentile electricity and gas consumption values for each archetype.
  • Added two new files phase_2_scenarios_set_2_mean.py and phase_2_scenarios_set_2_95pct.py for running set 2 scenarios at mean consumption and 95th percentile consumption values. Each saves results to Excel with respective file names for mean and 95th percentile.
  • Added a new file phase_2_scenarios_set_2_histograms.py that ingests outputs from the scenario run files and generates two Excel files with a table for each scenario, shaped for making a histogram in Flourish.

Please check that all the scenarios have been set up correctly, and that the outputs are as you expect.

Once we've merged the new EII levy and price cap update changes to dev, I'll get those changes and run everything to get our final set of results.

I've checked the setup for the scenarios for mean and 95%ile have been setup correctly and confirm that the outputs align with my expectations.

I'm happy for you to run a final set of results.

@eglucas

eglucas commented Mar 3, 2025

Copy link
Copy Markdown
Contributor Author

@danlewis85 Please have a look at the code for scenarios set 3. There are three new files:

  1. phase_2_scenarios_set_3.py for model runs with mean consumption
  2. phase_2_scenarios_set_3_95pctl.py for model runs with 95th percentile consumption
  3. phase_2_scenarios_set_3_histograms.py

In the code for model runs, please pay special attention to:

  • the separation of ECO4 and GBIS in policy costs
  • definition and application of rebalancing weights for rebalancing WHD to variable charge, and removing GBIS/ECO to general taxation

The histograms code is mainly the same as set 2 but I've altered the max and min net bill change intervals to capture the range of the new results.

If you'd like to check the general pattern across scenarios, preliminary visualisation is here.

…el into scenarios_phase_2

Merging new set 3 scenarios
@eglucas

eglucas commented Mar 3, 2025

Copy link
Copy Markdown
Contributor Author

@danlewis85 You may have already caught this but would also appreciate your opinion on the new way I've calculated whd_core_target_recipients:

whd_core_target_recipients = (pc["whd"].revenue - whd_industry_initiatives) / 150

This was previously whd_core_target_recipients = pc["whd"].CoreSpending / 150

I guess whd_core_target_recipients is a bit of a misnomer now but my interpretation is the number of households that receive the discount. After our discussion with Marcus, my understanding is now that households also get discount from the non-core target spend pot, and we're only ringfencing the industry initiatives.

@danlewis85

Copy link
Copy Markdown
Contributor

@danlewis85 You may have already caught this but would also appreciate your opinion on the new way I've calculated whd_core_target_recipients:

whd_core_target_recipients = (pc["whd"].revenue - whd_industry_initiatives) / 150

This was previously whd_core_target_recipients = pc["whd"].CoreSpending / 150

I guess whd_core_target_recipients is a bit of a misnomer now but my interpretation is the number of households that receive the discount. After our discussion with Marcus, my understanding is now that households also get discount from the non-core target spend pot, and we're only ringfencing the industry initiatives.

Yeah, the operation of WHD is a bit confusing. In Scotland it's slightly more obvious that the non-core spending covers both industry initiatives (max £7m) and spending on the broader group, whereas in England and Wales it seems as though the 2 core groups are funded from core spending and the non-core spending can act as a contingency of sorts. I think the approach of ringfencing £50m for industry initiatives and then taking the rest as the core spend is the right approach for this.

@danlewis85

Copy link
Copy Markdown
Contributor

@danlewis85 Please have a look at the code for scenarios set 3. There are three new files:

  1. phase_2_scenarios_set_3.py for model runs with mean consumption
  2. phase_2_scenarios_set_3_95pctl.py for model runs with 95th percentile consumption
  3. phase_2_scenarios_set_3_histograms.py

In the code for model runs, please pay special attention to:

  • the separation of ECO4 and GBIS in policy costs
  • definition and application of rebalancing weights for rebalancing WHD to variable charge, and removing GBIS/ECO to general taxation

The histograms code is mainly the same as set 2 but I've altered the max and min net bill change intervals to capture the range of the new results.

If you'd like to check the general pattern across scenarios, preliminary visualisation is here.

Happy with all this. I spent extra time with the ECO4 & GBIS split and that all seemed to function as anticipated (as if using ECO collectively). I also recalculated the 2/3 move to general taxation and got hte same results.

Happy for you to proceed with the outputs.

@eglucas

eglucas commented Mar 4, 2025

Copy link
Copy Markdown
Contributor Author

Hi Dan, please see the latest commit for scenarios set 4 analyses. There are two files, one using mean consumption and one using 95th percentile consumption. I have integrated the histogram table creation into these files too.

I'm still fixing the code block for generating the helper arrow values for the individual scenario dot plot, so please ignore those lines for now.

…el into scenarios_phase_2

merging new changes for ongoing review of analytical outputs.
@danlewis85

Copy link
Copy Markdown
Contributor

Hi Dan, please see the latest commit for scenarios set 4 analyses. There are two files, one using mean consumption and one using 95th percentile consumption. I have integrated the histogram table creation into these files too.

I'm still fixing the code block for generating the helper arrow values for the individual scenario dot plot, so please ignore those lines for now.

I've had a look at this, paying particular attention to the 3 general taxation split scenarios, and the helper arrows now that you've pushed the fix. All looks good.

@danlewis85

Copy link
Copy Markdown
Contributor

Bug fix for calculating bills with a unit discount inclusive of VAT.

Note that flat rebate was always inclusive of VAT, but the unit discount wasn't. This fixes that in terms of the final bills calculated for consumers.

@eglucas

eglucas commented Mar 19, 2025

Copy link
Copy Markdown
Contributor Author

Set 5 scenario runs using mean consumption.

The code is structured similarly to set 4, except that the unit discount is specified/calculated at the beginning of each run. I've also resorted to numbering them as there are quite a lot to keep track of.

@danlewis85 Please could you check the code in general, and that the outputs are as expected? Results data are visualised in the flourish charts.

I also wanted to check with you on how to handle VAT when we're specifying the discount value explicitly - I've assumed that the value assigned to the variable is already inclusive of VAT, which should get propagated to the final WHD revenue.

@danlewis85

Copy link
Copy Markdown
Contributor

Happy with 8681a02, the handling of VAT looks right in context. The new output of weighted averages looks to be correct. Many thanks.

@eglucas

eglucas commented Mar 24, 2025

Copy link
Copy Markdown
Contributor Author

Added new "Scenario 12" to set 5. This scenario represents "Option 2 (reduced benefits + cut GBIS, taxpayer funds the rest of the support)".

@danlewis85 Please could you check that it has been set up correctly 🙏🏼

@danlewis85

Copy link
Copy Markdown
Contributor

Added new "Scenario 12" to set 5. This scenario represents "Option 2 (reduced benefits + cut GBIS, taxpayer funds the rest of the support)".

@danlewis85 Please could you check that it has been set up correctly 🙏🏼

I checked the new scenario as I developed the typical domestic consumption value runs and am happy that it is correctly specified.

@eglucas

eglucas commented Apr 9, 2025

Copy link
Copy Markdown
Contributor Author

Added new files for scenarios set 6 runs.

@danlewis85 Please could you check that the support parameters and levy rebalancing weights are correctly specified?

@danlewis85

Copy link
Copy Markdown
Contributor

Added new files for scenarios set 6 runs.

@danlewis85 Please could you check that the support parameters and levy rebalancing weights are correctly specified?

I'm happy these are correctly specified. I've checked the mean script in full, and the alternative variable definitions for tdcv and percentile outputs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants