-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Private school adjustment factor (#959)
* Private school adjustment factor * remove unneeded files * change tests * change tests
- Loading branch information
1 parent
7d7eccd
commit a6316bd
Showing
6 changed files
with
478 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
policyengine_uk/parameters/gov/simulation/private_school_vat/private_school_factor.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
description: student polulation adjustment factor, tested by Vahid | ||
values: | ||
2010-01-01: 0.77 | ||
metadata: | ||
unit: /1 | ||
label: student polulation adjustment factor |
22 changes: 0 additions & 22 deletions
22
policyengine_uk/tests/policy/baseline/contrib/labour/attends_private_school.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
policyengine_uk/utils/solve_private_school_attendance_factor.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from policyengine_uk import Microsimulation | ||
from policyengine_core.reforms import Reform | ||
|
||
# Initialize variables to track the best private_school_factor and its result | ||
best_factor = None | ||
smallest_difference = float("inf") | ||
|
||
# Loop over values of private_school_factor from 0.7 to 0.8 in steps of 0.01 | ||
for factor in [round(x * 0.01, 2) for x in range(70, 81)]: | ||
# Define the reform with the current private_school_factor value | ||
reform = Reform.from_dict( | ||
{ | ||
"gov.contrib.labour.private_school_vat": { | ||
"2024-01-01.2100-12-31": 0.2 | ||
}, | ||
"gov.simulation.private_school_vat.private_school_factor": { | ||
"2024-01-01.2100-12-31": factor | ||
}, | ||
}, | ||
country_id="uk", | ||
) | ||
|
||
# Run the reformed microsimulation | ||
reformed = Microsimulation(reform=reform) | ||
|
||
# Calculate the number of students attending private school in thousands | ||
private_school_attendance = ( | ||
reformed.calculate("attends_private_school", period=2025).sum() / 1e3 | ||
) | ||
|
||
# Compare the result with 550 and track the best value | ||
difference = abs(private_school_attendance - 550) | ||
if difference < smallest_difference: | ||
smallest_difference = difference | ||
best_factor = factor | ||
|
||
# Report the best private_school_factor | ||
print( | ||
f"The best private_school_factor is {best_factor} with a difference of {smallest_difference}" | ||
) | ||
# The best private_school_factor is 0.77 with a difference of 1.3427231160653719 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.