Dear all,
I came across the KHB method for mediation analysis. I have gone through the paper “Comparing coefficients of nested nonlinear probability models” but I couldn’t figure out (after trying many times) the command in the ordered outcome section which is as shown below:


. forv i = 1/3 { 2. quietly eststo: khb ologit edu fses || abil, outcome(`i´) ape > summary 3. }

. esttab, scalars("ratio_fses Conf.-Ratio" "pct_fses Conf.-Perc.")


I use an ordered logit as my dependent variable has 6 outcomes(which are educational levels) and I have a number of control variables too.

Dependent variable = isced1997_r

Independent variable= i.sl_hs045d2

Mediator= i.sl_cs010

Control variables = i.dn042, i.dn003, i.cs009, i.cs008.


I use this command:

. forv i = 1/6 { 2. quietly eststo: khb ologit isced1997_r i.sl_hs045d2 || i.sl_cs010, outcome(`i´) ape > summary 6. }

. esttab, scalars("ratio_ i.sl_hs045d2 Conf.-Ratio" "pct_ i.sl_hs045d2 Conf.-Perc.")


But get this message- program error: code follows on the same line as open brace

I will really appreciate your guidance on inputting this in Stata in order to get the analysis done. Many thanks.