Skip to content

Commit f3bcbc1

Browse files
authored
Merge pull request #285 from centreformicrosimulation/SUSTAINWELLMerge
Sustainwell merge
2 parents 7e92893 + 6ae6fa7 commit f3bcbc1

39 files changed

Lines changed: 39126 additions & 37555 deletions

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,10 @@ input/EUROMODoutput/current/uk_2026_std.txt
338338
input/EUROMODoutput/current/uk_2027_std.txt
339339
input/InitialPopulations/current/*
340340
input/InitialPopulations/testing/*
341-
342341
.idea/*
343342
*.dta
343+
src/main/java/simpaths/data/startingpop/DataParser.new
344+
src/main/java/simpaths/data/startingpop/DataParser.old
345+
input/EUROMODoutput/limit/*
346+
input/InitialPopulations/limit/*
344347
.Rproj.user

analysis/fertility analysis.do

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/**************************************************************************************
2+
*
3+
* PROGRAM TO ANALYSE EMPLOYMENT TRANSATIONS
4+
*
5+
* Last version: Justin van de Ven, 06 May 2025
6+
* First version: Justin van de Ven, 06 May 2025
7+
*
8+
**************************************************************************************/
9+
10+
clear all
11+
global moddir = "C:\Justin\dev\CeMPASimPaths\output\20251029155614\csv"
12+
global outdir = "C:\Justin\analysis\data\"
13+
cd "$outdir"
14+
15+
16+
/**************************************************************************************
17+
* start
18+
**************************************************************************************/
19+
global year_start = 2015
20+
global year_end = 2026
21+
22+
23+
/**************************************************************************************
24+
* load data
25+
**************************************************************************************/
26+
import delimited using "$moddir/BenefitUnit.csv", clear
27+
rename *, l
28+
rename id_benefitunit idbenefitunit
29+
gsort idbenefitunit time
30+
save "$outdir/temp0", replace
31+
import delimited using "$moddir/Person.csv", clear
32+
rename *, l
33+
rename id_person idperson
34+
rename socialcareprovision socialcareprovision_p
35+
gsort idbenefitunit time idperson
36+
merge m:1 idbenefitunit time using temp0
37+
gsort time idbenefitunit idperson
38+
gen refbenefitunit = 0
39+
replace refbenefitunit = 1 if (idbenefitunit != idbenefitunit[_n-1])
40+
41+
destring hoursworkedweekly, replace force
42+
recode hoursworkedweekly (missing=0)
43+
gen idNotEmployedAdult = (hoursworkedweekly<0.1 & dag>17)
44+
45+
gen led = (deh_c3=="Low")
46+
gen med = (deh_c3=="Medium")
47+
gen hed = (deh_c3=="High")
48+
49+
gen male = (dgn=="Male")
50+
51+
gen idbaby = (dag==0)
52+
bys time idbenefitunit: egen baby = sum(idbaby)
53+
54+
save "$outdir/temp1", replace
55+
56+
57+
/**************************************************************************************
58+
* analysis
59+
**************************************************************************************/
60+
use "$outdir/temp1", clear
61+
global year_ref = $year_start-1
62+
63+
// block 1 statistics
64+
gen emp = (hoursworkedweekly>0.5)
65+
gen emp_to_nemp = 0
66+
gen nemp_to_emp = 0
67+
gsort idperson time
68+
replace emp_to_nemp = 1 if (idperson[_n-1]==idperson & time[_n-1]+1==time & emp[_n-1]==1 & emp==0)
69+
replace nemp_to_emp = 1 if (idperson[_n-1]==idperson & time[_n-1]+1==time & emp[_n-1]==0 & emp==1)
70+
order time idperson hoursworkedweekly emp emp_to_nemp
71+
matrix store1 = J($year_end-$year_ref,1,.)
72+
forvalues yy = $year_start/$year_end {
73+
qui{
74+
sum baby if (time==`yy' & dag>17 & dag<65), mean
75+
mat store1[`yy'-${year_ref},1] = r(mean)
76+
}
77+
}
78+
matlist store1

input/DatabaseCountryYear.xlsx

14 Bytes
Binary file not shown.

input/EUROMODpolicySchedule.xlsx

29 Bytes
Binary file not shown.

input/InitialPopulations/compile/00_master.do

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ global dir_ukhls_data "D:\Dasha\UK-original-data\USoc\UKDA-6614-stata\stata\stat
5656
*global dir_ukhls_data "C:\Users\Patryk\Documents\SP_prep_pop\ukhls\UKDA-6614-stata\stata\stata13_se\ukhls"
5757

5858
* Directory which contains WAS data
59-
*global dir_was_data "J:\01 DATA\UK\was\wave7\stata\stata13_se"
59+
*global dir_was_data "J:\01 DATA\UK\was\wave8\stata\stata13_se"
6060
global dir_was_data "D:\Dasha\UK-original-data\WAS\UKDA-7215-stata\stata\stata13_se"
6161
*global dir_was_data "C:\Users\Patryk\Documents\WAS\UKDA-7215-stata\stata\stata13_se"
6262

input/InitialPopulations/compile/02_create_UKHLS_variables.do

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1326,6 +1326,33 @@ egen yhhnb = rowtotal(ypnb ypnbsp) if dhhtp_c4 == 1 | dhhtp_c4 == 2 //Household
13261326
replace yhhnb = ypnb if dhhtp_c4 == 3 | dhhtp_c4 == 4 //If single, household income is equal to individual income
13271327

13281328

1329+
/*Disposable income */
1330+
sort hidp
1331+
gen ydisp = fimnnet_dv
1332+
recode ydisp (missing = 0)
1333+
by hidp: egen hhinc = sum(ydisp)
1334+
gen res = fihhmnnet1_dv - hhinc
1335+
gen mis = (fimnnet_dv>=.)*(age_dv>17.5)
1336+
by hidp: egen nmis = sum(mis)
1337+
replace ydisp = res / nmis if (res>0.1 & res<. & mis==1)
1338+
1339+
drop hhinc res mis nmis
1340+
by hidp: egen hhinc = sum(ydisp)
1341+
gen res = fihhmnnet1_dv - hhinc
1342+
gen mis = (fimnnet_dv>=.)*(age_dv>14.5)*(age_dv<17.5)
1343+
by hidp: egen nmis = sum(mis)
1344+
replace ydisp = res / nmis if (res>0.1 & res<. & mis==1)
1345+
recode ydisp (missing=0)
1346+
/* checks
1347+
by hidp: egen hhinc2 = sum(ydisp)
1348+
gen res2 = fihhmnnet1_dv - hhinc2
1349+
gen chk = (abs(res2) > 0.1)*(fihhmnnet1_dv<.)
1350+
order age_dv fihhmnnet1_dv fimnnet_dv ydisp hhinc res res2 mis nmis chk, a(hidp)
1351+
tab chk
1352+
drop hhinc2 res2 chk
1353+
*/
1354+
drop hhinc res mis nmis
1355+
13291356
*Income CPI
13301357
/*CPIH INDEX 00: ALL ITEMS 2015=100
13311358
CDID L522
@@ -1362,6 +1389,7 @@ replace ypnb = ypnb/CPI
13621389
replace yptc = yptc/CPI
13631390
replace yplgrs = yplgrs/CPI
13641391
replace ypnbsp = ypnbsp/CPI
1392+
replace ydisp = ydisp/CPI
13651393

13661394
*Inverse hyperbolic sine transformation:
13671395
/*This transformation is useful for data that exhibit highly skewed distributions,
@@ -1409,6 +1437,7 @@ la var ypnbihs_dv "Gross personal non-benefit income"
14091437
la var yptciihs_dv "Gross personal non-employment, non-benefit income"
14101438
la var yplgrs_dv "Gross personal employment income"
14111439
la var ynbcpdf_dv "Difference between own and spouse's gross personal non-benefit income"
1440+
la var ydisp "Disposable income (individual)"
14121441

14131442
*Gross-to-net ratio
14141443
gen gross_net_ratio = fimngrs_dv/fimnnet_dv
@@ -1601,7 +1630,7 @@ replace dwt = 0 if missing(dwt)
16011630
/***************************Keep required variables***************************/
16021631
keep ivfio idhh idperson idpartner idfather idmother dct drgn1 dwt dnc02 dnc dgn dgnsp dag dagsq dhe dhesp dcpst ///
16031632
ded deh_c3 der dehsp_c3 dehm_c3 dehf_c3 dehmf_c3 dcpen dcpyy dcpex dcpagdf dlltsd dlltsd01 dlrtrd drtren dlftphm dhhtp_c4 dhm dhm_ghq dimlwt disclwt ///
1604-
dimxwt dhhwt jbhrs jshrs j2hrs jbstat les_c3 les_c4 lessp_c3 lessp_c4 lesdf_c4 ydses_c5 month scghq2_dv ///
1633+
dimxwt dhhwt jbhrs jshrs j2hrs jbstat les_c3 les_c4 lessp_c3 lessp_c4 lesdf_c4 ydses_c5 month scghq2_dv ydisp ///
16051634
ypnbihs_dv yptciihs_dv yplgrs_dv ynbcpdf_dv ypncp ypnoab swv sedex ssscp sprfm sedag stm dagsp lhw l1_lhw pno ppno hgbioad1 hgbioad2 der adultchildflag ///
16061635
econ_benefits econ_benefits_nonuc econ_benefits_uc ///
16071636
sedcsmpl sedrsmpl scedsmpl dhh_owned dukfr dchpd dagpns dagpns_sp CPI lesnr_c2 dlltsd_sp dlltsd01_sp ypnoab_lvl *_flag Int_Date dhe_mcs dhe_pcs dhe_mcssp dhe_pcssp dls dot dot01 unemp financial_distress

input/InitialPopulations/compile/09_finalise_input_data.do

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,26 +178,30 @@ forvalues yy = $firstSimYear/$lastSimYear {
178178
//sum of weights
179179
cap gen one =1
180180
sum one [w=dwt]
181+
182+
*evaluate disposable income at household level
183+
gsort idhh idbenefitunit idperson
184+
by idhh idbenefitunit: egen disp_inc = sum(ydisp)
181185

182186
*limit saved variables
183187
keep idhh idbenefitunit idperson idpartner idmother idfather pno swv dgn dag dcpst dnc02 dnc ded deh_c3 sedex jbstat les_c3 dlltsd dlltsd01 dhe ydses_c5 ///
184188
yplgrs_dv ypnbihs_dv yptciihs_dv dhhtp_c4 ssscp dcpen dcpyy dcpex dcpagdf ynbcpdf_dv der sedag sprfm dagsp dehsp_c3 dhesp lessp_c3 dehm_c3 dehf_c3 ///
185189
stm lesdf_c4 ppno dhm scghq2_dv dhh_owned lhw l1_lhw drgn1 dct dwt_sampling les_c4 dhm_ghq lessp_c4 adultchildflag multiplier dwt ///
186190
potential_earnings_hourly l1_potential_earnings_hourly liquid_wealth tot_pen nvmhome need_socare formal_socare_hrs partner_socare_hrs daughter_socare_hrs son_socare_hrs other_socare_hrs formal_socare_cost carehoursprovidedweekly ///
187191
econ_benefits econ_benefits_nonuc econ_benefits_uc ///
188-
ypncp ypnoab aidhrs carewho dhe_mcs dhe_pcs dhe_mcssp dhe_pcssp dls dot dot01 unemp financial_distress
192+
disp_inc ypncp ypnoab aidhrs carewho dhe_mcs dhe_pcs dhe_mcssp dhe_pcssp dls dot dot01 unemp financial_distress
189193

190194
order idhh idbenefitunit idperson idpartner idmother idfather pno swv dgn dag dcpst dnc02 dnc ded deh_c3 sedex jbstat les_c3 dlltsd dlltsd01 dhe ydses_c5 yplgrs_dv ypnbihs_dv yptciihs_dv dhhtp_c4 ssscp dcpen ///
191195
dcpyy dcpex dcpagdf ynbcpdf_dv der sedag sprfm dagsp dehsp_c3 dhesp lessp_c3 dehm_c3 dehf_c3 stm lesdf_c4 ppno dhm scghq2_dv dhh_owned lhw l1_lhw drgn1 dct dwt_sampling les_c4 dhm_ghq lessp_c4 adultchildflag ///
192196
multiplier dwt potential_earnings_hourly l1_potential_earnings_hourly liquid_wealth tot_pen nvmhome need_socare formal_socare_hrs partner_socare_hrs daughter_socare_hrs son_socare_hrs other_socare_hrs formal_socare_cost carehoursprovidedweekly ///
193197
econ_benefits econ_benefits_nonuc econ_benefits_uc ///
194-
ypncp ypnoab aidhrs carewho dhe_mcs dhe_pcs dhe_mcssp dhe_pcssp dls dot dot01 unemp financial_distress
198+
disp_inc ypncp ypnoab aidhrs carewho dhe_mcs dhe_pcs dhe_mcssp dhe_pcssp dls dot dot01 unemp financial_distress
195199

196200
recode idhh idbenefitunit idperson idpartner idmother idfather pno swv dgn dag dcpst dnc02 dnc ded deh_c3 sedex jbstat les_c3 dlltsd dlltsd01 dhe ydses_c5 yplgrs_dv ypnbihs_dv yptciihs_dv dhhtp_c4 ssscp ///
197201
dcpen dcpyy dcpex dcpagdf ynbcpdf_dv der sedag sprfm dagsp dehsp_c3 dhesp lessp_c3 dehm_c3 dehf_c3 stm lesdf_c4 ppno dhm scghq2_dv dhh_owned lhw l1_lhw drgn1 dct dwt_sampling les_c4 dhm_ghq lessp_c4 ///
198202
adultchildflag multiplier dwt potential_earnings_hourly l1_potential_earnings_hourly liquid_wealth tot_pen nvmhome need_socare formal_socare_hrs partner_socare_hrs daughter_socare_hrs son_socare_hrs other_socare_hrs carehoursprovidedweekly ///
199203
econ_benefits econ_benefits_nonuc econ_benefits_uc ///
200-
formal_socare_cost ypncp ypnoab aidhrs carewho dhe_mcs dhe_pcs dhe_mcssp dhe_pcssp dls dot dot01 unemp financial_distress (missing=-9)
204+
formal_socare_cost disp_inc ypncp ypnoab aidhrs carewho dhe_mcs dhe_pcs dhe_mcssp dhe_pcssp dls dot dot01 unemp financial_distress (missing=-9)
201205

202206
gsort idhh idbenefitunit idperson
203207
save "$dir_data/population_initial_UK_$year.dta", replace

input/InitialPopulations/compile/10_check_yearly_data.do

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ partner_socare_hrs
8585
daughter_socare_hrs
8686
son_socare_hrs
8787
other_socare_hrs
88-
formal_socare_cost
88+
formal_socare_cost
89+
disp_inc
8990
ypncp
9091
ypnoab
9192
dhe_mcs
@@ -142,7 +143,8 @@ dnc
142143
ded
143144
sedex
144145
dlltsd
145-
dlltsd01
146+
dlltsd01
147+
disp_inc
146148
ypncp
147149
ypnoab
148150
yplgrs_dv
@@ -365,17 +367,17 @@ insheet using "$dir_data/population_initial_UK_`year'.csv", clear
365367
yplgrs_dv ypnbihs_dv yptciihs_dv dhhtp_c4 ssscp dcpen dcpyy dcpex dcpagdf ynbcpdf_dv der sedag sprfm dagsp dehsp_c3 dhesp lessp_c3 dehm_c3 dehf_c3 ///
366368
stm lesdf_c4 ppno dhm scghq2_dv dhh_owned lhw drgn1 dct dwt_sampling les_c4 dhm_ghq lessp_c4 adultchildflag multiplier dwt ///
367369
potential_earnings_hourly l1_potential_earnings_hourly liquid_wealth need_socare formal_socare_hrs partner_socare_hrs daughter_socare_hrs son_socare_hrs other_socare_hrs formal_socare_cost ///
368-
ypncp ypnoab aidhrs carewho dhe_mcs dhe_pcs dot dot01 unemp dhe_mcssp dhe_pcssp
370+
disp_inc ypncp ypnoab aidhrs carewho dhe_mcs dhe_pcs dot dot01 unemp dhe_mcssp dhe_pcssp
369371
370372
order idhh idbenefitunit idperson idpartner idmother idfather pno swv dgn dag dcpst dnc02 dnc ded deh_c3 sedex jbstat les_c3 dlltsd dlltsd01 dhe ydses_c5 yplgrs_dv ypnbihs_dv yptciihs_dv dhhtp_c4 ssscp dcpen ///
371373
dcpyy dcpex dcpagdf ynbcpdf_dv der sedag sprfm dagsp dehsp_c3 dhesp lessp_c3 dehm_c3 dehf_c3 stm lesdf_c4 ppno dhm scghq2_dv dhh_owned lhw drgn1 dct dwt_sampling les_c4 dhm_ghq lessp_c4 adultchildflag ///
372374
multiplier dwt potential_earnings_hourly l1_potential_earnings_hourly liquid_wealth need_socare formal_socare_hrs partner_socare_hrs daughter_socare_hrs son_socare_hrs other_socare_hrs formal_socare_cost ///
373-
ypncp ypnoab aidhrs carewho dhe_mcs dhe_pcs dhe_mcssp dhe_pcssp dot dot01 unemp
375+
disp_inc ypncp ypnoab aidhrs carewho dhe_mcs dhe_pcs dhe_mcssp dhe_pcssp dot dot01 unemp
374376
375377
recode idhh idbenefitunit idperson idpartner idmother idfather pno swv dgn dag dcpst dnc02 dnc ded deh_c3 sedex jbstat les_c3 dlltsd dlltsd01 dhe ydses_c5 yplgrs_dv ypnbihs_dv yptciihs_dv dhhtp_c4 ssscp ///
376378
dcpen dcpyy dcpex dcpagdf ynbcpdf_dv der sedag sprfm dagsp dehsp_c3 dhesp lessp_c3 dehm_c3 dehf_c3 stm lesdf_c4 ppno dhm scghq2_dv dhh_owned lhw drgn1 dct dwt_sampling les_c4 dhm_ghq lessp_c4 ///
377379
adultchildflag multiplier dwt potential_earnings_hourly l1_potential_earnings_hourly liquid_wealth need_socare formal_socare_hrs partner_socare_hrs daughter_socare_hrs son_socare_hrs other_socare_hrs ///
378-
formal_socare_cost ypncp ypnoab aidhrs carewho dhe_mcs dhe_pcs dhe_mcssp dhe_pcssp dot dot01 unemp (missing=-9)
380+
formal_socare_cost disp_inc ypncp ypnoab aidhrs carewho dhe_mcs dhe_pcs dhe_mcssp dhe_pcssp dot dot01 unemp (missing=-9)
379381
380382
gsort idhh idbenefitunit idperson
381383
save "$dir_data/population_initial_UK_`year'.dta", replace

input/InitialPopulations/compile/99_training_data.do

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ rename dwt2 dwt
185185
save "$dir_data/temp10", replace
186186

187187
// adjust continuous variables
188-
foreach vv of varlist yplgrs_dv ypnbihs_dv yptciihs_dv ynbcpdf_dv liquid_wealth tot_pen nvmhome ypncp ypnoab formal_socare_hrs partner_socare_hrs daughter_socare_hrs son_socare_hrs other_socare_hrs formal_socare_cost aidhrs {
188+
foreach vv of varlist yplgrs_dv ypnbihs_dv yptciihs_dv ynbcpdf_dv liquid_wealth tot_pen nvmhome disp_inc ypncp ypnoab formal_socare_hrs partner_socare_hrs daughter_socare_hrs son_socare_hrs other_socare_hrs formal_socare_cost aidhrs {
189189
gen tmp = `vv'
190190
order tmp, a(`vv')
191191
recode tmp (0=.)
@@ -212,7 +212,7 @@ save "$dir_data/temp11", replace
212212

213213
// set benefit unit level variables
214214
use "$dir_data/temp11", clear
215-
foreach vv of varlist drgn1 ydses_c5 dhh_owned dwt liquid_wealth tot_pen nvmhome {
215+
foreach vv of varlist drgn1 ydses_c5 dhh_owned dwt liquid_wealth tot_pen nvmhome disp_inc {
216216

217217
rename `vv' `vv'i
218218
bys idbenefitunit: egen `vv' = mean(`vv'i)

0 commit comments

Comments
 (0)