diff --git a/.gitignore b/.gitignore
index 7fb437ae2..eb9eb8e22 100644
--- a/.gitignore
+++ b/.gitignore
@@ -52,3 +52,5 @@ policyengine_uk/calibration/*.h5
**/*.log
**/ukmod.json
*.ipynb
+
+!test9.ipynb
\ No newline at end of file
diff --git a/changelog_entry.yaml b/changelog_entry.yaml
index e69de29bb..aeb4843eb 100644
--- a/changelog_entry.yaml
+++ b/changelog_entry.yaml
@@ -0,0 +1,11 @@
+- bump: minor
+ changes:
+ added:
+ - Tax on excess pension contributions
+ fixed:
+ - Include Scottish income tax calculation within overall UK income tax calculation
+ - Apply allowances to all types of income
+ - Prevent negative income tax output
+ - Update Dividend Allowance values
+ - Correct Starter Rate for Savings taper structure
+ - Prevent calculation errors due to empty extra dividend bracket with conflicting rates
\ No newline at end of file
diff --git a/policyengine_uk/data/datasets/spi.py b/policyengine_uk/data/datasets/spi.py
index 88a7b7184..f91d04c78 100644
--- a/policyengine_uk/data/datasets/spi.py
+++ b/policyengine_uk/data/datasets/spi.py
@@ -49,20 +49,39 @@ def generate(self):
)
data["savings_interest_income"] = df.INCBBS
data["property_income"] = df.INCPROP
- data["employment_income"] = df.PAY
+ data["employment_income"] = df.PAY + df.EPB
data["employment_expenses"] = df.EXPS
- data["pension_income"] = df.PENSION
- data["pension_contributions"] = df.PENSRLF - df.PSAV_XS
+ data["private_pension_income"] = df.PENSION
+ # The below underestimates those with high amounts of excess pension
+ # savings, as it does not include the Annual Allowance
+ data["private_pension_contributions"] = df.PSAV_XS
+ data["pension_contributions_relief"] = df.PENSRLF
data["self_employment_income"] = df.PROFITS
- # HMRC seems to assume the trading allowance is already deducted (per record inspection of SREF 15494988 in 2020-21)
+ # HMRC seems to assume the trading and property allowance are already deducted
+ # (per record inspection of SREF 15494988 in 2020-21)
data["trading_allowance"] = np.zeros(len(df))
+ data["property_allowance"] = np.zeros(len(df))
+ data["savings_starter_rate_income"] = np.zeros(len(df))
data["capital_allowances"] = df.CAPALL
data["loss_relief"] = df.LOSSBF
data["is_SP_age"] = df.SPA == 1
data["state_pension"] = df.SRP
data["other_tax_credits"] = df.TAX_CRED
- data["miscellaneous_income"] = df.MOTHINC
+ data["miscellaneous_income"] = (
+ df.MOTHINC
+ + df.INCPBEN
+ + df.OSSBEN
+ + df.TAXTERM
+ + df.UBISJA
+ + df.OTHERINC
+ )
data["gift_aid"] = df.GIFTAID + df.GIFTINV
+ data["other_investment_income"] = df.OTHERINV
+ data["covenanted_payments"] = df.COVNTS
+ data["other_deductions"] = df.MOTHDED + df.DEFICIEN
+ data["married_couples_allowance"] = df.MCAS
+ data["blind_persons_allowance"] = df.BPADUE
+ data["marriage_allowance"] = np.where(df.MAIND == 1, 1_250, 0)
for field in data:
data[field] = {self.time_period: data[field]}
@@ -71,7 +90,7 @@ def generate(self):
class SPI_2020_21(SPI):
- spi_data_file_path = "~/Downloads/UKDA-9121-tab/tab/put2021uk.tab"
+ spi_data_file_path = "~/Desktop/put2021uk.tab"
file_path = STORAGE_FOLDER / "spi_2020_21.h5"
label = "SPI 2020-21"
name = "spi_2020_21"
diff --git a/policyengine_uk/parameters/gov/hmrc/income_tax/allowances/dividend_allowance.yaml b/policyengine_uk/parameters/gov/hmrc/income_tax/allowances/dividend_allowance.yaml
index f9512e957..466f6c8f3 100644
--- a/policyengine_uk/parameters/gov/hmrc/income_tax/allowances/dividend_allowance.yaml
+++ b/policyengine_uk/parameters/gov/hmrc/income_tax/allowances/dividend_allowance.yaml
@@ -1,9 +1,14 @@
description: Amount of dividend income untaxed per year
values:
- 2015-06-05: 2_000
+ 2016-04-06: 5_000
+ 2018-04-06: 2_000
+ 2023-04-06: 1_000
+ 2024-04-06: 500
metadata:
name: dividend_allowance
label: Dividend Allowance
period: year
unit: currency-GBP
- reference: https://www.gov.uk/government/publications/rates-and-allowances-income-tax/income-tax-rates-and-allowances-current-and-past
+ reference:
+ - title: Tax on dividends
+ href: https://www.gov.uk/tax-on-dividends
diff --git a/policyengine_uk/parameters/gov/hmrc/income_tax/earned_taxable_income_exclusions.yaml b/policyengine_uk/parameters/gov/hmrc/income_tax/earned_taxable_income_exclusions.yaml
index b3fff61ae..ff128f686 100644
--- a/policyengine_uk/parameters/gov/hmrc/income_tax/earned_taxable_income_exclusions.yaml
+++ b/policyengine_uk/parameters/gov/hmrc/income_tax/earned_taxable_income_exclusions.yaml
@@ -3,9 +3,8 @@ values:
0000-01-01:
- taxable_savings_interest_income
- taxable_dividend_income
- - allowances
+ - received_allowances_earned_income
- marriage_allowance
- - pension_contributions_relief
metadata:
unit: list
diff --git a/policyengine_uk/parameters/gov/hmrc/income_tax/income_tax_additions.yaml b/policyengine_uk/parameters/gov/hmrc/income_tax/income_tax_additions.yaml
new file mode 100644
index 000000000..7ddbb71f4
--- /dev/null
+++ b/policyengine_uk/parameters/gov/hmrc/income_tax/income_tax_additions.yaml
@@ -0,0 +1,11 @@
+description: All variables that are added together to calculate total income tax
+metadata:
+ label: Additive components of total income tax
+ unit: list
+values:
+ 0000-01-01:
+ - earned_income_tax
+ - savings_income_tax
+ - dividend_income_tax
+ - CB_HITC
+ - private_pension_contributions_tax
diff --git a/policyengine_uk/parameters/gov/hmrc/income_tax/income_tax_subtractions.yaml b/policyengine_uk/parameters/gov/hmrc/income_tax/income_tax_subtractions.yaml
new file mode 100644
index 000000000..e25d55974
--- /dev/null
+++ b/policyengine_uk/parameters/gov/hmrc/income_tax/income_tax_subtractions.yaml
@@ -0,0 +1,8 @@
+description: All variables that are subtracted from the base amount to calculate total income tax
+metadata:
+ label: Subtractive components of total income tax
+ unit: list
+values:
+ 0000-01-01:
+ - capped_mcad
+ - other_tax_credits
diff --git a/policyengine_uk/parameters/gov/hmrc/income_tax/rates/dividends.yaml b/policyengine_uk/parameters/gov/hmrc/income_tax/rates/dividends.yaml
index 7ba3701dd..e98e9198a 100644
--- a/policyengine_uk/parameters/gov/hmrc/income_tax/rates/dividends.yaml
+++ b/policyengine_uk/parameters/gov/hmrc/income_tax/rates/dividends.yaml
@@ -75,7 +75,8 @@ brackets:
label: Extra dividend tax bracket rate
unit: /1
values:
- 2015-06-05: 0.3935
+ 2015-06-01: 0.381
+ 2022-06-05: 0.3935
threshold:
description: The lower threshold for the extra dividend bracket rate.
metadata:
diff --git a/policyengine_uk/parameters/gov/hmrc/income_tax/rates/savings_starter_rate/phase_out.yaml b/policyengine_uk/parameters/gov/hmrc/income_tax/rates/savings_starter_rate/phase_out.yaml
new file mode 100644
index 000000000..c7b52e24e
--- /dev/null
+++ b/policyengine_uk/parameters/gov/hmrc/income_tax/rates/savings_starter_rate/phase_out.yaml
@@ -0,0 +1,9 @@
+description: Starter Rate for Savings phase-out rate
+values:
+ 2014-04-06: 1
+metadata:
+ unit: currency_GBP
+ description: Rate, above the max Personal Allowance, at which Starter Rate for Savings total amount phases out, for each additional pound of non-savings income
+ reference:
+ - title: Tax on savings interest
+ href: https://www.gov.uk/apply-tax-free-interest-on-savings
diff --git a/policyengine_uk/parameters/gov/hmrc/income_tax/rates/scotland/post_starter_rate.yaml b/policyengine_uk/parameters/gov/hmrc/income_tax/rates/scotland/post_starter_rate.yaml
index 614d753e9..4a9433ea7 100644
--- a/policyengine_uk/parameters/gov/hmrc/income_tax/rates/scotland/post_starter_rate.yaml
+++ b/policyengine_uk/parameters/gov/hmrc/income_tax/rates/scotland/post_starter_rate.yaml
@@ -26,7 +26,11 @@ brackets:
values:
2018-06-01: 2_000
2019-06-01: 2_049
- 2020-06-01: 2_085
+ 2020-03-04:
+ value: 2_085
+ reference:
+ - title: "Capture in full: Tax rates 2020/21; Spring Budget 2020"
+ href: https://taxscape.deloitte.com/taxtables/deloitte-uk-tax-rates-2020-21--updated.pdf
2022-01-01:
value: 2_162
reference:
@@ -53,7 +57,11 @@ brackets:
unit: currency-GBP
values:
2018-06-01: 12_150
- 2020-06-01: 12_444
+ 2020-03-04:
+ value: 12_444
+ reference:
+ - title: "Capture in full: Tax rates 2020/21; Spring Budget 2020"
+ href: https://taxscape.deloitte.com/taxtables/deloitte-uk-tax-rates-2020-21--updated.pdf
2021-06-01: 12_658
2022-01-01:
value: 13_118
@@ -81,7 +89,11 @@ brackets:
values:
2018-06-01: 31_580
2019-06-01: 30_930
- 2020-06-01: 30_930
+ 2020-03-04:
+ value: 30_930
+ reference:
+ - title: "Capture in full: Tax rates 2020/21; Spring Budget 2020"
+ href: https://taxscape.deloitte.com/taxtables/deloitte-uk-tax-rates-2020-21--updated.pdf
2022-01-01:
value: 31_092
reference:
@@ -99,6 +111,11 @@ brackets:
unit: /1
values:
2018-06-01: 0.47
+ 2020-03-04:
+ value: 0.46
+ reference:
+ - title: "Capture in full: Tax rates 2020/21; Spring Budget 2020"
+ href: https://taxscape.deloitte.com/taxtables/deloitte-uk-tax-rates-2020-21--updated.pdf
threshold:
description: The threshold at which an individual pays the Scottish additional
rate
diff --git a/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit.yaml b/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit.yaml
index bc10f258c..9d59d344e 100644
--- a/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit.yaml
+++ b/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit.yaml
@@ -6,7 +6,7 @@
person:
age: 30
employment_income: 30_000
- pension_contributions: 1_000
+ private_pension_contributions: 1_000
weekly_hours: 20
benunits:
benunit:
@@ -30,7 +30,7 @@
person:
age: 30
employment_income: 3_000
- pension_contributions: 1_000
+ private_pension_contributions: 1_000
weekly_hours: 20
benunits:
benunit:
@@ -85,7 +85,7 @@
age: 20
weekly_hours: 25
employment_income: 12_000
- pension_contributions: 57
+ private_pension_contributions: 57
dla_m: 62.55 * 52
uc_limited_capability_for_WRA: true
person_2:
diff --git a/policyengine_uk/tests/policy/baseline/finance/tax/income_tax/savings_starter_rate_income.yaml b/policyengine_uk/tests/policy/baseline/finance/tax/income_tax/savings_starter_rate_income.yaml
new file mode 100644
index 000000000..c2eb08bdc
--- /dev/null
+++ b/policyengine_uk/tests/policy/baseline/finance/tax/income_tax/savings_starter_rate_income.yaml
@@ -0,0 +1,44 @@
+- name: Full savings starter rate allowance
+ period: 2024
+ input:
+ basic_rate_savings_income_pre_starter: 5_000
+ earned_taxable_income: 15_000
+ taxable_dividend_income: 0
+ output:
+ savings_starter_rate_income: 5_000
+
+- name: Partial savings starter rate allowance
+ period: 2024
+ input:
+ basic_rate_savings_income_pre_starter: 4_000
+ earned_taxable_income: 19_000
+ taxable_dividend_income: 0
+ output:
+ savings_starter_rate_income: 3_570
+
+- name: No savings starter rate allowance due to high non-savings income
+ period: 2024
+ input:
+ basic_rate_savings_income_pre_starter: 2_000
+ earned_taxable_income: 22_000
+ taxable_dividend_income: 1_000
+ output:
+ savings_starter_rate_income: 0
+
+- name: Savings income exceeds allowance
+ period: 2024
+ input:
+ basic_rate_savings_income_pre_starter: 10_000
+ earned_taxable_income: 16_000
+ taxable_dividend_income: 0
+ output:
+ savings_starter_rate_income: 5_000
+
+- name: Partial allowance with dividend income
+ period: 2024
+ input:
+ basic_rate_savings_income_pre_starter: 5_000
+ earned_taxable_income: 16_000
+ taxable_dividend_income: 2_000
+ output:
+ savings_starter_rate_income: 4_570
\ No newline at end of file
diff --git a/policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/allowances/is_allowance_eligible.yaml b/policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/allowances/is_allowance_eligible.yaml
index 96864baf2..921706fe0 100644
--- a/policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/allowances/is_allowance_eligible.yaml
+++ b/policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/allowances/is_allowance_eligible.yaml
@@ -61,7 +61,7 @@
period: 2024
input: {}
output:
- dividend_allowance: 2000.0
+ dividend_allowance: 500.0
- name: Allowances Applicable to Adjusted Net Income
period: 2024
diff --git a/policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/allowances/received_allowances/received_allowances.yaml b/policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/allowances/received_allowances/received_allowances.yaml
new file mode 100644
index 000000000..e8c912a01
--- /dev/null
+++ b/policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/allowances/received_allowances/received_allowances.yaml
@@ -0,0 +1,44 @@
+- name: Received allowances with low income
+ period: 2024
+ input:
+ received_allowances_earned_income: 8_000
+ received_allowances_savings_income: 1_000
+ received_allowances_dividend_income: 500
+ output:
+ received_allowances: 9_500
+
+- name: Received allowances with medium income
+ period: 2024
+ input:
+ received_allowances_earned_income: 25_000
+ received_allowances_savings_income: 3_000
+ received_allowances_dividend_income: 2_000
+ output:
+ received_allowances: 30_000
+
+- name: Received allowances with high income
+ period: 2024
+ input:
+ received_allowances_earned_income: 80_000
+ received_allowances_savings_income: 10_000
+ received_allowances_dividend_income: 5_000
+ output:
+ received_allowances: 95_000
+
+- name: Received allowances with uneven amounts
+ period: 2024
+ input:
+ received_allowances_earned_income: 42_567.50
+ received_allowances_savings_income: 3_789.25
+ received_allowances_dividend_income: 1_234.75
+ output:
+ received_allowances: 47_591.50
+
+- name: Received allowances with zero savings and dividend income
+ period: 2024
+ input:
+ received_allowances_earned_income: 50_000
+ received_allowances_savings_income: 0
+ received_allowances_dividend_income: 0
+ output:
+ received_allowances: 50_000
\ No newline at end of file
diff --git a/policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/allowances/received_allowances/received_allowances_dividend_income.yaml b/policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/allowances/received_allowances/received_allowances_dividend_income.yaml
new file mode 100644
index 000000000..bc8ca3381
--- /dev/null
+++ b/policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/allowances/received_allowances/received_allowances_dividend_income.yaml
@@ -0,0 +1,59 @@
+- name: Dividend income less than remaining allowance
+ period: 2024
+ input:
+ allowances: 12_570
+ received_allowances_earned_income: 8_000
+ received_allowances_savings_income: 2_000
+ taxable_dividend_income: 2_000
+ output:
+ received_allowances_dividend_income: 2_000
+
+- name: Dividend income equal to remaining allowance
+ period: 2024
+ input:
+ allowances: 12_570
+ received_allowances_earned_income: 10_000
+ received_allowances_savings_income: 570
+ taxable_dividend_income: 2_000
+ output:
+ received_allowances_dividend_income: 2_000
+
+- name: Dividend income greater than remaining allowance
+ period: 2024
+ input:
+ allowances: 12_570
+ received_allowances_earned_income: 11_000
+ received_allowances_savings_income: 1_000
+ taxable_dividend_income: 1_000
+ output:
+ received_allowances_dividend_income: 570
+
+- name: No remaining allowance
+ period: 2024
+ input:
+ allowances: 12_570
+ received_allowances_earned_income: 10_570
+ received_allowances_savings_income: 2_000
+ taxable_dividend_income: 1_000
+ output:
+ received_allowances_dividend_income: 0
+
+- name: Negative taxable dividend income
+ period: 2024
+ input:
+ allowances: 12_570
+ received_allowances_earned_income: 10_000
+ received_allowances_savings_income: 1_000
+ taxable_dividend_income: -500
+ output:
+ received_allowances_dividend_income: 0
+
+- name: Negative remaining allowance
+ period: 2024
+ input:
+ allowances: 12_570
+ received_allowances_earned_income: 11_000
+ received_allowances_savings_income: 2_000
+ taxable_dividend_income: 1_000
+ output:
+ received_allowances_dividend_income: 0
\ No newline at end of file
diff --git a/policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/allowances/received_allowances/received_allowances_earned_income.yaml b/policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/allowances/received_allowances/received_allowances_earned_income.yaml
new file mode 100644
index 000000000..3f9c06ad8
--- /dev/null
+++ b/policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/allowances/received_allowances/received_allowances_earned_income.yaml
@@ -0,0 +1,59 @@
+- name: Earned income less than allowances
+ period: 2024
+ input:
+ allowances: 12_570
+ adjusted_net_income: 10_000
+ taxable_savings_interest_income: 500
+ taxable_dividend_income: 500
+ output:
+ received_allowances_earned_income: 9_000
+
+- name: Earned income equal to allowances
+ period: 2024
+ input:
+ allowances: 12_570
+ adjusted_net_income: 13_570
+ taxable_savings_interest_income: 500
+ taxable_dividend_income: 500
+ output:
+ received_allowances_earned_income: 12_570
+
+- name: Earned income greater than allowances
+ period: 2024
+ input:
+ allowances: 12_570
+ adjusted_net_income: 50_000
+ taxable_savings_interest_income: 2_000
+ taxable_dividend_income: 3_000
+ output:
+ received_allowances_earned_income: 12_570
+
+- name: Low earned income with significant savings and dividends
+ period: 2024
+ input:
+ allowances: 12_570
+ adjusted_net_income: 20_000
+ taxable_savings_interest_income: 8_000
+ taxable_dividend_income: 7_000
+ output:
+ received_allowances_earned_income: 5_000
+
+- name: Earned income only, no savings or dividends
+ period: 2024
+ input:
+ allowances: 12_570
+ adjusted_net_income: 30_000
+ taxable_savings_interest_income: 0
+ taxable_dividend_income: 0
+ output:
+ received_allowances_earned_income: 12_570
+
+- name: Adjusted net income is erroneously negative
+ period: 2024
+ input:
+ allowances: 12_570
+ adjusted_net_income: -10_000
+ taxable_savings_interest_income: 0
+ taxable_dividend_income: 0
+ output:
+ received_allowances_earned_income: 0
\ No newline at end of file
diff --git a/policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/allowances/received_allowances/received_allowances_savings_income.yaml b/policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/allowances/received_allowances/received_allowances_savings_income.yaml
new file mode 100644
index 000000000..ff181a517
--- /dev/null
+++ b/policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/allowances/received_allowances/received_allowances_savings_income.yaml
@@ -0,0 +1,53 @@
+- name: Savings income less than remaining allowance
+ period: 2024
+ input:
+ allowances: 12_570
+ received_allowances_earned_income: 10_000
+ taxable_savings_interest_income: 2_000
+ output:
+ received_allowances_savings_income: 2_000
+
+- name: Savings income equal to remaining allowance
+ period: 2024
+ input:
+ allowances: 12_570
+ received_allowances_earned_income: 10_570
+ taxable_savings_interest_income: 2_000
+ output:
+ received_allowances_savings_income: 2_000
+
+- name: Savings income greater than remaining allowance
+ period: 2024
+ input:
+ allowances: 12_570
+ received_allowances_earned_income: 11_570
+ taxable_savings_interest_income: 3_000
+ output:
+ received_allowances_savings_income: 1_000
+
+- name: No remaining allowance
+ period: 2024
+ input:
+ allowances: 12_570
+ received_allowances_earned_income: 12_570
+ taxable_savings_interest_income: 1_000
+ output:
+ received_allowances_savings_income: 0
+
+- name: Negative taxable savings interest income
+ period: 2024
+ input:
+ allowances: 12_570
+ received_allowances_earned_income: 10_000
+ taxable_savings_interest_income: -500
+ output:
+ received_allowances_savings_income: 0
+
+- name: Negative remaining allowance
+ period: 2024
+ input:
+ allowances: 12_570
+ received_allowances_earned_income: 13_000
+ taxable_savings_interest_income: 1_000
+ output:
+ received_allowances_savings_income: 0
\ No newline at end of file
diff --git a/policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/bases/taxed_dividend_income.yaml b/policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/bases/taxed_dividend_income.yaml
index 9ed5dc925..953bf8f4c 100644
--- a/policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/bases/taxed_dividend_income.yaml
+++ b/policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/bases/taxed_dividend_income.yaml
@@ -3,6 +3,8 @@
input:
taxable_dividend_income: 0
dividend_allowance: 1000
+ # Nullify Personal Allowance for testing purposes
+ gov.hmrc.income_tax.allowances.personal_allowance.amount: 0
output:
taxed_dividend_income: 0
@@ -11,6 +13,8 @@
input:
taxable_dividend_income: 500
dividend_allowance: 1000
+ # Nullify Personal Allowance for testing purposes
+ gov.hmrc.income_tax.allowances.personal_allowance.amount: 0
output:
taxed_dividend_income: 0
@@ -19,6 +23,8 @@
input:
taxable_dividend_income: 1000
dividend_allowance: 1000
+ # Nullify Personal Allowance for testing purposes
+ gov.hmrc.income_tax.allowances.personal_allowance.amount: 0
output:
taxed_dividend_income: 0
@@ -27,6 +33,8 @@
input:
taxable_dividend_income: 1100
dividend_allowance: 1000
+ # Nullify Personal Allowance for testing purposes
+ gov.hmrc.income_tax.allowances.personal_allowance.amount: 0
output:
taxed_dividend_income: 100
@@ -35,6 +43,8 @@
input:
taxable_dividend_income: 50000
dividend_allowance: 2000
+ # Nullify Personal Allowance for testing purposes
+ gov.hmrc.income_tax.allowances.personal_allowance.amount: 0
output:
taxed_dividend_income: 48000
@@ -43,6 +53,8 @@
input:
taxable_dividend_income: 1000000
dividend_allowance: 2000
+ # Nullify Personal Allowance for testing purposes
+ gov.hmrc.income_tax.allowances.personal_allowance.amount: 0
output:
taxed_dividend_income: 998000
@@ -51,6 +63,8 @@
input:
taxable_dividend_income: 5000
dividend_allowance: 0
+ # Nullify Personal Allowance for testing purposes
+ gov.hmrc.income_tax.allowances.personal_allowance.amount: 0
output:
taxed_dividend_income: 5000
@@ -59,6 +73,8 @@
input:
taxable_dividend_income: 2500.50
dividend_allowance: 2000.00
+ # Nullify Personal Allowance for testing purposes
+ gov.hmrc.income_tax.allowances.personal_allowance.amount: 0
output:
taxed_dividend_income: 500.50
@@ -67,6 +83,8 @@
input:
taxable_dividend_income: 1000
dividend_allowance: 2000
+ # Nullify Personal Allowance for testing purposes
+ gov.hmrc.income_tax.allowances.personal_allowance.amount: 0
output:
taxed_dividend_income: 0
@@ -75,5 +93,7 @@
input:
taxable_dividend_income: 1000.01
dividend_allowance: 1000
+ # Nullify Personal Allowance for testing purposes
+ gov.hmrc.income_tax.allowances.personal_allowance.amount: 0
output:
taxed_dividend_income: 0.01
diff --git a/policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/income_tax.yaml b/policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/income_tax.yaml
index 4ed9fee07..1249f26d0 100644
--- a/policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/income_tax.yaml
+++ b/policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/income_tax.yaml
@@ -10,7 +10,7 @@
absolute_error_margin: 10
input:
employment_income: 34000
- pension_contributions: 1200
+ private_pension_contributions: 1200
output:
income_tax: (34000 - 1200 - 12500) * 0.2
- name: Income Tax for earner with pension contributions in 2018
@@ -18,7 +18,7 @@
absolute_error_margin: 10
input:
employment_income: 34000
- pension_contributions: 1200
+ private_pension_contributions: 1200
output:
income_tax: (34000 - 1200 - 11500) * 0.2
- name: Income Tax for earner with pension contributions in 2019
@@ -26,7 +26,7 @@
absolute_error_margin: 10
input:
employment_income: 34000
- pension_contributions: 1200
+ private_pension_contributions: 1200
output:
income_tax: (34000 - 1200 - 11850) * 0.2
- name: Income Tax for earner in 2019
diff --git a/policyengine_uk/tests/policy/baseline/gov/hmrc/pensions/pension_contributions_relief.yaml b/policyengine_uk/tests/policy/baseline/gov/hmrc/pensions/pension_contributions_relief.yaml
index 24b6b8307..f3a8d9b5c 100644
--- a/policyengine_uk/tests/policy/baseline/gov/hmrc/pensions/pension_contributions_relief.yaml
+++ b/policyengine_uk/tests/policy/baseline/gov/hmrc/pensions/pension_contributions_relief.yaml
@@ -3,7 +3,7 @@
absolute_error_margin: 0
input:
employment_income: 76000
- pension_contributions: 40000
+ private_pension_contributions: 40000
output:
pension_contributions_relief: 40000
- name: Pension relief excessive
@@ -11,7 +11,7 @@
absolute_error_margin: 0
input:
employment_income: 2000000
- pension_contributions: 400000
+ private_pension_contributions: 400000
output:
pension_contributions_relief: 4000
- name: £30k self-employment income, no private pension contributions
diff --git a/policyengine_uk/tests/policy/integration/income.yaml b/policyengine_uk/tests/policy/integration/income.yaml
index 5df324c12..2093e0f17 100644
--- a/policyengine_uk/tests/policy/integration/income.yaml
+++ b/policyengine_uk/tests/policy/integration/income.yaml
@@ -32,6 +32,8 @@
absolute_error_margin: 0
input:
dividend_income: 50_000
+ # Nullify Personal Allowance for testing purposes
+ gov.hmrc.income_tax.allowances.personal_allowance.amount: 0
output:
dividend_income_tax: 6_225
diff --git a/policyengine_uk/variables/gov/hmrc/income_tax/allowances/allowances.py b/policyengine_uk/variables/gov/hmrc/income_tax/allowances/allowances.py
index 72e93a8b8..159468262 100644
--- a/policyengine_uk/variables/gov/hmrc/income_tax/allowances/allowances.py
+++ b/policyengine_uk/variables/gov/hmrc/income_tax/allowances/allowances.py
@@ -234,4 +234,5 @@ class allowances(Variable):
"covenanted_payments",
"charitable_investment_gifts",
"other_deductions",
+ "pension_contributions_relief",
]
diff --git a/policyengine_uk/variables/gov/hmrc/income_tax/allowances/received_allowances/received_allowances.py b/policyengine_uk/variables/gov/hmrc/income_tax/allowances/received_allowances/received_allowances.py
new file mode 100644
index 000000000..f4f15bf2e
--- /dev/null
+++ b/policyengine_uk/variables/gov/hmrc/income_tax/allowances/received_allowances/received_allowances.py
@@ -0,0 +1,15 @@
+from policyengine_uk.model_api import *
+
+
+class received_allowances(Variable):
+ value_type = float
+ entity = Person
+ label = "Total of all allowances received by an individual; minimum value of 0, maximum value of 100% of the individual's income"
+ definition_period = YEAR
+ unit = GBP
+
+ adds = [
+ "received_allowances_earned_income",
+ "received_allowances_savings_income",
+ "received_allowances_dividend_income",
+ ]
diff --git a/policyengine_uk/variables/gov/hmrc/income_tax/allowances/received_allowances/received_allowances_dividend_income.py b/policyengine_uk/variables/gov/hmrc/income_tax/allowances/received_allowances/received_allowances_dividend_income.py
new file mode 100644
index 000000000..3ec0cd9fd
--- /dev/null
+++ b/policyengine_uk/variables/gov/hmrc/income_tax/allowances/received_allowances/received_allowances_dividend_income.py
@@ -0,0 +1,32 @@
+from policyengine_uk.model_api import *
+
+
+class received_allowances_dividend_income(Variable):
+ value_type = float
+ entity = Person
+ label = "The portion of all allowances (excluding those for a particular income type) calculated last, applied to dividends."
+ unit = GBP
+ definition_period = YEAR
+ reference = "Income Tax Act 2007 s. 35"
+
+ def formula(person, period, parameters):
+ all_allowances = person("allowances", period)
+ received_allowances_earned_income = person(
+ "received_allowances_earned_income", period
+ )
+ received_allowances_savings_income = person(
+ "received_allowances_savings_income", period
+ )
+ remaining_allowance = (
+ all_allowances
+ - received_allowances_earned_income
+ - received_allowances_savings_income
+ )
+
+ dividend_income = person("taxable_dividend_income", period)
+
+ return where(
+ dividend_income < remaining_allowance,
+ max_(0, dividend_income),
+ max_(0, remaining_allowance),
+ )
diff --git a/policyengine_uk/variables/gov/hmrc/income_tax/allowances/received_allowances/received_allowances_earned_income.py b/policyengine_uk/variables/gov/hmrc/income_tax/allowances/received_allowances/received_allowances_earned_income.py
new file mode 100644
index 000000000..c72826c0c
--- /dev/null
+++ b/policyengine_uk/variables/gov/hmrc/income_tax/allowances/received_allowances/received_allowances_earned_income.py
@@ -0,0 +1,27 @@
+from policyengine_uk.model_api import *
+
+
+class received_allowances_earned_income(Variable):
+ value_type = float
+ entity = Person
+ label = "The portion of all allowances (minus those only applicable to certain types of income) that is applied to earned income"
+ unit = GBP
+ definition_period = YEAR
+ reference = "Income Tax Act 2007 s. 35"
+
+ def formula(person, period, parameters):
+ # This portion of all allowances, applied first, excludes savings and dividends
+
+ all_allowances = person("allowances", period)
+
+ all_income = person("adjusted_net_income", period)
+ excluded_income = person(
+ "taxable_savings_interest_income", period
+ ) + person("taxable_dividend_income", period)
+ earned_income = all_income - excluded_income
+
+ return where(
+ earned_income < all_allowances,
+ max_(0, earned_income),
+ all_allowances,
+ )
diff --git a/policyengine_uk/variables/gov/hmrc/income_tax/allowances/received_allowances/received_allowances_savings_income.py b/policyengine_uk/variables/gov/hmrc/income_tax/allowances/received_allowances/received_allowances_savings_income.py
new file mode 100644
index 000000000..926765a83
--- /dev/null
+++ b/policyengine_uk/variables/gov/hmrc/income_tax/allowances/received_allowances/received_allowances_savings_income.py
@@ -0,0 +1,27 @@
+from policyengine_uk.model_api import *
+
+
+class received_allowances_savings_income(Variable):
+ value_type = float
+ entity = Person
+ label = "The portion of all allowances (minus those only applicable to one income type) calculated after earned taxable income, but before dividends. This is applied to savings interest income."
+ unit = GBP
+ definition_period = YEAR
+ reference = "Income Tax Act 2007 s. 35"
+
+ def formula(person, period, parameters):
+ all_allowances = person("allowances", period)
+ received_allowances_earned_income = person(
+ "received_allowances_earned_income", period
+ )
+ remaining_allowance = (
+ all_allowances - received_allowances_earned_income
+ )
+
+ savings_income = person("taxable_savings_interest_income", period)
+
+ return where(
+ savings_income < remaining_allowance,
+ max_(0, savings_income),
+ max_(0, remaining_allowance),
+ )
diff --git a/policyengine_uk/variables/gov/hmrc/income_tax/bases/savings_income/taxable_savings_interest_income.py b/policyengine_uk/variables/gov/hmrc/income_tax/bases/savings_income/taxable_savings_interest_income.py
index 67121d9f0..0e432661a 100644
--- a/policyengine_uk/variables/gov/hmrc/income_tax/bases/savings_income/taxable_savings_interest_income.py
+++ b/policyengine_uk/variables/gov/hmrc/income_tax/bases/savings_income/taxable_savings_interest_income.py
@@ -13,6 +13,8 @@ class taxable_savings_interest_income(Variable):
unit = GBP
def formula(person, period, parameters):
- total_interest = person("savings_interest_income", period)
+ standard_interest = person("savings_interest_income", period)
+ other_interest = person("other_investment_income", period)
+ total_interest = standard_interest + other_interest
exempt_interest = person("tax_free_savings_income", period)
return max_(0, total_interest - exempt_interest)
diff --git a/policyengine_uk/variables/gov/hmrc/income_tax/bases/taxed_dividend_income.py b/policyengine_uk/variables/gov/hmrc/income_tax/bases/taxed_dividend_income.py
index ff110c7b9..82bec3f1d 100644
--- a/policyengine_uk/variables/gov/hmrc/income_tax/bases/taxed_dividend_income.py
+++ b/policyengine_uk/variables/gov/hmrc/income_tax/bases/taxed_dividend_income.py
@@ -16,5 +16,6 @@ def formula(person, period, parameters):
return max_(
0,
person("taxable_dividend_income", period)
+ - person("received_allowances_dividend_income", period)
- person("dividend_allowance", period),
)
diff --git a/policyengine_uk/variables/gov/hmrc/income_tax/bracketized_savings_income/add_rate_savings_income.py b/policyengine_uk/variables/gov/hmrc/income_tax/bracketized_savings_income/add_rate_savings_income.py
index 7d5314c7b..e1a215307 100644
--- a/policyengine_uk/variables/gov/hmrc/income_tax/bracketized_savings_income/add_rate_savings_income.py
+++ b/policyengine_uk/variables/gov/hmrc/income_tax/bracketized_savings_income/add_rate_savings_income.py
@@ -18,7 +18,11 @@ def formula(person, period, parameters):
savings_deductions = add(
person,
period,
- ["savings_allowance", "savings_starter_rate_income"],
+ [
+ "received_allowances_savings_income",
+ "savings_allowance",
+ "savings_starter_rate_income",
+ ],
)
savings_income_less_deductions = max_(
0,
diff --git a/policyengine_uk/variables/gov/hmrc/income_tax/bracketized_savings_income/basic_rate_savings_income.py b/policyengine_uk/variables/gov/hmrc/income_tax/bracketized_savings_income/basic_rate_savings_income.py
index f8269b0f8..49d196527 100644
--- a/policyengine_uk/variables/gov/hmrc/income_tax/bracketized_savings_income/basic_rate_savings_income.py
+++ b/policyengine_uk/variables/gov/hmrc/income_tax/bracketized_savings_income/basic_rate_savings_income.py
@@ -18,7 +18,11 @@ def formula(person, period, parameters):
savings_deductions = add(
person,
period,
- ["savings_allowance", "savings_starter_rate_income"],
+ [
+ "received_allowances_savings_income",
+ "savings_allowance",
+ "savings_starter_rate_income",
+ ],
)
savings_income_less_deductions = max_(
0,
diff --git a/policyengine_uk/variables/gov/hmrc/income_tax/bracketized_savings_income/higher_rate_savings_income.py b/policyengine_uk/variables/gov/hmrc/income_tax/bracketized_savings_income/higher_rate_savings_income.py
index ae87d2baf..45fdaab49 100644
--- a/policyengine_uk/variables/gov/hmrc/income_tax/bracketized_savings_income/higher_rate_savings_income.py
+++ b/policyengine_uk/variables/gov/hmrc/income_tax/bracketized_savings_income/higher_rate_savings_income.py
@@ -18,7 +18,11 @@ def formula(person, period, parameters):
savings_deductions = add(
person,
period,
- ["savings_allowance", "savings_starter_rate_income"],
+ [
+ "received_allowances_savings_income",
+ "savings_allowance",
+ "savings_starter_rate_income",
+ ],
)
savings_income_less_deductions = max_(
0,
diff --git a/policyengine_uk/variables/gov/hmrc/income_tax/bracketized_savings_income/savings_starter_rate_income.py b/policyengine_uk/variables/gov/hmrc/income_tax/bracketized_savings_income/savings_starter_rate_income.py
index 4c3371175..ddc197dcf 100644
--- a/policyengine_uk/variables/gov/hmrc/income_tax/bracketized_savings_income/savings_starter_rate_income.py
+++ b/policyengine_uk/variables/gov/hmrc/income_tax/bracketized_savings_income/savings_starter_rate_income.py
@@ -6,15 +6,40 @@ class savings_starter_rate_income(Variable):
entity = Person
label = "Savings income which is tax-free under the starter rate"
definition_period = YEAR
- reference = dict(
- title="Income Tax Act 2007, s. 12",
- href="https://www.legislation.gov.uk/ukpga/2007/3/section/12",
+ reference = list(
+ [
+ dict(
+ title="Income Tax Act 2007, s. 12",
+ href="https://www.legislation.gov.uk/ukpga/2007/3/section/12",
+ ),
+ dict(
+ title="Tax on savings interest",
+ href="https://www.gov.uk/apply-tax-free-interest-on-savings",
+ ),
+ ]
)
unit = GBP
def formula(person, period, parameters):
- income = person("basic_rate_savings_income_pre_starter", period)
- limit = parameters(
- period
- ).gov.hmrc.income_tax.rates.savings_starter_rate.allowance
- return max_(0, limit - income)
+ p = parameters(period).gov.hmrc.income_tax
+ limit = p.rates.savings_starter_rate.allowance
+ phase_out_rate = p.rates.savings_starter_rate.phase_out
+
+ max_personal_allowance = p.allowances.personal_allowance.amount
+
+ starter_rate_taper_start = max_personal_allowance + limit
+
+ savings_income = person(
+ "basic_rate_savings_income_pre_starter", period
+ )
+ earned_taxable_income = person("earned_taxable_income", period)
+ dividend_income = person("taxable_dividend_income", period)
+ non_savings_income = earned_taxable_income + dividend_income
+
+ removed_amount = max_(
+ 0, (non_savings_income - starter_rate_taper_start) * phase_out_rate
+ )
+
+ post_taper_max = max_(0, limit - removed_amount)
+
+ return clip(savings_income, 0, post_taper_max)
diff --git a/policyengine_uk/variables/gov/hmrc/income_tax/earned_income_tax.py b/policyengine_uk/variables/gov/hmrc/income_tax/earned_income_tax.py
index 919150516..99a8cc4fb 100644
--- a/policyengine_uk/variables/gov/hmrc/income_tax/earned_income_tax.py
+++ b/policyengine_uk/variables/gov/hmrc/income_tax/earned_income_tax.py
@@ -14,4 +14,12 @@ class earned_income_tax(Variable):
def formula(person, period, parameters):
rates = parameters(period).gov.hmrc.income_tax.rates
- return rates.uk.calc(person("earned_taxable_income", period))
+ # return rates.uk.calc(person("earned_taxable_income", period))
+
+ return where(
+ person("pays_scottish_income_tax", period),
+ rates.scotland.post_starter_rate.calc(
+ person("earned_taxable_income", period)
+ ),
+ rates.uk.calc(person("earned_taxable_income", period)),
+ )
diff --git a/policyengine_uk/variables/gov/hmrc/income_tax/income_tax.py b/policyengine_uk/variables/gov/hmrc/income_tax/income_tax.py
index 3bfe184a2..8a1596bc9 100644
--- a/policyengine_uk/variables/gov/hmrc/income_tax/income_tax.py
+++ b/policyengine_uk/variables/gov/hmrc/income_tax/income_tax.py
@@ -13,12 +13,11 @@ class income_tax(Variable):
href="https://www.legislation.gov.uk/ukpga/2007/3/section/23",
)
category = TAX
- adds = [
- "earned_income_tax",
- "savings_income_tax",
- "dividend_income_tax",
- "CB_HITC",
- ]
- subtracts = [
- "capped_mcad",
- ]
+
+ def formula(person, period, parameters):
+ p = parameters(period).gov.hmrc.income_tax
+
+ additions = add(person, period, p.income_tax_additions)
+ subtractions = add(person, period, p.income_tax_subtractions)
+
+ return max_(0, additions - subtractions)
diff --git a/policyengine_uk/variables/gov/hmrc/pensions/pension_contributions_relief.py b/policyengine_uk/variables/gov/hmrc/pensions/pension_contributions_relief.py
index 564f8d84a..52bf0e3f7 100644
--- a/policyengine_uk/variables/gov/hmrc/pensions/pension_contributions_relief.py
+++ b/policyengine_uk/variables/gov/hmrc/pensions/pension_contributions_relief.py
@@ -13,7 +13,7 @@ class pension_contributions_relief(Variable):
unit = GBP
def formula(person, period, parameters):
- contributions = person("pension_contributions", period)
+ contributions = person("private_pension_contributions", period)
pension_allowance = person("pension_annual_allowance", period)
age_limit = parameters(
period
diff --git a/policyengine_uk/variables/gov/hmrc/pensions/private_pension_contributions_tax.py b/policyengine_uk/variables/gov/hmrc/pensions/private_pension_contributions_tax.py
new file mode 100644
index 000000000..0007164c8
--- /dev/null
+++ b/policyengine_uk/variables/gov/hmrc/pensions/private_pension_contributions_tax.py
@@ -0,0 +1,28 @@
+from policyengine_uk.model_api import *
+
+
+class private_pension_contributions_tax(Variable):
+ value_type = float
+ entity = Person
+ label = "Reduction in taxable income from pension contributions to pensions other than the State Pension"
+ definition_period = YEAR
+ reference = dict(
+ title="Finance Act 2004 s. 227",
+ href="https://www.legislation.gov.uk/ukpga/2004/12/section/227",
+ )
+ unit = GBP
+
+ def formula(person, period, parameters):
+ p = parameters(period).gov.hmrc.income_tax.rates.uk
+ taxed_income = person("taxed_income", period)
+
+ private_pension_contributions = person(
+ "private_pension_contributions", period
+ )
+ pension_annual_allowance = person("pension_annual_allowance", period)
+ taxable_contributions = (
+ private_pension_contributions - pension_annual_allowance
+ )
+
+ tax_rate = p.marginal_rates(taxed_income)
+ return max_(0, taxable_contributions * tax_rate)
diff --git a/policyengine_uk/variables/input/income.py b/policyengine_uk/variables/input/income.py
index 01f915ecb..31d2891b0 100644
--- a/policyengine_uk/variables/input/income.py
+++ b/policyengine_uk/variables/input/income.py
@@ -185,3 +185,12 @@ class maintenance_income(Variable):
documentation = "Income from maintenance payments to you"
definition_period = YEAR
unit = GBP
+
+
+class other_investment_income(Variable):
+ value_type = float
+ entity = Person
+ label = "other investment income"
+ documentation = "Investment income from sources other than dividends, property, and net interest on UK bank accounts; may include National Savings interest products, securities interest, interest from trusts or settlements, etc."
+ definition_period = YEAR
+ unit = GBP
diff --git a/test9.ipynb b/test9.ipynb
new file mode 100644
index 000000000..0fb8ebca6
--- /dev/null
+++ b/test9.ipynb
@@ -0,0 +1,3195 @@
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from policyengine_uk.data import SPI_2020_21\n",
+ "\n",
+ "SPI_2020_21().generate()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from policyengine_uk import Microsimulation\n",
+ "\n",
+ "sim = Microsimulation(dataset=SPI_2020_21)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "195.3940847496191"
+ ]
+ },
+ "execution_count": 3,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "sim.calculate(\"income_tax\").sum()/1e9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import pandas as pd\n",
+ "\n",
+ "df = pd.read_csv(SPI_2020_21.spi_data_file_path, delimiter=\"\\t\")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "variables_to_add = [\n",
+ " \"income_tax\",\n",
+ " \"adjusted_net_income\",\n",
+ " \"other_tax_credits\",\n",
+ " \"received_allowances\",\n",
+ " \"personal_allowance\",\n",
+ " \"taxed_income\",\n",
+ " \"taxed_dividend_income\",\n",
+ " \"taxed_savings_income\",\n",
+ " \"earned_taxable_income\",\n",
+ " \"taxable_pension_income\",\n",
+ " \"savings_allowance\",\n",
+ " \"received_allowances_savings_income\",\n",
+ " \"savings_starter_rate_income\",\n",
+ " \"basic_rate_savings_income_pre_starter\",\n",
+ " \"taxable_savings_interest_income\",\n",
+ " \"savings_allowance\",\n",
+ " \"earned_taxable_income\",\n",
+ " \"taxable_employment_income\",\n",
+ " \"employment_deductions\",\n",
+ " \"employment_benefits\",\n",
+ " \"basic_rate_savings_income\",\n",
+ " \"higher_rate_savings_income\",\n",
+ " \"add_rate_savings_income\",\n",
+ " \"pays_scottish_income_tax\"\n",
+ "]\n",
+ "\n",
+ "for variable in variables_to_add:\n",
+ " df[f\"zzz_policyengine_{variable}\"] = sim.calculate(variable)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "df[\"error\"] = df.zzz_policyengine_income_tax - df.TOTTAX_DEVO_TXP\n",
+ "df[\"abs_error\"] = df.error.abs()\n",
+ "\n",
+ "# Add the EMPINC column\n",
+ "df['EMPINC'] = df.apply(lambda row: max(0, row['PAY'] + row['EPB'] - row['EXPS']) + \n",
+ " row['INCPBEN'] + row['OSSBEN'] + row['TAXTERM'] + \n",
+ " row['UBISJA'] + row['MOTHINC'], axis=1)\n",
+ "\n",
+ "import numpy as np\n",
+ "\n",
+ "# pandas show all rows\n",
+ "pd.set_option('display.max_rows', None)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "
\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " 575248 | \n",
+ " 589754 | \n",
+ " 709563 | \n",
+ " 709428 | \n",
+ " 304375 | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " abs_error | \n",
+ " 100.0 | \n",
+ " 100.0 | \n",
+ " 100.0 | \n",
+ " 100.0 | \n",
+ " 100.0 | \n",
+ "
\n",
+ " \n",
+ " AGERANGE | \n",
+ " 5 | \n",
+ " 6 | \n",
+ " 6 | \n",
+ " 5 | \n",
+ " 7 | \n",
+ "
\n",
+ " \n",
+ " BPADUE | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " CAPALL | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " COVNTS | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " DEFICIEN | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " DIVIDENDS | \n",
+ " 47200 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 2000 | \n",
+ " 160 | \n",
+ "
\n",
+ " \n",
+ " DSHIPS | \n",
+ " 1 | \n",
+ " 3 | \n",
+ " 3 | \n",
+ " 3 | \n",
+ " 3 | \n",
+ "
\n",
+ " \n",
+ " EIDF | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " EMPINC | \n",
+ " 17000 | \n",
+ " 17700 | \n",
+ " 0 | \n",
+ " 9200 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " EPB | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 6200 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " error | \n",
+ " -100.0 | \n",
+ " -100.0 | \n",
+ " -100.0 | \n",
+ " -100.0 | \n",
+ " -100.0 | \n",
+ "
\n",
+ " \n",
+ " EXPS | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " FACT | \n",
+ " 10.474315 | \n",
+ " 28.014512 | \n",
+ " 25.833991 | \n",
+ " 25.594814 | \n",
+ " 63.1219 | \n",
+ "
\n",
+ " \n",
+ " GIFTAID | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 150 | \n",
+ "
\n",
+ " \n",
+ " GIFTINV | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " GORCODE | \n",
+ " 6 | \n",
+ " 1 | \n",
+ " 3 | \n",
+ " 8 | \n",
+ " 9 | \n",
+ "
\n",
+ " \n",
+ " IIDF | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 150 | \n",
+ "
\n",
+ " \n",
+ " INCBBS | \n",
+ " 13400 | \n",
+ " 9710 | \n",
+ " 50 | \n",
+ " 29200 | \n",
+ " 4300 | \n",
+ "
\n",
+ " \n",
+ " INCPBEN | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " INCPROP | \n",
+ " 9600 | \n",
+ " 0 | \n",
+ " 500 | \n",
+ " 13000 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " INDUSTRY07 | \n",
+ " | \n",
+ " 1600 | \n",
+ " 1600 | \n",
+ " L | \n",
+ " 1600 | \n",
+ "
\n",
+ " \n",
+ " LLIR_RESTRICT_AMT_TOT | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 6770 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " LOSSBF | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " MAIND | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " MAINSRCE | \n",
+ " 1 | \n",
+ " 1 | \n",
+ " 2 | \n",
+ " 1 | \n",
+ " 2 | \n",
+ "
\n",
+ " \n",
+ " MAR | \n",
+ " NSHR | \n",
+ " NSHR | \n",
+ " NSHR | \n",
+ " NSHR | \n",
+ " NSHR | \n",
+ "
\n",
+ " \n",
+ " MCAS | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " MOTHDED | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " MOTHINC | \n",
+ " 17000 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " OSSBEN | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " OTHERINC | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " OTHERINV | \n",
+ " 11400 | \n",
+ " 0 | \n",
+ " 14900 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " PAS | \n",
+ " 12500 | \n",
+ " 12500 | \n",
+ " 12500 | \n",
+ " 12500 | \n",
+ " 12500 | \n",
+ "
\n",
+ " \n",
+ " PAY | \n",
+ " 0 | \n",
+ " 17700 | \n",
+ " 0 | \n",
+ " 3000 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " PENSION | \n",
+ " 0 | \n",
+ " 21500 | \n",
+ " 7690 | \n",
+ " 0 | \n",
+ " 36400 | \n",
+ "
\n",
+ " \n",
+ " PENSRLF | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " PROFITS | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 28300 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " PSAV_XS | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " SCOT_TXP | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " SEINC_NUM | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 1 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " SEISS | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " SEX | \n",
+ " 2 | \n",
+ " 1 | \n",
+ " 1 | \n",
+ " 2 | \n",
+ " 2 | \n",
+ "
\n",
+ " \n",
+ " SPA | \n",
+ " 0 | \n",
+ " 1 | \n",
+ " 1 | \n",
+ " 0 | \n",
+ " 1 | \n",
+ "
\n",
+ " \n",
+ " SREF | \n",
+ " 15663820 | \n",
+ " 15680336 | \n",
+ " 15816666 | \n",
+ " 15816519 | \n",
+ " 15368458 | \n",
+ "
\n",
+ " \n",
+ " SRP | \n",
+ " 0 | \n",
+ " 8690 | \n",
+ " 8410 | \n",
+ " 0 | \n",
+ " 10400 | \n",
+ "
\n",
+ " \n",
+ " TAX_CRED | \n",
+ " 605 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 1355 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " TAX_ST_AR_DEVO_TXP | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " TAX_ST_AR_DEVO_WRIT | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " TAX_ST_BR_DEVO_TXP | \n",
+ " 2745 | \n",
+ " 7080 | \n",
+ " 6480 | \n",
+ " 1610 | \n",
+ " 6830 | \n",
+ "
\n",
+ " \n",
+ " TAX_ST_BR_DEVO_WRIT | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " TAX_ST_HR_DEVO_TXP | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " TAX_ST_HR_DEVO_WRIT | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " TAX_ST_IR_DEVO_TXP | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " TAX_ST_SR_DEVO_TXP | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " TAXINC | \n",
+ " 86100 | \n",
+ " 45100 | \n",
+ " 47350 | \n",
+ " 40900 | \n",
+ " 38610 | \n",
+ "
\n",
+ " \n",
+ " TAXPAYER | \n",
+ " 1 | \n",
+ " 1 | \n",
+ " 1 | \n",
+ " 1 | \n",
+ " 1 | \n",
+ "
\n",
+ " \n",
+ " TAXTERM | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " TEI | \n",
+ " 17000 | \n",
+ " 47890 | \n",
+ " 44400 | \n",
+ " 9200 | \n",
+ " 46800 | \n",
+ "
\n",
+ " \n",
+ " TI | \n",
+ " 98600 | \n",
+ " 57600 | \n",
+ " 59850 | \n",
+ " 53400 | \n",
+ " 51260 | \n",
+ "
\n",
+ " \n",
+ " TII | \n",
+ " 81600 | \n",
+ " 9710 | \n",
+ " 15450 | \n",
+ " 44200 | \n",
+ " 4460 | \n",
+ "
\n",
+ " \n",
+ " TOTTAX_DEVO_TXP | \n",
+ " 22045 | \n",
+ " 10440 | \n",
+ " 11340 | \n",
+ " 6605 | \n",
+ " 7780 | \n",
+ "
\n",
+ " \n",
+ " UBISJA | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " WELSH_TXP | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_add_rate_savings_income | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_adjusted_net_income | \n",
+ " 98600.0 | \n",
+ " 57600.0 | \n",
+ " 59850.0 | \n",
+ " 53400.0 | \n",
+ " 51260.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_basic_rate_savings_income | \n",
+ " 23400.0 | \n",
+ " 2110.0 | \n",
+ " 5100.0 | \n",
+ " 27800.0 | \n",
+ " 3350.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_basic_rate_savings_income_pre_starter | \n",
+ " 23400.0 | \n",
+ " 2110.0 | \n",
+ " 5100.0 | \n",
+ " 27800.0 | \n",
+ " 3350.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_earned_taxable_income | \n",
+ " 14100.0 | \n",
+ " 35390.0 | \n",
+ " 32400.0 | \n",
+ " 9700.0 | \n",
+ " 34150.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_employment_benefits | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_employment_deductions | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_higher_rate_savings_income | \n",
+ " 900.0 | \n",
+ " 7100.0 | \n",
+ " 9350.0 | \n",
+ " 900.0 | \n",
+ " 450.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_income_tax | \n",
+ " 21945.0 | \n",
+ " 10340.0 | \n",
+ " 11240.0 | \n",
+ " 6505.0 | \n",
+ " 7680.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_other_tax_credits | \n",
+ " 605.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 1355.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_pays_scottish_income_tax | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_personal_allowance | \n",
+ " 12500.0 | \n",
+ " 12500.0 | \n",
+ " 12500.0 | \n",
+ " 12500.0 | \n",
+ " 12500.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_received_allowances | \n",
+ " 12500.0 | \n",
+ " 12500.0 | \n",
+ " 12500.0 | \n",
+ " 12500.0 | \n",
+ " 12650.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_received_allowances_savings_income | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_savings_allowance | \n",
+ " 500.0 | \n",
+ " 500.0 | \n",
+ " 500.0 | \n",
+ " 500.0 | \n",
+ " 500.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_savings_starter_rate_income | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_taxable_employment_income | \n",
+ " 0.0 | \n",
+ " 17700.0 | \n",
+ " 0.0 | \n",
+ " 9200.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_taxable_pension_income | \n",
+ " 0.0 | \n",
+ " 21500.0 | \n",
+ " 7690.0 | \n",
+ " 0.0 | \n",
+ " 36400.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_taxable_savings_interest_income | \n",
+ " 24800.0 | \n",
+ " 9710.0 | \n",
+ " 14950.0 | \n",
+ " 29200.0 | \n",
+ " 4300.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_taxed_dividend_income | \n",
+ " 45200.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_taxed_income | \n",
+ " 83600.0 | \n",
+ " 44600.0 | \n",
+ " 46850.0 | \n",
+ " 38400.0 | \n",
+ " 37950.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_taxed_savings_income | \n",
+ " 24300.0 | \n",
+ " 9210.0 | \n",
+ " 14450.0 | \n",
+ " 28700.0 | \n",
+ " 3800.0 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " 575248 589754 \\\n",
+ "abs_error 100.0 100.0 \n",
+ "AGERANGE 5 6 \n",
+ "BPADUE 0 0 \n",
+ "CAPALL 0 0 \n",
+ "COVNTS 0 0 \n",
+ "DEFICIEN 0 0 \n",
+ "DIVIDENDS 47200 0 \n",
+ "DSHIPS 1 3 \n",
+ "EIDF 0 0 \n",
+ "EMPINC 17000 17700 \n",
+ "EPB 0 0 \n",
+ "error -100.0 -100.0 \n",
+ "EXPS 0 0 \n",
+ "FACT 10.474315 28.014512 \n",
+ "GIFTAID 0 0 \n",
+ "GIFTINV 0 0 \n",
+ "GORCODE 6 1 \n",
+ "IIDF 0 0 \n",
+ "INCBBS 13400 9710 \n",
+ "INCPBEN 0 0 \n",
+ "INCPROP 9600 0 \n",
+ "INDUSTRY07 1600 \n",
+ "LLIR_RESTRICT_AMT_TOT 0 0 \n",
+ "LOSSBF 0 0 \n",
+ "MAIND 0 0 \n",
+ "MAINSRCE 1 1 \n",
+ "MAR NSHR NSHR \n",
+ "MCAS 0 0 \n",
+ "MOTHDED 0 0 \n",
+ "MOTHINC 17000 0 \n",
+ "OSSBEN 0 0 \n",
+ "OTHERINC 0 0 \n",
+ "OTHERINV 11400 0 \n",
+ "PAS 12500 12500 \n",
+ "PAY 0 17700 \n",
+ "PENSION 0 21500 \n",
+ "PENSRLF 0 0 \n",
+ "PROFITS 0 0 \n",
+ "PSAV_XS 0 0 \n",
+ "SCOT_TXP 0 0 \n",
+ "SEINC_NUM 0 0 \n",
+ "SEISS 0 0 \n",
+ "SEX 2 1 \n",
+ "SPA 0 1 \n",
+ "SREF 15663820 15680336 \n",
+ "SRP 0 8690 \n",
+ "TAX_CRED 605 0 \n",
+ "TAX_ST_AR_DEVO_TXP 0 0 \n",
+ "TAX_ST_AR_DEVO_WRIT 0 0 \n",
+ "TAX_ST_BR_DEVO_TXP 2745 7080 \n",
+ "TAX_ST_BR_DEVO_WRIT 0 0 \n",
+ "TAX_ST_HR_DEVO_TXP 0 0 \n",
+ "TAX_ST_HR_DEVO_WRIT 0 0 \n",
+ "TAX_ST_IR_DEVO_TXP 0 0 \n",
+ "TAX_ST_SR_DEVO_TXP 0 0 \n",
+ "TAXINC 86100 45100 \n",
+ "TAXPAYER 1 1 \n",
+ "TAXTERM 0 0 \n",
+ "TEI 17000 47890 \n",
+ "TI 98600 57600 \n",
+ "TII 81600 9710 \n",
+ "TOTTAX_DEVO_TXP 22045 10440 \n",
+ "UBISJA 0 0 \n",
+ "WELSH_TXP 0 0 \n",
+ "zzz_policyengine_add_rate_savings_income 0.0 0.0 \n",
+ "zzz_policyengine_adjusted_net_income 98600.0 57600.0 \n",
+ "zzz_policyengine_basic_rate_savings_income 23400.0 2110.0 \n",
+ "zzz_policyengine_basic_rate_savings_income_pre_... 23400.0 2110.0 \n",
+ "zzz_policyengine_earned_taxable_income 14100.0 35390.0 \n",
+ "zzz_policyengine_employment_benefits 0.0 0.0 \n",
+ "zzz_policyengine_employment_deductions 0.0 0.0 \n",
+ "zzz_policyengine_higher_rate_savings_income 900.0 7100.0 \n",
+ "zzz_policyengine_income_tax 21945.0 10340.0 \n",
+ "zzz_policyengine_other_tax_credits 605.0 0.0 \n",
+ "zzz_policyengine_pays_scottish_income_tax False False \n",
+ "zzz_policyengine_personal_allowance 12500.0 12500.0 \n",
+ "zzz_policyengine_received_allowances 12500.0 12500.0 \n",
+ "zzz_policyengine_received_allowances_savings_in... 0.0 0.0 \n",
+ "zzz_policyengine_savings_allowance 500.0 500.0 \n",
+ "zzz_policyengine_savings_starter_rate_income 0.0 0.0 \n",
+ "zzz_policyengine_taxable_employment_income 0.0 17700.0 \n",
+ "zzz_policyengine_taxable_pension_income 0.0 21500.0 \n",
+ "zzz_policyengine_taxable_savings_interest_income 24800.0 9710.0 \n",
+ "zzz_policyengine_taxed_dividend_income 45200.0 0.0 \n",
+ "zzz_policyengine_taxed_income 83600.0 44600.0 \n",
+ "zzz_policyengine_taxed_savings_income 24300.0 9210.0 \n",
+ "\n",
+ " 709563 709428 \\\n",
+ "abs_error 100.0 100.0 \n",
+ "AGERANGE 6 5 \n",
+ "BPADUE 0 0 \n",
+ "CAPALL 0 0 \n",
+ "COVNTS 0 0 \n",
+ "DEFICIEN 0 0 \n",
+ "DIVIDENDS 0 2000 \n",
+ "DSHIPS 3 3 \n",
+ "EIDF 0 0 \n",
+ "EMPINC 0 9200 \n",
+ "EPB 0 6200 \n",
+ "error -100.0 -100.0 \n",
+ "EXPS 0 0 \n",
+ "FACT 25.833991 25.594814 \n",
+ "GIFTAID 0 0 \n",
+ "GIFTINV 0 0 \n",
+ "GORCODE 3 8 \n",
+ "IIDF 0 0 \n",
+ "INCBBS 50 29200 \n",
+ "INCPBEN 0 0 \n",
+ "INCPROP 500 13000 \n",
+ "INDUSTRY07 1600 L \n",
+ "LLIR_RESTRICT_AMT_TOT 0 6770 \n",
+ "LOSSBF 0 0 \n",
+ "MAIND 0 0 \n",
+ "MAINSRCE 2 1 \n",
+ "MAR NSHR NSHR \n",
+ "MCAS 0 0 \n",
+ "MOTHDED 0 0 \n",
+ "MOTHINC 0 0 \n",
+ "OSSBEN 0 0 \n",
+ "OTHERINC 0 0 \n",
+ "OTHERINV 14900 0 \n",
+ "PAS 12500 12500 \n",
+ "PAY 0 3000 \n",
+ "PENSION 7690 0 \n",
+ "PENSRLF 0 0 \n",
+ "PROFITS 28300 0 \n",
+ "PSAV_XS 0 0 \n",
+ "SCOT_TXP 0 0 \n",
+ "SEINC_NUM 1 0 \n",
+ "SEISS 0 0 \n",
+ "SEX 1 2 \n",
+ "SPA 1 0 \n",
+ "SREF 15816666 15816519 \n",
+ "SRP 8410 0 \n",
+ "TAX_CRED 0 1355 \n",
+ "TAX_ST_AR_DEVO_TXP 0 0 \n",
+ "TAX_ST_AR_DEVO_WRIT 0 0 \n",
+ "TAX_ST_BR_DEVO_TXP 6480 1610 \n",
+ "TAX_ST_BR_DEVO_WRIT 0 0 \n",
+ "TAX_ST_HR_DEVO_TXP 0 0 \n",
+ "TAX_ST_HR_DEVO_WRIT 0 0 \n",
+ "TAX_ST_IR_DEVO_TXP 0 0 \n",
+ "TAX_ST_SR_DEVO_TXP 0 0 \n",
+ "TAXINC 47350 40900 \n",
+ "TAXPAYER 1 1 \n",
+ "TAXTERM 0 0 \n",
+ "TEI 44400 9200 \n",
+ "TI 59850 53400 \n",
+ "TII 15450 44200 \n",
+ "TOTTAX_DEVO_TXP 11340 6605 \n",
+ "UBISJA 0 0 \n",
+ "WELSH_TXP 0 0 \n",
+ "zzz_policyengine_add_rate_savings_income 0.0 0.0 \n",
+ "zzz_policyengine_adjusted_net_income 59850.0 53400.0 \n",
+ "zzz_policyengine_basic_rate_savings_income 5100.0 27800.0 \n",
+ "zzz_policyengine_basic_rate_savings_income_pre_... 5100.0 27800.0 \n",
+ "zzz_policyengine_earned_taxable_income 32400.0 9700.0 \n",
+ "zzz_policyengine_employment_benefits 0.0 0.0 \n",
+ "zzz_policyengine_employment_deductions 0.0 0.0 \n",
+ "zzz_policyengine_higher_rate_savings_income 9350.0 900.0 \n",
+ "zzz_policyengine_income_tax 11240.0 6505.0 \n",
+ "zzz_policyengine_other_tax_credits 0.0 1355.0 \n",
+ "zzz_policyengine_pays_scottish_income_tax False False \n",
+ "zzz_policyengine_personal_allowance 12500.0 12500.0 \n",
+ "zzz_policyengine_received_allowances 12500.0 12500.0 \n",
+ "zzz_policyengine_received_allowances_savings_in... 0.0 0.0 \n",
+ "zzz_policyengine_savings_allowance 500.0 500.0 \n",
+ "zzz_policyengine_savings_starter_rate_income 0.0 0.0 \n",
+ "zzz_policyengine_taxable_employment_income 0.0 9200.0 \n",
+ "zzz_policyengine_taxable_pension_income 7690.0 0.0 \n",
+ "zzz_policyengine_taxable_savings_interest_income 14950.0 29200.0 \n",
+ "zzz_policyengine_taxed_dividend_income 0.0 0.0 \n",
+ "zzz_policyengine_taxed_income 46850.0 38400.0 \n",
+ "zzz_policyengine_taxed_savings_income 14450.0 28700.0 \n",
+ "\n",
+ " 304375 \n",
+ "abs_error 100.0 \n",
+ "AGERANGE 7 \n",
+ "BPADUE 0 \n",
+ "CAPALL 0 \n",
+ "COVNTS 0 \n",
+ "DEFICIEN 0 \n",
+ "DIVIDENDS 160 \n",
+ "DSHIPS 3 \n",
+ "EIDF 0 \n",
+ "EMPINC 0 \n",
+ "EPB 0 \n",
+ "error -100.0 \n",
+ "EXPS 0 \n",
+ "FACT 63.1219 \n",
+ "GIFTAID 150 \n",
+ "GIFTINV 0 \n",
+ "GORCODE 9 \n",
+ "IIDF 150 \n",
+ "INCBBS 4300 \n",
+ "INCPBEN 0 \n",
+ "INCPROP 0 \n",
+ "INDUSTRY07 1600 \n",
+ "LLIR_RESTRICT_AMT_TOT 0 \n",
+ "LOSSBF 0 \n",
+ "MAIND 0 \n",
+ "MAINSRCE 2 \n",
+ "MAR NSHR \n",
+ "MCAS 0 \n",
+ "MOTHDED 0 \n",
+ "MOTHINC 0 \n",
+ "OSSBEN 0 \n",
+ "OTHERINC 0 \n",
+ "OTHERINV 0 \n",
+ "PAS 12500 \n",
+ "PAY 0 \n",
+ "PENSION 36400 \n",
+ "PENSRLF 0 \n",
+ "PROFITS 0 \n",
+ "PSAV_XS 0 \n",
+ "SCOT_TXP 0 \n",
+ "SEINC_NUM 0 \n",
+ "SEISS 0 \n",
+ "SEX 2 \n",
+ "SPA 1 \n",
+ "SREF 15368458 \n",
+ "SRP 10400 \n",
+ "TAX_CRED 0 \n",
+ "TAX_ST_AR_DEVO_TXP 0 \n",
+ "TAX_ST_AR_DEVO_WRIT 0 \n",
+ "TAX_ST_BR_DEVO_TXP 6830 \n",
+ "TAX_ST_BR_DEVO_WRIT 0 \n",
+ "TAX_ST_HR_DEVO_TXP 0 \n",
+ "TAX_ST_HR_DEVO_WRIT 0 \n",
+ "TAX_ST_IR_DEVO_TXP 0 \n",
+ "TAX_ST_SR_DEVO_TXP 0 \n",
+ "TAXINC 38610 \n",
+ "TAXPAYER 1 \n",
+ "TAXTERM 0 \n",
+ "TEI 46800 \n",
+ "TI 51260 \n",
+ "TII 4460 \n",
+ "TOTTAX_DEVO_TXP 7780 \n",
+ "UBISJA 0 \n",
+ "WELSH_TXP 0 \n",
+ "zzz_policyengine_add_rate_savings_income 0.0 \n",
+ "zzz_policyengine_adjusted_net_income 51260.0 \n",
+ "zzz_policyengine_basic_rate_savings_income 3350.0 \n",
+ "zzz_policyengine_basic_rate_savings_income_pre_... 3350.0 \n",
+ "zzz_policyengine_earned_taxable_income 34150.0 \n",
+ "zzz_policyengine_employment_benefits 0.0 \n",
+ "zzz_policyengine_employment_deductions 0.0 \n",
+ "zzz_policyengine_higher_rate_savings_income 450.0 \n",
+ "zzz_policyengine_income_tax 7680.0 \n",
+ "zzz_policyengine_other_tax_credits 0.0 \n",
+ "zzz_policyengine_pays_scottish_income_tax False \n",
+ "zzz_policyengine_personal_allowance 12500.0 \n",
+ "zzz_policyengine_received_allowances 12650.0 \n",
+ "zzz_policyengine_received_allowances_savings_in... 0.0 \n",
+ "zzz_policyengine_savings_allowance 500.0 \n",
+ "zzz_policyengine_savings_starter_rate_income 0.0 \n",
+ "zzz_policyengine_taxable_employment_income 0.0 \n",
+ "zzz_policyengine_taxable_pension_income 36400.0 \n",
+ "zzz_policyengine_taxable_savings_interest_income 4300.0 \n",
+ "zzz_policyengine_taxed_dividend_income 0.0 \n",
+ "zzz_policyengine_taxed_income 37950.0 \n",
+ "zzz_policyengine_taxed_savings_income 3800.0 "
+ ]
+ },
+ "execution_count": 7,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "(df[df.abs_error.between(100, np.inf)]\n",
+ " .sort_values(\"abs_error\", ascending=True)\n",
+ " .head()\n",
+ " .T\n",
+ " .sort_index(key=lambda x: x.str.lower()))\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "abs_error\n",
+ "<=10 91.265491\n",
+ "<1000 5.586080\n",
+ ">=1000 1.999022\n",
+ "<100 1.149407\n",
+ "Name: proportion, dtype: float64"
+ ]
+ },
+ "execution_count": 8,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "def error_category(error):\n",
+ " if error <= 10:\n",
+ " return \"<=10\"\n",
+ " elif error < 100:\n",
+ " return \"<100\"\n",
+ " elif error < 1000:\n",
+ " return \"<1000\"\n",
+ " else:\n",
+ " return \">=1000\"\n",
+ "df.abs_error.apply(error_category).value_counts(normalize=True) * 100\n",
+ "\n",
+ "\n",
+ "#495286"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " 79574 | \n",
+ " 201397 | \n",
+ " 200975 | \n",
+ " 520288 | \n",
+ " 524966 | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " abs_error | \n",
+ " 250.0 | \n",
+ " 250.0 | \n",
+ " 250.0 | \n",
+ " 250.0 | \n",
+ " 250.0 | \n",
+ "
\n",
+ " \n",
+ " AGERANGE | \n",
+ " 4 | \n",
+ " 5 | \n",
+ " 5 | \n",
+ " 5 | \n",
+ " 7 | \n",
+ "
\n",
+ " \n",
+ " BPADUE | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " CAPALL | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " COVNTS | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " DEFICIEN | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " DIVIDENDS | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 92600 | \n",
+ " 55 | \n",
+ "
\n",
+ " \n",
+ " DSHIPS | \n",
+ " 3 | \n",
+ " 3 | \n",
+ " 3 | \n",
+ " 3 | \n",
+ " 3 | \n",
+ "
\n",
+ " \n",
+ " EIDF | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " EMPINC | \n",
+ " 12500 | \n",
+ " 3500 | \n",
+ " 0 | \n",
+ " 8780 | \n",
+ " 30 | \n",
+ "
\n",
+ " \n",
+ " EPB | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " error | \n",
+ " -250.0 | \n",
+ " -250.0 | \n",
+ " -250.0 | \n",
+ " -250.0 | \n",
+ " 250.0 | \n",
+ "
\n",
+ " \n",
+ " EXPS | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " FACT | \n",
+ " 57.1795 | \n",
+ " 103.8659 | \n",
+ " 125.4422 | \n",
+ " 10.267938 | \n",
+ " 52.477097 | \n",
+ "
\n",
+ " \n",
+ " GIFTAID | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " GIFTINV | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " GORCODE | \n",
+ " 10 | \n",
+ " 10 | \n",
+ " 2 | \n",
+ " 9 | \n",
+ " 9 | \n",
+ "
\n",
+ " \n",
+ " IIDF | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " INCBBS | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 955 | \n",
+ " 3910 | \n",
+ "
\n",
+ " \n",
+ " INCPBEN | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " INCPROP | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 4290 | \n",
+ "
\n",
+ " \n",
+ " INDUSTRY07 | \n",
+ " F | \n",
+ " 1600 | \n",
+ " 1600 | \n",
+ " Q | \n",
+ " 1600 | \n",
+ "
\n",
+ " \n",
+ " LLIR_RESTRICT_AMT_TOT | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " LOSSBF | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " MAIND | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " MAINSRCE | \n",
+ " 1 | \n",
+ " 2 | \n",
+ " 2 | \n",
+ " 1 | \n",
+ " 2 | \n",
+ "
\n",
+ " \n",
+ " MAR | \n",
+ " STBR | \n",
+ " STBR | \n",
+ " STBR | \n",
+ " DVHR | \n",
+ " NONTP | \n",
+ "
\n",
+ " \n",
+ " MCAS | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " MOTHDED | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " MOTHINC | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 30 | \n",
+ "
\n",
+ " \n",
+ " OSSBEN | \n",
+ " 0 | \n",
+ " 3500 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " OTHERINC | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " OTHERINV | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " PAS | \n",
+ " 11250 | \n",
+ " 11250 | \n",
+ " 11250 | \n",
+ " 11335 | \n",
+ " 12500 | \n",
+ "
\n",
+ " \n",
+ " PAY | \n",
+ " 12500 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 8780 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " PENSION | \n",
+ " 0 | \n",
+ " 9000 | \n",
+ " 12500 | \n",
+ " 0 | \n",
+ " 2330 | \n",
+ "
\n",
+ " \n",
+ " PENSRLF | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " PROFITS | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " PSAV_XS | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " SCOT_TXP | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " SEINC_NUM | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " SEISS | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " SEX | \n",
+ " 1 | \n",
+ " 1 | \n",
+ " 2 | \n",
+ " 2 | \n",
+ " 2 | \n",
+ "
\n",
+ " \n",
+ " SPA | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 1 | \n",
+ "
\n",
+ " \n",
+ " SREF | \n",
+ " 15143186 | \n",
+ " 15265269 | \n",
+ " 15264845 | \n",
+ " 15601122 | \n",
+ " 15606453 | \n",
+ "
\n",
+ " \n",
+ " SRP | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 4190 | \n",
+ "
\n",
+ " \n",
+ " TAX_CRED | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 19800 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " TAX_ST_AR_DEVO_TXP | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " TAX_ST_AR_DEVO_WRIT | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " TAX_ST_BR_DEVO_TXP | \n",
+ " 250 | \n",
+ " 250 | \n",
+ " 250 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " TAX_ST_BR_DEVO_WRIT | \n",
+ " 125 | \n",
+ " 125 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " TAX_ST_HR_DEVO_TXP | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " TAX_ST_HR_DEVO_WRIT | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " TAX_ST_IR_DEVO_TXP | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " TAX_ST_SR_DEVO_TXP | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " TAXINC | \n",
+ " 1250 | \n",
+ " 1250 | \n",
+ " 1250 | \n",
+ " 91000 | \n",
+ " 2305 | \n",
+ "
\n",
+ " \n",
+ " TAXPAYER | \n",
+ " 1 | \n",
+ " 1 | \n",
+ " 1 | \n",
+ " 1 | \n",
+ " 2 | \n",
+ "
\n",
+ " \n",
+ " TAXTERM | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " TEI | \n",
+ " 12500 | \n",
+ " 12500 | \n",
+ " 12500 | \n",
+ " 8780 | \n",
+ " 6550 | \n",
+ "
\n",
+ " \n",
+ " TI | \n",
+ " 12500 | \n",
+ " 12500 | \n",
+ " 12500 | \n",
+ " 102335 | \n",
+ " 14805 | \n",
+ "
\n",
+ " \n",
+ " TII | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 93555 | \n",
+ " 8255 | \n",
+ "
\n",
+ " \n",
+ " TOTTAX_DEVO_TXP | \n",
+ " 250 | \n",
+ " 250 | \n",
+ " 250 | \n",
+ " 250 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " UBISJA | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " WELSH_TXP | \n",
+ " 1 | \n",
+ " 1 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_add_rate_savings_income | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_adjusted_net_income | \n",
+ " 12500.0 | \n",
+ " 12500.0 | \n",
+ " 12500.0 | \n",
+ " 102335.0 | \n",
+ " 14805.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_basic_rate_savings_income | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 1250.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_basic_rate_savings_income_pre_starter | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 455.0 | \n",
+ " 2910.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_earned_taxable_income | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_employment_benefits | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_employment_deductions | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_higher_rate_savings_income | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_income_tax | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 250.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_other_tax_credits | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 19800.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_pays_scottish_income_tax | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_personal_allowance | \n",
+ " 12500.0 | \n",
+ " 12500.0 | \n",
+ " 12500.0 | \n",
+ " 11332.5 | \n",
+ " 12500.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_received_allowances | \n",
+ " 12500.0 | \n",
+ " 12500.0 | \n",
+ " 12500.0 | \n",
+ " 11332.5 | \n",
+ " 12500.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_received_allowances_savings_income | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 955.0 | \n",
+ " 1660.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_savings_allowance | \n",
+ " 1000.0 | \n",
+ " 1000.0 | \n",
+ " 1000.0 | \n",
+ " 500.0 | \n",
+ " 1000.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_savings_starter_rate_income | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_taxable_employment_income | \n",
+ " 12500.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 8780.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_taxable_pension_income | \n",
+ " 0.0 | \n",
+ " 9000.0 | \n",
+ " 12500.0 | \n",
+ " 0.0 | \n",
+ " 2330.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_taxable_savings_interest_income | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 955.0 | \n",
+ " 3910.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_taxed_dividend_income | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 89002.5 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_taxed_income | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 89002.5 | \n",
+ " 1250.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_taxed_savings_income | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 1250.0 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " 79574 201397 \\\n",
+ "abs_error 250.0 250.0 \n",
+ "AGERANGE 4 5 \n",
+ "BPADUE 0 0 \n",
+ "CAPALL 0 0 \n",
+ "COVNTS 0 0 \n",
+ "DEFICIEN 0 0 \n",
+ "DIVIDENDS 0 0 \n",
+ "DSHIPS 3 3 \n",
+ "EIDF 0 0 \n",
+ "EMPINC 12500 3500 \n",
+ "EPB 0 0 \n",
+ "error -250.0 -250.0 \n",
+ "EXPS 0 0 \n",
+ "FACT 57.1795 103.8659 \n",
+ "GIFTAID 0 0 \n",
+ "GIFTINV 0 0 \n",
+ "GORCODE 10 10 \n",
+ "IIDF 0 0 \n",
+ "INCBBS 0 0 \n",
+ "INCPBEN 0 0 \n",
+ "INCPROP 0 0 \n",
+ "INDUSTRY07 F 1600 \n",
+ "LLIR_RESTRICT_AMT_TOT 0 0 \n",
+ "LOSSBF 0 0 \n",
+ "MAIND 0 0 \n",
+ "MAINSRCE 1 2 \n",
+ "MAR STBR STBR \n",
+ "MCAS 0 0 \n",
+ "MOTHDED 0 0 \n",
+ "MOTHINC 0 0 \n",
+ "OSSBEN 0 3500 \n",
+ "OTHERINC 0 0 \n",
+ "OTHERINV 0 0 \n",
+ "PAS 11250 11250 \n",
+ "PAY 12500 0 \n",
+ "PENSION 0 9000 \n",
+ "PENSRLF 0 0 \n",
+ "PROFITS 0 0 \n",
+ "PSAV_XS 0 0 \n",
+ "SCOT_TXP 0 0 \n",
+ "SEINC_NUM 0 0 \n",
+ "SEISS 0 0 \n",
+ "SEX 1 1 \n",
+ "SPA 0 0 \n",
+ "SREF 15143186 15265269 \n",
+ "SRP 0 0 \n",
+ "TAX_CRED 0 0 \n",
+ "TAX_ST_AR_DEVO_TXP 0 0 \n",
+ "TAX_ST_AR_DEVO_WRIT 0 0 \n",
+ "TAX_ST_BR_DEVO_TXP 250 250 \n",
+ "TAX_ST_BR_DEVO_WRIT 125 125 \n",
+ "TAX_ST_HR_DEVO_TXP 0 0 \n",
+ "TAX_ST_HR_DEVO_WRIT 0 0 \n",
+ "TAX_ST_IR_DEVO_TXP 0 0 \n",
+ "TAX_ST_SR_DEVO_TXP 0 0 \n",
+ "TAXINC 1250 1250 \n",
+ "TAXPAYER 1 1 \n",
+ "TAXTERM 0 0 \n",
+ "TEI 12500 12500 \n",
+ "TI 12500 12500 \n",
+ "TII 0 0 \n",
+ "TOTTAX_DEVO_TXP 250 250 \n",
+ "UBISJA 0 0 \n",
+ "WELSH_TXP 1 1 \n",
+ "zzz_policyengine_add_rate_savings_income 0.0 0.0 \n",
+ "zzz_policyengine_adjusted_net_income 12500.0 12500.0 \n",
+ "zzz_policyengine_basic_rate_savings_income 0.0 0.0 \n",
+ "zzz_policyengine_basic_rate_savings_income_pre_... 0.0 0.0 \n",
+ "zzz_policyengine_earned_taxable_income 0.0 0.0 \n",
+ "zzz_policyengine_employment_benefits 0.0 0.0 \n",
+ "zzz_policyengine_employment_deductions 0.0 0.0 \n",
+ "zzz_policyengine_higher_rate_savings_income 0.0 0.0 \n",
+ "zzz_policyengine_income_tax 0.0 0.0 \n",
+ "zzz_policyengine_other_tax_credits 0.0 0.0 \n",
+ "zzz_policyengine_pays_scottish_income_tax False False \n",
+ "zzz_policyengine_personal_allowance 12500.0 12500.0 \n",
+ "zzz_policyengine_received_allowances 12500.0 12500.0 \n",
+ "zzz_policyengine_received_allowances_savings_in... 0.0 0.0 \n",
+ "zzz_policyengine_savings_allowance 1000.0 1000.0 \n",
+ "zzz_policyengine_savings_starter_rate_income 0.0 0.0 \n",
+ "zzz_policyengine_taxable_employment_income 12500.0 0.0 \n",
+ "zzz_policyengine_taxable_pension_income 0.0 9000.0 \n",
+ "zzz_policyengine_taxable_savings_interest_income 0.0 0.0 \n",
+ "zzz_policyengine_taxed_dividend_income 0.0 0.0 \n",
+ "zzz_policyengine_taxed_income 0.0 0.0 \n",
+ "zzz_policyengine_taxed_savings_income 0.0 0.0 \n",
+ "\n",
+ " 200975 520288 \\\n",
+ "abs_error 250.0 250.0 \n",
+ "AGERANGE 5 5 \n",
+ "BPADUE 0 0 \n",
+ "CAPALL 0 0 \n",
+ "COVNTS 0 0 \n",
+ "DEFICIEN 0 0 \n",
+ "DIVIDENDS 0 92600 \n",
+ "DSHIPS 3 3 \n",
+ "EIDF 0 0 \n",
+ "EMPINC 0 8780 \n",
+ "EPB 0 0 \n",
+ "error -250.0 -250.0 \n",
+ "EXPS 0 0 \n",
+ "FACT 125.4422 10.267938 \n",
+ "GIFTAID 0 0 \n",
+ "GIFTINV 0 0 \n",
+ "GORCODE 2 9 \n",
+ "IIDF 0 0 \n",
+ "INCBBS 0 955 \n",
+ "INCPBEN 0 0 \n",
+ "INCPROP 0 0 \n",
+ "INDUSTRY07 1600 Q \n",
+ "LLIR_RESTRICT_AMT_TOT 0 0 \n",
+ "LOSSBF 0 0 \n",
+ "MAIND 0 0 \n",
+ "MAINSRCE 2 1 \n",
+ "MAR STBR DVHR \n",
+ "MCAS 0 0 \n",
+ "MOTHDED 0 0 \n",
+ "MOTHINC 0 0 \n",
+ "OSSBEN 0 0 \n",
+ "OTHERINC 0 0 \n",
+ "OTHERINV 0 0 \n",
+ "PAS 11250 11335 \n",
+ "PAY 0 8780 \n",
+ "PENSION 12500 0 \n",
+ "PENSRLF 0 0 \n",
+ "PROFITS 0 0 \n",
+ "PSAV_XS 0 0 \n",
+ "SCOT_TXP 0 0 \n",
+ "SEINC_NUM 0 0 \n",
+ "SEISS 0 0 \n",
+ "SEX 2 2 \n",
+ "SPA 0 0 \n",
+ "SREF 15264845 15601122 \n",
+ "SRP 0 0 \n",
+ "TAX_CRED 0 19800 \n",
+ "TAX_ST_AR_DEVO_TXP 0 0 \n",
+ "TAX_ST_AR_DEVO_WRIT 0 0 \n",
+ "TAX_ST_BR_DEVO_TXP 250 0 \n",
+ "TAX_ST_BR_DEVO_WRIT 0 0 \n",
+ "TAX_ST_HR_DEVO_TXP 0 0 \n",
+ "TAX_ST_HR_DEVO_WRIT 0 0 \n",
+ "TAX_ST_IR_DEVO_TXP 0 0 \n",
+ "TAX_ST_SR_DEVO_TXP 0 0 \n",
+ "TAXINC 1250 91000 \n",
+ "TAXPAYER 1 1 \n",
+ "TAXTERM 0 0 \n",
+ "TEI 12500 8780 \n",
+ "TI 12500 102335 \n",
+ "TII 0 93555 \n",
+ "TOTTAX_DEVO_TXP 250 250 \n",
+ "UBISJA 0 0 \n",
+ "WELSH_TXP 0 0 \n",
+ "zzz_policyengine_add_rate_savings_income 0.0 0.0 \n",
+ "zzz_policyengine_adjusted_net_income 12500.0 102335.0 \n",
+ "zzz_policyengine_basic_rate_savings_income 0.0 0.0 \n",
+ "zzz_policyengine_basic_rate_savings_income_pre_... 0.0 455.0 \n",
+ "zzz_policyengine_earned_taxable_income 0.0 0.0 \n",
+ "zzz_policyengine_employment_benefits 0.0 0.0 \n",
+ "zzz_policyengine_employment_deductions 0.0 0.0 \n",
+ "zzz_policyengine_higher_rate_savings_income 0.0 0.0 \n",
+ "zzz_policyengine_income_tax 0.0 0.0 \n",
+ "zzz_policyengine_other_tax_credits 0.0 19800.0 \n",
+ "zzz_policyengine_pays_scottish_income_tax False False \n",
+ "zzz_policyengine_personal_allowance 12500.0 11332.5 \n",
+ "zzz_policyengine_received_allowances 12500.0 11332.5 \n",
+ "zzz_policyengine_received_allowances_savings_in... 0.0 955.0 \n",
+ "zzz_policyengine_savings_allowance 1000.0 500.0 \n",
+ "zzz_policyengine_savings_starter_rate_income 0.0 0.0 \n",
+ "zzz_policyengine_taxable_employment_income 0.0 8780.0 \n",
+ "zzz_policyengine_taxable_pension_income 12500.0 0.0 \n",
+ "zzz_policyengine_taxable_savings_interest_income 0.0 955.0 \n",
+ "zzz_policyengine_taxed_dividend_income 0.0 89002.5 \n",
+ "zzz_policyengine_taxed_income 0.0 89002.5 \n",
+ "zzz_policyengine_taxed_savings_income 0.0 0.0 \n",
+ "\n",
+ " 524966 \n",
+ "abs_error 250.0 \n",
+ "AGERANGE 7 \n",
+ "BPADUE 0 \n",
+ "CAPALL 0 \n",
+ "COVNTS 0 \n",
+ "DEFICIEN 0 \n",
+ "DIVIDENDS 55 \n",
+ "DSHIPS 3 \n",
+ "EIDF 0 \n",
+ "EMPINC 30 \n",
+ "EPB 0 \n",
+ "error 250.0 \n",
+ "EXPS 0 \n",
+ "FACT 52.477097 \n",
+ "GIFTAID 0 \n",
+ "GIFTINV 0 \n",
+ "GORCODE 9 \n",
+ "IIDF 0 \n",
+ "INCBBS 3910 \n",
+ "INCPBEN 0 \n",
+ "INCPROP 4290 \n",
+ "INDUSTRY07 1600 \n",
+ "LLIR_RESTRICT_AMT_TOT 0 \n",
+ "LOSSBF 0 \n",
+ "MAIND 0 \n",
+ "MAINSRCE 2 \n",
+ "MAR NONTP \n",
+ "MCAS 0 \n",
+ "MOTHDED 0 \n",
+ "MOTHINC 30 \n",
+ "OSSBEN 0 \n",
+ "OTHERINC 0 \n",
+ "OTHERINV 0 \n",
+ "PAS 12500 \n",
+ "PAY 0 \n",
+ "PENSION 2330 \n",
+ "PENSRLF 0 \n",
+ "PROFITS 0 \n",
+ "PSAV_XS 0 \n",
+ "SCOT_TXP 0 \n",
+ "SEINC_NUM 0 \n",
+ "SEISS 0 \n",
+ "SEX 2 \n",
+ "SPA 1 \n",
+ "SREF 15606453 \n",
+ "SRP 4190 \n",
+ "TAX_CRED 0 \n",
+ "TAX_ST_AR_DEVO_TXP 0 \n",
+ "TAX_ST_AR_DEVO_WRIT 0 \n",
+ "TAX_ST_BR_DEVO_TXP 0 \n",
+ "TAX_ST_BR_DEVO_WRIT 0 \n",
+ "TAX_ST_HR_DEVO_TXP 0 \n",
+ "TAX_ST_HR_DEVO_WRIT 0 \n",
+ "TAX_ST_IR_DEVO_TXP 0 \n",
+ "TAX_ST_SR_DEVO_TXP 0 \n",
+ "TAXINC 2305 \n",
+ "TAXPAYER 2 \n",
+ "TAXTERM 0 \n",
+ "TEI 6550 \n",
+ "TI 14805 \n",
+ "TII 8255 \n",
+ "TOTTAX_DEVO_TXP 0 \n",
+ "UBISJA 0 \n",
+ "WELSH_TXP 0 \n",
+ "zzz_policyengine_add_rate_savings_income 0.0 \n",
+ "zzz_policyengine_adjusted_net_income 14805.0 \n",
+ "zzz_policyengine_basic_rate_savings_income 1250.0 \n",
+ "zzz_policyengine_basic_rate_savings_income_pre_... 2910.0 \n",
+ "zzz_policyengine_earned_taxable_income 0.0 \n",
+ "zzz_policyengine_employment_benefits 0.0 \n",
+ "zzz_policyengine_employment_deductions 0.0 \n",
+ "zzz_policyengine_higher_rate_savings_income 0.0 \n",
+ "zzz_policyengine_income_tax 250.0 \n",
+ "zzz_policyengine_other_tax_credits 0.0 \n",
+ "zzz_policyengine_pays_scottish_income_tax False \n",
+ "zzz_policyengine_personal_allowance 12500.0 \n",
+ "zzz_policyengine_received_allowances 12500.0 \n",
+ "zzz_policyengine_received_allowances_savings_in... 1660.0 \n",
+ "zzz_policyengine_savings_allowance 1000.0 \n",
+ "zzz_policyengine_savings_starter_rate_income 0.0 \n",
+ "zzz_policyengine_taxable_employment_income 0.0 \n",
+ "zzz_policyengine_taxable_pension_income 2330.0 \n",
+ "zzz_policyengine_taxable_savings_interest_income 3910.0 \n",
+ "zzz_policyengine_taxed_dividend_income 0.0 \n",
+ "zzz_policyengine_taxed_income 1250.0 \n",
+ "zzz_policyengine_taxed_savings_income 1250.0 "
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "result_df = df[(df[\"abs_error\"] == 250)].sort_values(\"zzz_policyengine_earned_taxable_income\", ascending=True).head().T.sort_index(key=lambda x: x.str.lower())\n",
+ "\n",
+ "# Display the result\n",
+ "display(result_df)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " 670183 | \n",
+ " 653918 | \n",
+ " 487185 | \n",
+ " 640988 | \n",
+ " 428507 | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " abs_error | \n",
+ " 1878.0 | \n",
+ " 1615.0 | \n",
+ " 1599.0 | \n",
+ " 1400.0 | \n",
+ " 1380.0 | \n",
+ "
\n",
+ " \n",
+ " AGERANGE | \n",
+ " 5 | \n",
+ " 4 | \n",
+ " 2 | \n",
+ " 4 | \n",
+ " 3 | \n",
+ "
\n",
+ " \n",
+ " BPADUE | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " CAPALL | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " COVNTS | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " DEFICIEN | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " DIVIDENDS | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " DSHIPS | \n",
+ " 3 | \n",
+ " 3 | \n",
+ " 3 | \n",
+ " 3 | \n",
+ " 3 | \n",
+ "
\n",
+ " \n",
+ " EIDF | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " EMPINC | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " EPB | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " error | \n",
+ " 1878.0 | \n",
+ " 1615.0 | \n",
+ " 1599.0 | \n",
+ " 1400.0 | \n",
+ " -1380.0 | \n",
+ "
\n",
+ " \n",
+ " EXPS | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " FACT | \n",
+ " 10.648841 | \n",
+ " 10.423152 | \n",
+ " 10.648841 | \n",
+ " 10.648841 | \n",
+ " 53.399523 | \n",
+ "
\n",
+ " \n",
+ " GIFTAID | \n",
+ " 9380 | \n",
+ " 45000 | \n",
+ " 8190 | \n",
+ " 56900 | \n",
+ " 1500 | \n",
+ "
\n",
+ " \n",
+ " GIFTINV | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " GORCODE | \n",
+ " 9 | \n",
+ " 7 | \n",
+ " 7 | \n",
+ " 2 | \n",
+ " 14 | \n",
+ "
\n",
+ " \n",
+ " IIDF | \n",
+ " 9380 | \n",
+ " 45000 | \n",
+ " 8190 | \n",
+ " 56900 | \n",
+ " 1500 | \n",
+ "
\n",
+ " \n",
+ " INCBBS | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " INCPBEN | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " INCPROP | \n",
+ " 124000 | \n",
+ " 109000 | \n",
+ " 108000 | \n",
+ " 107000 | \n",
+ " 9650 | \n",
+ "
\n",
+ " \n",
+ " INDUSTRY07 | \n",
+ " F | \n",
+ " 1500 | \n",
+ " 1500 | \n",
+ " F | \n",
+ " 1500 | \n",
+ "
\n",
+ " \n",
+ " LLIR_RESTRICT_AMT_TOT | \n",
+ " 42150 | \n",
+ " 66435 | \n",
+ " 46975 | \n",
+ " 22685 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " LOSSBF | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " MAIND | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " MAINSRCE | \n",
+ " 4 | \n",
+ " 5 | \n",
+ " 5 | \n",
+ " 4 | \n",
+ " 5 | \n",
+ "
\n",
+ " \n",
+ " MAR | \n",
+ " STHR | \n",
+ " NONTP | \n",
+ " STHR | \n",
+ " STHR | \n",
+ " STBR | \n",
+ "
\n",
+ " \n",
+ " MCAS | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " MOTHDED | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " MOTHINC | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " OSSBEN | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " OTHERINC | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " OTHERINV | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " PAS | \n",
+ " 5190 | \n",
+ " 12500 | \n",
+ " 12500 | \n",
+ " 12500 | \n",
+ " 1250 | \n",
+ "
\n",
+ " \n",
+ " PAY | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " PENSION | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " PENSRLF | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " PROFITS | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " PSAV_XS | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " SCOT_TXP | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " SEINC_NUM | \n",
+ " 1 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 1 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " SEISS | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " SEX | \n",
+ " 2 | \n",
+ " 1 | \n",
+ " 2 | \n",
+ " 2 | \n",
+ " 2 | \n",
+ "
\n",
+ " \n",
+ " SPA | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " SREF | \n",
+ " 15771837 | \n",
+ " 15753289 | \n",
+ " 15563623 | \n",
+ " 15738484 | \n",
+ " 15496884 | \n",
+ "
\n",
+ " \n",
+ " SRP | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " TAX_CRED | \n",
+ " 8430 | \n",
+ " 13285 | \n",
+ " 19395 | \n",
+ " 4535 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " TAX_ST_AR_DEVO_TXP | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " TAX_ST_AR_DEVO_WRIT | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " TAX_ST_BR_DEVO_TXP | \n",
+ " 5755 | \n",
+ " 0 | \n",
+ " 2195 | \n",
+ " 2985 | \n",
+ " 1380 | \n",
+ "
\n",
+ " \n",
+ " TAX_ST_BR_DEVO_WRIT | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " TAX_ST_HR_DEVO_TXP | \n",
+ " 22085 | \n",
+ " 0 | \n",
+ " 5835 | \n",
+ " 15 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " TAX_ST_HR_DEVO_WRIT | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " TAX_ST_IR_DEVO_TXP | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " TAX_ST_SR_DEVO_TXP | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " TAXINC | \n",
+ " 109430 | \n",
+ " 51500 | \n",
+ " 87310 | \n",
+ " 37600 | \n",
+ " 6900 | \n",
+ "
\n",
+ " \n",
+ " TAXPAYER | \n",
+ " 1 | \n",
+ " 1 | \n",
+ " 1 | \n",
+ " 1 | \n",
+ " 1 | \n",
+ "
\n",
+ " \n",
+ " TAXTERM | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " TEI | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " TI | \n",
+ " 124000 | \n",
+ " 109000 | \n",
+ " 108000 | \n",
+ " 107000 | \n",
+ " 9650 | \n",
+ "
\n",
+ " \n",
+ " TII | \n",
+ " 124000 | \n",
+ " 109000 | \n",
+ " 108000 | \n",
+ " 107000 | \n",
+ " 9650 | \n",
+ "
\n",
+ " \n",
+ " TOTTAX_DEVO_TXP | \n",
+ " 27840 | \n",
+ " 0 | \n",
+ " 8030 | \n",
+ " 3005 | \n",
+ " 1380 | \n",
+ "
\n",
+ " \n",
+ " UBISJA | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " WELSH_TXP | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_add_rate_savings_income | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_adjusted_net_income | \n",
+ " 124000.0 | \n",
+ " 109000.0 | \n",
+ " 108000.0 | \n",
+ " 107000.0 | \n",
+ " 9650.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_basic_rate_savings_income | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_basic_rate_savings_income_pre_starter | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_earned_taxable_income | \n",
+ " 114120.0 | \n",
+ " 56000.0 | \n",
+ " 91310.0 | \n",
+ " 41100.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_employment_benefits | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_employment_deductions | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_higher_rate_savings_income | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_income_tax | \n",
+ " 29718.0 | \n",
+ " 1615.0 | \n",
+ " 9629.0 | \n",
+ " 4405.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_other_tax_credits | \n",
+ " 8430.0 | \n",
+ " 13285.0 | \n",
+ " 19395.0 | \n",
+ " 4535.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_pays_scottish_income_tax | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_personal_allowance | \n",
+ " 500.0 | \n",
+ " 8000.0 | \n",
+ " 8500.0 | \n",
+ " 9000.0 | \n",
+ " 12500.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_received_allowances | \n",
+ " 9880.0 | \n",
+ " 53000.0 | \n",
+ " 16690.0 | \n",
+ " 65900.0 | \n",
+ " 9650.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_received_allowances_savings_income | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_savings_allowance | \n",
+ " 500.0 | \n",
+ " 500.0 | \n",
+ " 500.0 | \n",
+ " 500.0 | \n",
+ " 1000.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_savings_starter_rate_income | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_taxable_employment_income | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_taxable_pension_income | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_taxable_savings_interest_income | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_taxed_dividend_income | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_taxed_income | \n",
+ " 114120.0 | \n",
+ " 56000.0 | \n",
+ " 91310.0 | \n",
+ " 41100.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " zzz_policyengine_taxed_savings_income | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " 670183 653918 \\\n",
+ "abs_error 1878.0 1615.0 \n",
+ "AGERANGE 5 4 \n",
+ "BPADUE 0 0 \n",
+ "CAPALL 0 0 \n",
+ "COVNTS 0 0 \n",
+ "DEFICIEN 0 0 \n",
+ "DIVIDENDS 0 0 \n",
+ "DSHIPS 3 3 \n",
+ "EIDF 0 0 \n",
+ "EMPINC 0 0 \n",
+ "EPB 0 0 \n",
+ "error 1878.0 1615.0 \n",
+ "EXPS 0 0 \n",
+ "FACT 10.648841 10.423152 \n",
+ "GIFTAID 9380 45000 \n",
+ "GIFTINV 0 0 \n",
+ "GORCODE 9 7 \n",
+ "IIDF 9380 45000 \n",
+ "INCBBS 0 0 \n",
+ "INCPBEN 0 0 \n",
+ "INCPROP 124000 109000 \n",
+ "INDUSTRY07 F 1500 \n",
+ "LLIR_RESTRICT_AMT_TOT 42150 66435 \n",
+ "LOSSBF 0 0 \n",
+ "MAIND 0 0 \n",
+ "MAINSRCE 4 5 \n",
+ "MAR STHR NONTP \n",
+ "MCAS 0 0 \n",
+ "MOTHDED 0 0 \n",
+ "MOTHINC 0 0 \n",
+ "OSSBEN 0 0 \n",
+ "OTHERINC 0 0 \n",
+ "OTHERINV 0 0 \n",
+ "PAS 5190 12500 \n",
+ "PAY 0 0 \n",
+ "PENSION 0 0 \n",
+ "PENSRLF 0 0 \n",
+ "PROFITS 0 0 \n",
+ "PSAV_XS 0 0 \n",
+ "SCOT_TXP 0 0 \n",
+ "SEINC_NUM 1 0 \n",
+ "SEISS 0 0 \n",
+ "SEX 2 1 \n",
+ "SPA 0 0 \n",
+ "SREF 15771837 15753289 \n",
+ "SRP 0 0 \n",
+ "TAX_CRED 8430 13285 \n",
+ "TAX_ST_AR_DEVO_TXP 0 0 \n",
+ "TAX_ST_AR_DEVO_WRIT 0 0 \n",
+ "TAX_ST_BR_DEVO_TXP 5755 0 \n",
+ "TAX_ST_BR_DEVO_WRIT 0 0 \n",
+ "TAX_ST_HR_DEVO_TXP 22085 0 \n",
+ "TAX_ST_HR_DEVO_WRIT 0 0 \n",
+ "TAX_ST_IR_DEVO_TXP 0 0 \n",
+ "TAX_ST_SR_DEVO_TXP 0 0 \n",
+ "TAXINC 109430 51500 \n",
+ "TAXPAYER 1 1 \n",
+ "TAXTERM 0 0 \n",
+ "TEI 0 0 \n",
+ "TI 124000 109000 \n",
+ "TII 124000 109000 \n",
+ "TOTTAX_DEVO_TXP 27840 0 \n",
+ "UBISJA 0 0 \n",
+ "WELSH_TXP 0 0 \n",
+ "zzz_policyengine_add_rate_savings_income 0.0 0.0 \n",
+ "zzz_policyengine_adjusted_net_income 124000.0 109000.0 \n",
+ "zzz_policyengine_basic_rate_savings_income 0.0 0.0 \n",
+ "zzz_policyengine_basic_rate_savings_income_pre_... 0.0 0.0 \n",
+ "zzz_policyengine_earned_taxable_income 114120.0 56000.0 \n",
+ "zzz_policyengine_employment_benefits 0.0 0.0 \n",
+ "zzz_policyengine_employment_deductions 0.0 0.0 \n",
+ "zzz_policyengine_higher_rate_savings_income 0.0 0.0 \n",
+ "zzz_policyengine_income_tax 29718.0 1615.0 \n",
+ "zzz_policyengine_other_tax_credits 8430.0 13285.0 \n",
+ "zzz_policyengine_pays_scottish_income_tax False False \n",
+ "zzz_policyengine_personal_allowance 500.0 8000.0 \n",
+ "zzz_policyengine_received_allowances 9880.0 53000.0 \n",
+ "zzz_policyengine_received_allowances_savings_in... 0.0 0.0 \n",
+ "zzz_policyengine_savings_allowance 500.0 500.0 \n",
+ "zzz_policyengine_savings_starter_rate_income 0.0 0.0 \n",
+ "zzz_policyengine_taxable_employment_income 0.0 0.0 \n",
+ "zzz_policyengine_taxable_pension_income 0.0 0.0 \n",
+ "zzz_policyengine_taxable_savings_interest_income 0.0 0.0 \n",
+ "zzz_policyengine_taxed_dividend_income 0.0 0.0 \n",
+ "zzz_policyengine_taxed_income 114120.0 56000.0 \n",
+ "zzz_policyengine_taxed_savings_income 0.0 0.0 \n",
+ "\n",
+ " 487185 640988 \\\n",
+ "abs_error 1599.0 1400.0 \n",
+ "AGERANGE 2 4 \n",
+ "BPADUE 0 0 \n",
+ "CAPALL 0 0 \n",
+ "COVNTS 0 0 \n",
+ "DEFICIEN 0 0 \n",
+ "DIVIDENDS 0 0 \n",
+ "DSHIPS 3 3 \n",
+ "EIDF 0 0 \n",
+ "EMPINC 0 0 \n",
+ "EPB 0 0 \n",
+ "error 1599.0 1400.0 \n",
+ "EXPS 0 0 \n",
+ "FACT 10.648841 10.648841 \n",
+ "GIFTAID 8190 56900 \n",
+ "GIFTINV 0 0 \n",
+ "GORCODE 7 2 \n",
+ "IIDF 8190 56900 \n",
+ "INCBBS 0 0 \n",
+ "INCPBEN 0 0 \n",
+ "INCPROP 108000 107000 \n",
+ "INDUSTRY07 1500 F \n",
+ "LLIR_RESTRICT_AMT_TOT 46975 22685 \n",
+ "LOSSBF 0 0 \n",
+ "MAIND 0 0 \n",
+ "MAINSRCE 5 4 \n",
+ "MAR STHR STHR \n",
+ "MCAS 0 0 \n",
+ "MOTHDED 0 0 \n",
+ "MOTHINC 0 0 \n",
+ "OSSBEN 0 0 \n",
+ "OTHERINC 0 0 \n",
+ "OTHERINV 0 0 \n",
+ "PAS 12500 12500 \n",
+ "PAY 0 0 \n",
+ "PENSION 0 0 \n",
+ "PENSRLF 0 0 \n",
+ "PROFITS 0 0 \n",
+ "PSAV_XS 0 0 \n",
+ "SCOT_TXP 0 0 \n",
+ "SEINC_NUM 0 1 \n",
+ "SEISS 0 0 \n",
+ "SEX 2 2 \n",
+ "SPA 0 0 \n",
+ "SREF 15563623 15738484 \n",
+ "SRP 0 0 \n",
+ "TAX_CRED 19395 4535 \n",
+ "TAX_ST_AR_DEVO_TXP 0 0 \n",
+ "TAX_ST_AR_DEVO_WRIT 0 0 \n",
+ "TAX_ST_BR_DEVO_TXP 2195 2985 \n",
+ "TAX_ST_BR_DEVO_WRIT 0 0 \n",
+ "TAX_ST_HR_DEVO_TXP 5835 15 \n",
+ "TAX_ST_HR_DEVO_WRIT 0 0 \n",
+ "TAX_ST_IR_DEVO_TXP 0 0 \n",
+ "TAX_ST_SR_DEVO_TXP 0 0 \n",
+ "TAXINC 87310 37600 \n",
+ "TAXPAYER 1 1 \n",
+ "TAXTERM 0 0 \n",
+ "TEI 0 0 \n",
+ "TI 108000 107000 \n",
+ "TII 108000 107000 \n",
+ "TOTTAX_DEVO_TXP 8030 3005 \n",
+ "UBISJA 0 0 \n",
+ "WELSH_TXP 0 0 \n",
+ "zzz_policyengine_add_rate_savings_income 0.0 0.0 \n",
+ "zzz_policyengine_adjusted_net_income 108000.0 107000.0 \n",
+ "zzz_policyengine_basic_rate_savings_income 0.0 0.0 \n",
+ "zzz_policyengine_basic_rate_savings_income_pre_... 0.0 0.0 \n",
+ "zzz_policyengine_earned_taxable_income 91310.0 41100.0 \n",
+ "zzz_policyengine_employment_benefits 0.0 0.0 \n",
+ "zzz_policyengine_employment_deductions 0.0 0.0 \n",
+ "zzz_policyengine_higher_rate_savings_income 0.0 0.0 \n",
+ "zzz_policyengine_income_tax 9629.0 4405.0 \n",
+ "zzz_policyengine_other_tax_credits 19395.0 4535.0 \n",
+ "zzz_policyengine_pays_scottish_income_tax False False \n",
+ "zzz_policyengine_personal_allowance 8500.0 9000.0 \n",
+ "zzz_policyengine_received_allowances 16690.0 65900.0 \n",
+ "zzz_policyengine_received_allowances_savings_in... 0.0 0.0 \n",
+ "zzz_policyengine_savings_allowance 500.0 500.0 \n",
+ "zzz_policyengine_savings_starter_rate_income 0.0 0.0 \n",
+ "zzz_policyengine_taxable_employment_income 0.0 0.0 \n",
+ "zzz_policyengine_taxable_pension_income 0.0 0.0 \n",
+ "zzz_policyengine_taxable_savings_interest_income 0.0 0.0 \n",
+ "zzz_policyengine_taxed_dividend_income 0.0 0.0 \n",
+ "zzz_policyengine_taxed_income 91310.0 41100.0 \n",
+ "zzz_policyengine_taxed_savings_income 0.0 0.0 \n",
+ "\n",
+ " 428507 \n",
+ "abs_error 1380.0 \n",
+ "AGERANGE 3 \n",
+ "BPADUE 0 \n",
+ "CAPALL 0 \n",
+ "COVNTS 0 \n",
+ "DEFICIEN 0 \n",
+ "DIVIDENDS 0 \n",
+ "DSHIPS 3 \n",
+ "EIDF 0 \n",
+ "EMPINC 0 \n",
+ "EPB 0 \n",
+ "error -1380.0 \n",
+ "EXPS 0 \n",
+ "FACT 53.399523 \n",
+ "GIFTAID 1500 \n",
+ "GIFTINV 0 \n",
+ "GORCODE 14 \n",
+ "IIDF 1500 \n",
+ "INCBBS 0 \n",
+ "INCPBEN 0 \n",
+ "INCPROP 9650 \n",
+ "INDUSTRY07 1500 \n",
+ "LLIR_RESTRICT_AMT_TOT 0 \n",
+ "LOSSBF 0 \n",
+ "MAIND 0 \n",
+ "MAINSRCE 5 \n",
+ "MAR STBR \n",
+ "MCAS 0 \n",
+ "MOTHDED 0 \n",
+ "MOTHINC 0 \n",
+ "OSSBEN 0 \n",
+ "OTHERINC 0 \n",
+ "OTHERINV 0 \n",
+ "PAS 1250 \n",
+ "PAY 0 \n",
+ "PENSION 0 \n",
+ "PENSRLF 0 \n",
+ "PROFITS 0 \n",
+ "PSAV_XS 0 \n",
+ "SCOT_TXP 0 \n",
+ "SEINC_NUM 0 \n",
+ "SEISS 0 \n",
+ "SEX 2 \n",
+ "SPA 0 \n",
+ "SREF 15496884 \n",
+ "SRP 0 \n",
+ "TAX_CRED 0 \n",
+ "TAX_ST_AR_DEVO_TXP 0 \n",
+ "TAX_ST_AR_DEVO_WRIT 0 \n",
+ "TAX_ST_BR_DEVO_TXP 1380 \n",
+ "TAX_ST_BR_DEVO_WRIT 0 \n",
+ "TAX_ST_HR_DEVO_TXP 0 \n",
+ "TAX_ST_HR_DEVO_WRIT 0 \n",
+ "TAX_ST_IR_DEVO_TXP 0 \n",
+ "TAX_ST_SR_DEVO_TXP 0 \n",
+ "TAXINC 6900 \n",
+ "TAXPAYER 1 \n",
+ "TAXTERM 0 \n",
+ "TEI 0 \n",
+ "TI 9650 \n",
+ "TII 9650 \n",
+ "TOTTAX_DEVO_TXP 1380 \n",
+ "UBISJA 0 \n",
+ "WELSH_TXP 0 \n",
+ "zzz_policyengine_add_rate_savings_income 0.0 \n",
+ "zzz_policyengine_adjusted_net_income 9650.0 \n",
+ "zzz_policyengine_basic_rate_savings_income 0.0 \n",
+ "zzz_policyengine_basic_rate_savings_income_pre_... 0.0 \n",
+ "zzz_policyengine_earned_taxable_income 0.0 \n",
+ "zzz_policyengine_employment_benefits 0.0 \n",
+ "zzz_policyengine_employment_deductions 0.0 \n",
+ "zzz_policyengine_higher_rate_savings_income 0.0 \n",
+ "zzz_policyengine_income_tax 0.0 \n",
+ "zzz_policyengine_other_tax_credits 0.0 \n",
+ "zzz_policyengine_pays_scottish_income_tax False \n",
+ "zzz_policyengine_personal_allowance 12500.0 \n",
+ "zzz_policyengine_received_allowances 9650.0 \n",
+ "zzz_policyengine_received_allowances_savings_in... 0.0 \n",
+ "zzz_policyengine_savings_allowance 1000.0 \n",
+ "zzz_policyengine_savings_starter_rate_income 0.0 \n",
+ "zzz_policyengine_taxable_employment_income 0.0 \n",
+ "zzz_policyengine_taxable_pension_income 0.0 \n",
+ "zzz_policyengine_taxable_savings_interest_income 0.0 \n",
+ "zzz_policyengine_taxed_dividend_income 0.0 \n",
+ "zzz_policyengine_taxed_income 0.0 \n",
+ "zzz_policyengine_taxed_savings_income 0.0 "
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "result_df = df[\n",
+ " (df['EMPINC'] == 0) & \n",
+ " (df['DIVIDENDS'] == 0) & \n",
+ " (df['INCBBS'] == 0) & \n",
+ " (df['PROFITS'] == 0) &\n",
+ " (df['CAPALL'] == 0) & \n",
+ " (df['PAY'] == 0) &\n",
+ " (df['PENSION'] == 0) &\n",
+ " (df['INCPROP'] != 0) &\n",
+ " (df['PAS'] != 0) &\n",
+ " (df['MOTHDED'] == 0)\n",
+ " # (df['abs_error'] < 1000)\n",
+ "].sort_values(\"abs_error\", ascending=False).head().T.sort_index(key=lambda x: x.str.lower())\n",
+ "\n",
+ "display(result_df)"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "base",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.10.14"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}