Dear Statalists,

My dependent variable is y2_ft in the second stage of heckman selection model, f denotes firm, t denotes time. y2_ft is firm performance and one firm only locate in one country c in my data (that's why I have ft subscript rather than fct in my second stage). My first stage is firms' location choice y1_fct, capturing the selection effect; in the first stage, a firm can choose to locate in 191 different countries in the world.

My independent variable is institution_ct, which means the institutional environment in country c and year t.
Since different firms in a country can face the same institution_ct, so I need to cluster standard errors by country c. And I also include year and country FEs.

But heckman two-step option in Stata can not allow for clustering s.e. by country. Heckman MLE option can, but if adding FEs in the second stage using MLE, the program does not converge.

The code I am using is:

1) heckman two-step:
Code:
 xi: heckman y2_ft institution_ct $control i.year i.countryid ,select (y1_fct= institution_ct $control $exo)   two
2) heckman mle:
Code:
 xi: heckman y2_ft institution_ct $control  ,select (y1_fct= institution_ct $control $exo)  vce(cluster countryid)

How can I cluster s.e. by country using heckman two-step in Stata? Any suggestions or comments would be appreciated.
Thank you very much.
Kailin