Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1] - added the overall budgetary impact metric #20

Merged
Merged
Show file tree
Hide file tree
Changes from 6 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
Empty file.
192 changes: 192 additions & 0 deletions policyengine/economic_impact/budgetary_impact/by_program/by_program.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
from policyengine.economic_impact.base_metric_calculator import BaseMetricCalculator
from policyengine_uk import Microsimulation

class IncomeTax(BaseMetricCalculator):
def __init__(self, baseline: Microsimulation, reformed: Microsimulation, default_period: int = 2024) -> None:
super().__init__(baseline, reformed, default_period)
self.baseline = baseline
self.reformed = reformed

def calculate(self):

baseline = self.baseline.calculate("income_tax", map_to="household").sum()
reform = self.reformed.calculate("income_tax", map_to="household").sum()

change = ((reform - baseline) / baseline) * 100

return {
"baseline": round(baseline,2),
"reform": round(reform,2),
"change": round(change,1)
}

class NationalInsurance(BaseMetricCalculator):
def __init__(self, baseline: Microsimulation, reformed: Microsimulation, default_period: int = 2024) -> None:
super().__init__(baseline, reformed, default_period)
self.baseline = baseline
self.reformed = reformed

def calculate(self):

baseline = self.baseline.calculate("national_insurance", map_to="household").sum()
reform = self.reformed.calculate("national_insurance", map_to="household").sum()

change = ((reform - baseline) / baseline) * 100

return {
"baseline": round(baseline,2),
"reform": round(reform,2),
"change": round(change,1)
}

class Vat(BaseMetricCalculator):
def __init__(self, baseline: Microsimulation, reformed: Microsimulation, default_period: int = 2024) -> None:
super().__init__(baseline, reformed, default_period)
self.baseline = baseline
self.reformed = reformed

def calculate(self):

baseline = self.baseline.calculate("vat", map_to="household").sum()
reform = self.reformed.calculate("vat", map_to="household").sum()

change = ((reform - baseline) / baseline) * 100

return {
"baseline": round(baseline,2),
"reform": round(reform,2),
"change": round(change,1)
}

class CouncilTax(BaseMetricCalculator):
def __init__(self, baseline: Microsimulation, reformed: Microsimulation, default_period: int = 2024) -> None:
super().__init__(baseline, reformed, default_period)
self.baseline = baseline
self.reformed = reformed

def calculate(self):

baseline = self.baseline.calculate("council_tax", map_to="household").sum()
reform = self.reformed.calculate("council_tax", map_to="household").sum()

change = ((reform - baseline) / baseline) * 100

return {
"baseline": round(baseline,2),
"reform": round(reform,2),
"change": round(change,1)
}

class FuelDuty(BaseMetricCalculator):
def __init__(self, baseline: Microsimulation, reformed: Microsimulation, default_period: int = 2024) -> None:
super().__init__(baseline, reformed, default_period)
self.baseline = baseline
self.reformed = reformed

def calculate(self):

baseline = self.baseline.calculate("fuel_duty", map_to="household").sum()
reform = self.reformed.calculate("fuel_duty", map_to="household").sum()

change = ((reform - baseline) / baseline) * 100

return {
"baseline": round(baseline,2),
"reform": round(reform,2),
"change": round(change,1)
}

class TaxCredits(BaseMetricCalculator):
def __init__(self, baseline: Microsimulation, reformed: Microsimulation, default_period: int = 2024) -> None:
super().__init__(baseline, reformed, default_period)
self.baseline = baseline
self.reformed = reformed

def calculate(self):

baseline = self.baseline.calculate("tax_credits", map_to="household").sum() * -1
reform = self.reformed.calculate("tax_credits", map_to="household").sum() * -1

change = ((reform - baseline) / baseline) * 100

return {
"baseline": round(baseline,2),
"reform": round(reform,2),
"change": round(change,1)
}

class UniversalCredit(BaseMetricCalculator):
def __init__(self, baseline: Microsimulation, reformed: Microsimulation, default_period: int = 2024) -> None:
super().__init__(baseline, reformed, default_period)
self.baseline = baseline
self.reformed = reformed

def calculate(self):

baseline = self.baseline.calculate("universal_credit", map_to="household").sum() * -1
reform = self.reformed.calculate("universal_credit", map_to="household").sum() * -1

change = ((reform - baseline) / baseline) * 100

return {
"baseline": round(baseline,2),
"reform": round(reform,2),
"change": round(change,1)
}

class ChildBenefit(BaseMetricCalculator):
def __init__(self, baseline: Microsimulation, reformed: Microsimulation, default_period: int = 2024) -> None:
super().__init__(baseline, reformed, default_period)
self.baseline = baseline
self.reformed = reformed

def calculate(self):

baseline = self.baseline.calculate("child_benefit", map_to="household").sum() * -1
reform = self.reformed.calculate("child_benefit", map_to="household").sum() * -1

change = ((reform - baseline) / baseline) * 100

return {
"baseline": round(baseline,2),
"reform": round(reform,2),
"change": round(change,1)
}

class StatePension(BaseMetricCalculator):
def __init__(self, baseline: Microsimulation, reformed: Microsimulation, default_period: int = 2024) -> None:
super().__init__(baseline, reformed, default_period)
self.baseline = baseline
self.reformed = reformed

def calculate(self):

baseline = self.baseline.calculate("state_pension", map_to="household").sum() * -1
reform = self.reformed.calculate("state_pension", map_to="household").sum() * -1

change = ((reform - baseline) / baseline) * 100

