Skip to content

Commit 70a478a

Browse files
authored
Merge pull request #1427 from PolicyEngine/add-own-vehicle-variable
Add owns vehicle variable
2 parents 39576ea + d34793d commit 70a478a

8 files changed

Lines changed: 68 additions & 1 deletion

File tree

changelog_entry.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- bump: minor
2+
changes:
3+
added:
4+
- Add owns vehicle variable

policyengine_uk/tests/policy/baseline/finance/benefit/family/child_benefit.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
benunits:
2727
benunit:
2828
members: [parent1, parent2, child1]
29+
would_claim_child_benefit: true
2930
output:
3031
child_benefit: 1098
3132
- name: Child Benefit with two children, one over 16
@@ -45,5 +46,6 @@
4546
benunits:
4647
benunit:
4748
members: [parent1, parent2, child1, child2]
49+
would_claim_child_benefit: true
4850
output:
4951
child_benefit: 1825.20

policyengine_uk/tests/policy/baseline/gov/dcms/bbc/tv-licence/tv_licence.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
- name: TV Licence full price - ineligible for aged or blind discount.
22
period: 2023
33
input:
4+
household_owns_tv: true
45
tv_licence_discount: 0
56
would_evade_tv_licence_fee: false
67
output:
@@ -9,6 +10,7 @@
910
- name: TV Licence half price - eligible for blind discount but not aged.
1011
period: 2023
1112
input:
13+
household_owns_tv: true
1214
tv_licence_discount: 0.5
1315
would_evade_tv_licence_fee: false
1416
output:
@@ -17,6 +19,7 @@
1719
- name: Free TV Licence - eligible for aged discount.
1820
period: 2023
1921
input:
22+
household_owns_tv: true
2023
tv_licence_discount: 1
2124
would_evade_tv_licence_fee: false
2225
output:
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
- name: Household with no vehicles does not own a vehicle
2+
period: 2024
3+
input:
4+
num_vehicles: 0
5+
output:
6+
owns_vehicle: false
7+
8+
- name: Household with one vehicle owns a vehicle
9+
period: 2024
10+
input:
11+
num_vehicles: 1
12+
output:
13+
owns_vehicle: true
14+
15+
- name: Household with multiple vehicles owns a vehicle
16+
period: 2024
17+
input:
18+
num_vehicles: 3
19+
output:
20+
owns_vehicle: true
21+
22+
- name: Default num_vehicles is zero
23+
period: 2024
24+
input: {}
25+
output:
26+
num_vehicles: 0
27+
owns_vehicle: false

policyengine_uk/tests/policy/reforms/parametric/basic_income/basic_income.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
benunits:
2222
benunit:
2323
members: [working_age, senior, child]
24+
would_claim_child_benefit: true
2425
output:
2526
basic_income: [52, 104, 156]
2627
child_benefit: 1820

policyengine_uk/variables/gov/hmrc/would_claim_child_benefit.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@ class would_claim_child_benefit(Variable):
1111
value_type = bool
1212

1313
def formula(benunit, period, parameters):
14+
claims_all_entitled_benefits = benunit(
15+
"claims_all_entitled_benefits", period
16+
)
1417
takeup_rate = parameters(period).gov.hmrc.child_benefit.takeup
1518
overall_p = takeup_rate.overall
16-
return (random(benunit) < overall_p) * ~benunit(
19+
random_takeup = (random(benunit) < overall_p) & ~benunit(
1720
"child_benefit_opts_out", period
1821
)
22+
return claims_all_entitled_benefits | random_takeup
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from policyengine_uk.model_api import *
2+
3+
4+
class num_vehicles(Variable):
5+
label = "number of vehicles owned by the household"
6+
documentation = "Imputed from WAS vcarnr7 variable"
7+
entity = Household
8+
definition_period = YEAR
9+
value_type = int
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from policyengine_uk.model_api import *
2+
3+
4+
class owns_vehicle(Variable):
5+
label = "whether the household owns a vehicle"
6+
documentation = (
7+
"Used for calibration to NTS 2024 data "
8+
"showing 78% of UK households own at least one car. "
9+
"Source: https://www.gov.uk/government/statistics/national-travel-survey-2024"
10+
)
11+
reference = "https://www.gov.uk/government/statistics/national-travel-survey-2024/nts-2024-household-car-availability-and-trends-in-car-trips"
12+
entity = Household
13+
definition_period = YEAR
14+
value_type = bool
15+
16+
def formula(household, period):
17+
return household("num_vehicles", period) > 0

0 commit comments

Comments
 (0)