LS do-files for PL - #198
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Several new PL adult-children scripts contain Stata runtime-breaking issues (undefined variables and a precedence bug in a drop if condition) that must be fixed before the pipeline can execute reliably.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR adds/updates the Poland (PL) labour supply (LS) Stata pipeline do-files used to prepare samples, run EUROMOD counterfactuals (10% wage increase), and estimate/derive elasticities for singles, couples, and adult children subsamples.
Changes:
- Added PL “std singles/couples” sample construction and EUROMOD wage-elasticity runner scripts.
- Added PL final LS model specification scripts (singles indep/dep, couples, adult children).
- Added adult-children “dropped sample” pipeline (household split + sample prep + EUROMOD elasticity) plus helper
.adoutilities.
File summaries
| File | Description |
|---|---|
| input_processing/labour_supply/do-files/std singles and couples data preparation/3b-EM couple wage elasticity-std model.do | Runs EUROMOD for couples under +10% wage counterfactual and saves simulated outputs. |
| input_processing/labour_supply/do-files/std singles and couples data preparation/3a-EM single wage elasticity-std model.do | Runs EUROMOD for singles under +10% wage counterfactual and saves simulated outputs. |
| input_processing/labour_supply/do-files/std singles and couples data preparation/2b-couples sample-std model.do | Builds the estimation sample for couples and constructs LS covariates/alternatives. |
| input_processing/labour_supply/do-files/std singles and couples data preparation/2a-singles sample-std model.do | Builds the estimation sample for singles and constructs LS covariates/alternatives. |
| input_processing/labour_supply/do-files/PL master-elast.do | Master driver for the full PL LS + elasticity workflow (std + adult children + final specs). |
| input_processing/labour_supply/do-files/model specifications/4d-singles_indep_elast-adult_ch - final.do | Final LS estimation/elasticity computation for independent adult children. |
| input_processing/labour_supply/do-files/model specifications/4c-couples elast-std model - final.do | Final LS estimation/elasticity computation for flexible couples. |
| input_processing/labour_supply/do-files/model specifications/4b-singles_dep_elast-std model - final.do | Final LS estimation/elasticity computation for dependent singles. |
| input_processing/labour_supply/do-files/model specifications/4a-singles_indep_elast-std model - final.do | Final LS estimation/elasticity computation for independent singles (sex-specific). |
| input_processing/labour_supply/do-files/adult children data preparation/3-EM single wage elasticity-adult_ch.do | Runs EUROMOD counterfactual for adult-children sample and saves simulated outputs. |
| input_processing/labour_supply/do-files/adult children data preparation/2-singles sample-dropped sample.do | Prepares the adult-children estimation sample and required covariates. |
| input_processing/labour_supply/do-files/adult children data preparation/1-input and output data-dropped sample.do | Creates the dropped/adult-children sample, splits households, generates LS alternatives, corrects benefits, and runs EUROMOD. |
| input_processing/labour_supply/do-files/ADO/add_partner_variables2.ado | Adds a variant helper to merge partner variables using a (stm,idpartner) key. |
| input_processing/labour_supply/do-files/ADO/add_partner_variables.ado | Adds/updates helper to merge partner variables using idpartner. |
| input_processing/labour_supply/do-files/ADO/add_mother_variables2.ado | Adds a variant helper to merge mother variables using a (stm,idmother) key. |
| input_processing/labour_supply/do-files/ADO/add_mother_variables.ado | Adds/updates helper to merge mother variables using idmother. |
| input_processing/labour_supply/do-files/ADO/add_father_variables2.ado | Adds a variant helper to merge father variables using a (stm,idfather) key. |
| input_processing/labour_supply/do-files/ADO/add_father_variables.ado | Adds/updates helper to merge father variables using idfather. |
| input_processing/labour_supply/do-files/add_original_SILC_vars.do | Adds a utility script to pull selected variables (e.g., health) from original EU-SILC extracts. |
Review details
Suppressed comments (1)
input_processing/labour_supply/do-files/adult children data preparation/1-input and output data-dropped sample.do:291
- This assertion uses
number_workers_singles, but the computed household worker count variable in this block isnumber_workers_singleshh. As written, the assertion will fail to run due to an undefined variable.
assert number_workers_singles==1 if temp_singles==1
- Files reviewed: 19/20 changed files
- Comments generated: 5
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
|
||
| //check there are no more than TWO flexible workers in a "COUPLES"' household | ||
| bysort idhh: egen number_workers_coupleshh=total(worker_count) if temp_couples==1, missing | ||
| su number_workers_couples |
| fre psu00 //Survivors pension (agricultural and non-agricultural) | ||
| fre pyr //Pre-retirement allowance and benefit | ||
| */ | ||
| drop if pdi00>0 | pdinw>0 & (temp_singles==1|temp_couples==1) //(5,896 observations deleted) |
| gen d_owner_mort=(amrtn==1) //own on mortgage | ||
| label variable d_owner_out "house owner (on mortgage)" | ||
|
|
| cd "$local_data" | ||
|
|
||
| capture log close | ||
| log using "$file_log", replace | ||
| pwd |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
Multiple added do-files contain script-stopping issues (undefined macros, invalid lines, option typos, and precedence bugs) that will break the PL LS pipeline when executed.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Suppressed comments (8)
Previously missed (3) — in code that hasn't changed since the last review.
input_processing/labour_supply/do-files/std singles and couples data preparation/2b-couples sample-std model.do:95
- This assert checks
temp_singles==1, but the dataset has already been filtered totemp_couples==1(line 90). As written, it won’t validate missing wage/hours fields for the actual couples sample.
input_processing/labour_supply/do-files/std singles and couples data preparation/2b-couples sample-std model.do:154 mean_age2_10000is named/labeled as age^2 scaled by 10,000, but it is currently divided by 100. This mis-scales the regressor and can change estimated coefficients.
input_processing/labour_supply/do-files/model specifications/4b-singles_dep_elast-std model - final.do:13- This log filename macro is for the dependent-singles model, but it’s set to the same value as the independent-singles script. That can silently overwrite logs and make debugging/repro harder.
input_processing/labour_supply/do-files/adult children data preparation/2-singles sample-dropped sample.do:107
- The mortgage-ownership label is being applied to
d_owner_outinstead ofd_owner_mort, sod_owner_outgets labeled twice andd_owner_mortremains unlabeled/mislabeled.
gen d_owner_out=(amrtn==2) //own outright
label variable d_owner_out "house owner (outright)"
gen d_owner_mort=(amrtn==1) //own on mortgage
label variable d_owner_out "house owner (on mortgage)"
input_processing/labour_supply/do-files/adult children data preparation/3-EM single wage elasticity-adult_ch.do:16
$file_logis used forlog usingbut never defined in this do-file, so running it will error with “macro not found”.
cd "$local_data"
capture log close
log using "$file_log", replace
pwd
input_processing/labour_supply/do-files/adult children data preparation/1-input and output data-dropped sample.do:275
- This summary uses
number_workers_couples, but the variable created isnumber_workers_coupleshh. As written, Stata will error becausenumber_workers_couplesdoesn’t exist.
//check there are no more than TWO flexible workers in a "COUPLES"' household
bysort idhh: egen number_workers_coupleshh=total(worker_count) if temp_couples==1, missing
su number_workers_couples
count if number_workers_coupleshh>2 & temp_couples==1 //0 obs
input_processing/labour_supply/do-files/adult children data preparation/1-input and output data-dropped sample.do:292
- This assert references
number_workers_singles, but the computed variable isnumber_workers_singleshh. As written, it will error and stop the script.
duplicates report idperson //count how many unique individuals there are
assert number_workers_singles==1 if temp_singles==1
drop worker_count number_* //22/1/2021
input_processing/labour_supply/do-files/adult children data preparation/1-input and output data-dropped sample.do:653
- Operator precedence makes this drop unconditional on
temp_*forpdi00>0(because|is evaluated after&), potentially deleting records outside the intended singles/couples sample. Parentheses are needed.
drop if pdi00>0 | pdinw>0 & (temp_singles==1|temp_couples==1) //(5,896 observations deleted)
- Files reviewed: 19/20 changed files
- Comments generated: 3
- Review effort level: Lite
| //check whether a not flexible individual can have temp_with_couples=1 and temp_with_singles=1 at the same time : no such cases | ||
| su dag if temp_with_singles==1 &temp_with_couples==1 &temp_not_flexible==1 //they are <16 and either pre-school or student | ||
| tab les if temp_with_singles==1 &temp_with_couples==1 &temp_not_flexible==1 //they are <16 and either pre-school or student | ||
| *** | ||
| su temp_singles temp_couples temp_not_flexible if temp_with_singles==1 &temp_with_couples==1 //this shows singles, couples, and not flexible individuals can all live together | ||
|
|
There was a problem hiding this comment.
not true, Copilot comment is irrelevant
| drop if sim_flag==1 //make sure the data is actual at this point | ||
| //clogit temp_choicehh ${vars_`gender'} if dgn==`gender' , group (temp_idorigperson2) //estimate only on actual data (sim_flag==0) | ||
| asclogit temp_choicehh ${vars_`gender'} if dgn==`gender', case(temp_idorigperson2) alt(temp_seq) casevar(liwwh liwwh2) nocons | ||
| ************************************************************************************************************************************** |
| //clogit temp_choicehh $vars , group (temp_idorigperson2) | ||
| asclogit temp_choicehh $vars, case(temp_idorigperson2) alt(temp_seq) casevar(liwwh liwwh2 sp_liwwh sp_liwwh2) nocons | ||
| ************************************************************************************************************************************************* |
I've added the latest do-files for the LS model for PL.