return {
"baseline": round(baseline,2),
"reform": round(reform,2),
"change": round(change,1)
}

class PensionCredit(BaseMetricCalculator):
def __init__(self, baseline: Microsimulation, reformed: Microsimulation, default_period: int = 2024) -> None:
super().__init__(baseline, reformed, default_period)
self.baseline = baseline
self.reformed = reformed

def calculate(self):

baseline = self.baseline.calculate("pension_credit", map_to="household").sum() * -1
reform = self.reformed.calculate("pension_credit", map_to="household").sum() * -1

change = ((reform - baseline) / baseline) * 100

return {
"baseline": round(baseline,2),
"reform": round(reform,2),
"change": round(change,1)
}
Empty file.
71 changes: 71 additions & 0 deletions policyengine/economic_impact/budgetary_impact/overall/overall.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
from policyengine.economic_impact.base_metric_calculator import BaseMetricCalculator
from policyengine_uk import Microsimulation

class BudgetaryImpact(BaseMetricCalculator):
def __init__(self, baseline: Microsimulation, reformed: Microsimulation, default_period: int = 2024) -> None:
super().__init__(baseline, reformed, default_period)
self.baseline = baseline
self.reformed = reformed

def calculate(self):

baseline_total_tax = self.baseline.calculate("household_tax").sum()
reformed_total_tax = self.reformed.calculate("household_tax").sum()

tax_revenue_impact = reformed_total_tax - baseline_total_tax

baseline_total_benefits = self.baseline.calculate("household_benefits").sum()
reformed_total_benefits = self.reformed.calculate("household_benefits").sum()


benefit_spending_impact = reformed_total_benefits - baseline_total_benefits

budgetary_impact = tax_revenue_impact - benefit_spending_impact



return {
"budgetary_impact" : round(budgetary_impact,2)
}

class BenefitSpendingImpact(BaseMetricCalculator):
def __init__(self, baseline: Microsimulation, reformed: Microsimulation, default_period: int = 2024) -> None:
super().__init__(baseline, reformed, default_period)
self.baseline = baseline
self.reformed = reformed

def calculate(self):

baseline_total_benefits = self.baseline.calculate("household_benefits").sum()
reformed_total_benefits = self.reformed.calculate("household_benefits").sum()


benefit_spending_impact = reformed_total_benefits - baseline_total_benefits



return {
"baseline_total_benefits": round(baseline_total_benefits,2),
"reformed_total_benefits": round(reformed_total_benefits,2),
"benefit_spending_impact": round(benefit_spending_impact,2)
}

class TaxRevenueImpact(BaseMetricCalculator):
def __init__(self, baseline: Microsimulation, reformed: Microsimulation, default_period: int = 2024) -> None:
super().__init__(baseline, reformed, default_period)
self.baseline = baseline
self.reformed = reformed

def calculate(self):

baseline_total_tax = self.baseline.calculate("household_tax").sum()
reformed_total_tax = self.reformed.calculate("household_tax").sum()

tax_revenue_impact = reformed_total_tax - baseline_total_tax


return {
"baseline_total_tax": round(baseline_total_tax,2),
"reformed_total_tax": round(reformed_total_tax,2),
"tax_revenue_impact": round(tax_revenue_impact,2)
}
33 changes: 33 additions & 0 deletions policyengine/economic_impact/economic_impact.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,26 @@
FemalePoverty as DeepFemalePoverty,
AllPoverty as DeepGenderAllPoverty
)

from .budgetary_impact.by_program.by_program import (
IncomeTax,
NationalInsurance,
Vat,
CouncilTax,
FuelDuty,
TaxCredits,
UniversalCredit,
ChildBenefit,
StatePension,
PensionCredit
)

from .budgetary_impact.overall.overall import (
BudgetaryImpact,
BenefitSpendingImpact,
TaxRevenueImpact
)

from typing import Dict

class EconomicImpact:
Expand Down Expand Up @@ -55,6 +75,19 @@ def __init__(self, reform: dict, country: str) -> None:

# Set up metric calculators
self.metric_calculators: Dict[str, object] = {
"budgetary/overall/budgetary_impact" : BudgetaryImpact(self.baseline, self.reformed),
"budgetary/overall/benefit_spending_impact" : BenefitSpendingImpact(self.baseline, self.reformed),
"budgetary/overall/tax_revenue_impact" : TaxRevenueImpact(self.baseline, self.reformed),
"budgetary/by_program/income_tax" : IncomeTax(self.baseline, self.reformed),
"budgetary/by_program/national_insurance" : NationalInsurance(self.baseline, self.reformed),
"budgetary/by_program/vat" : Vat(self.baseline, self.reformed),
"budgetary/by_program/council_tax" : CouncilTax(self.baseline, self.reformed),
"budgetary/by_program/fuel_duty" : FuelDuty(self.baseline, self.reformed),
"budgetary/by_program/tax_credits" : TaxCredits(self.baseline, self.reformed),
"budgetary/by_program/universal_credits" : UniversalCredit(self.baseline, self.reformed),
"budgetary/by_program/child_benefits" : ChildBenefit(self.baseline, self.reformed),
"budgetary/by_program/state_pension" : StatePension(self.baseline, self.reformed),
"budgetary/by_program/pension_credit" : PensionCredit(self.baseline, self.reformed),
"inequality/gini": GiniCalculator(self.baseline, self.reformed),
"inequality/top_1_pct_share": Top1PctShareCalculator(self.baseline, self.reformed),
"inequality/top_10_pct_share": Top10PctShareCalculator(self.baseline, self.reformed),
Expand Down
Loading
Loading