Hello, I'm trying to estimate a heckman model. The thing is when I use "heckman,twostep" it works, but when I use "heckman,ml", the maximum likelihood function won't converge. But I have to use "heckman,ml" because I need to use "margins, ycond" later and "ycond" option does not work after "heckman,twostep". That's why I want to try to put the estimates from the twostep estimation as the initial search values for the "heckman,ml" in the hope that it will converge this way.
To put in the initial search value from the above estimation results into "heckman, ml" estimation, I know it's something like
but I don't know what to put into the parentheses after "from".
This is from https://www.stata.com/manuals/rmaximize.pdf.
I know I can type in the values of the estimates into from() one by one, but in my own model, I have more than 50 variables, and I just cannot type it one by one. I was wondering whether there is an easier way. Thank you.
Code:
. use https://www.stata-press.com/data/r17/womenwk,clear
. heckman wage educ age, select(married children educ age) twostep
Heckman selection model -- two-step estimates Number of obs = 2,000
(regression model with sample selection) Selected = 1,343
Nonselected = 657
Wald chi2(2) = 442.54
Prob > chi2 = 0.0000
------------------------------------------------------------------------------
wage | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
wage |
education | .9825259 .0538821 18.23 0.000 .8769189 1.088133
age | .2118695 .0220511 9.61 0.000 .1686502 .2550888
_cons | .7340391 1.248331 0.59 0.557 -1.712645 3.180723
-------------+----------------------------------------------------------------
select |
married | .4308575 .074208 5.81 0.000 .2854125 .5763025
children | .4473249 .0287417 15.56 0.000 .3909922 .5036576
education | .0583645 .0109742 5.32 0.000 .0368555 .0798735
age | .0347211 .0042293 8.21 0.000 .0264318 .0430105
_cons | -2.467365 .1925635 -12.81 0.000 -2.844782 -2.089948
-------------+----------------------------------------------------------------
/mills |
lambda | 4.001615 .6065388 6.60 0.000 2.812821 5.19041
-------------+----------------------------------------------------------------
rho | 0.67284
sigma | 5.9473529
------------------------------------------------------------------------------
To put in the initial search value from the above estimation results into "heckman, ml" estimation, I know it's something like
Code:
heckman wage educ age, select(married children educ age) ml from()
from() specifies initial values for the coefficients. Not all estimators in Stata support this option. You can specify the initial values in one of three ways: by specifying the name of a vector containing the initial values (for example, from(b0), where b0 is a properly labeled vector); by specifying coefficient names with the values (for example, from(age=2.1 /sigma=7.4)); or by specifying a list of values (for example, from(2.1 7.4, copy)).
I know I can type in the values of the estimates into from() one by one, but in my own model, I have more than 50 variables, and I just cannot type it one by one. I was wondering whether there is an easier way. Thank you.

Comment