Skip to content

LS do-files for PL - #198

Merged
Mariia-Var merged 2 commits into
simpaths:developfrom
dariaple:LS-do-files
Sep 8, 2026
Merged

LS do-files for PL#198
Mariia-Var merged 2 commits into
simpaths:developfrom
dariaple:LS-do-files

Conversation

@dariaple

@dariaple dariaple commented Sep 3, 2026

Copy link
Copy Markdown

I've added the latest do-files for the LS model for PL.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 .ado utilities.
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 is number_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)
Comment on lines +105 to +107
gen d_owner_mort=(amrtn==1) //own on mortgage
label variable d_owner_out "house owner (on mortgage)"

Comment on lines +12 to +16
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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 to temp_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_10000 is 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_out instead of d_owner_mort, so d_owner_out gets labeled twice and d_owner_mort remains 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_log is used for log using but 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 is number_workers_coupleshh. As written, Stata will error because number_workers_couples doesn’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 is number_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_* for pdi00>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

Comment on lines +257 to +262
//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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not true, Copilot comment is irrelevant

Comment on lines +67 to +70
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
**************************************************************************************************************************************
Comment on lines +33 to +35
//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
*************************************************************************************************************************************************
@Mariia-Var
Mariia-Var merged commit 1dab801 into simpaths:develop Sep 8, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants