Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • 2-way cluster using logit2 by Peterson - way to get marginal effects?

    My question is similar to one that was posted a while back but unanswered: http://www.stata.com/statalist/archi.../msg00196.html

    I am using the logit2 ado file by Peterson (at http://www.kellogg.northwestern.edu/...rogramming.htm) to 2-way cluster on a dataset of ~15,000 observations with 50 binary variables in Stata 14.1; however, I am unable to use the margins command following logit2. Error: e(sample) does not identify the estimation sample. Does anyone have suggestions?

    Also, is there a way to get the ORs to display with logit2 (other than manually exponentiating the coefficients). Currently, I get an error that the OR option is not allowed. Thanks in advance.


  • #2
    Monica Aswani I came across this thread as I encountered the same problem. As it stands, logit2 does neither provide marginal effects nor associated standard errors. The first point is no problem because marginal effects are unaffected by the choice of the clustering option. However, the second point is worth discussing.

    I looked up Jingling Guan's and Mitchell Petersen's logit2 ado-file from the link you posted to learn that what they do to find the variance-covariance matrix of the estimators can be summarized by the three-step procedure also explained in Cameron/Gelbach/Miller (Robust Inference with Multi-way Clustering):
    1. Run the logit model with errors clustered on the first dimension and save the variance-covariance matrix of the estimators: e(V).
    2. Rerun the same model with errors clustered on the second dimension and save the variance-covariance matrix of the estimators: e(V).
    3. Rerun the same model again with errors now clustered on the interaction of the two cluster dimensions and save the variance-covariance matrix of the estimators: e(V).
    Your final estimator is the sum of the first two matrices minus the third (see Cameron/Gelbach/Miller for details). You can do each of these steps "by hand", running logit with the one-dimensional cluster option. Sidenote: In case, the final matrix is not positive-definite Cameron, Gelbach and Miller provide also a simple solution.

    To finally arrive at the standard errors for the marginal effects you apply the Jacobian to the beforementioned matrix. Since the Jacobian is unchanged by your clustering you can obtain it by running margins after logit and extracting it from memory:
    Code:
    logit yvar xvar1 i.xvar2
    margins, dydx(*)
    matrix Jac = r(Jacobian)
    Put this together with your variance-covariance matrix of the estimators:
    Code:
    matrix rV = Jac*varest*Jac'
    and the square root of the diagonal elements should give the according standard errors.

    At the moment, logit2 would stop with an error when your logit model contains factor variables. But from my understanding the three-step-procedure does also apply to these cases. If anyone has a different opinion on that I would be happy to know.

    Comment


    • #3
      Dear Roberto Liebscher , can you please explain how can we execute this three step pcoedure in stata? I am unabale to save e(V) of the three models separately in stata memory and also the final step you mentioned.
      Thank you in advance.

      Comment


      • #4
        Zahid Khan: You can use the -vcemway- command (which you can download by typing -ssc install vcemway-) and estimate a logit model with two-way clustered standard errors by typing something like -vcemway logit y x, cluster(id1 id2)-. A background paper for the -vcemway- is available at this link.

        Comment


        • #5
          Dear Hong Il Yoo thank you very much for your response. It really worked the way i wanted. I was able to use https://www.kellogg.northwestern.edu...rogramming.htm for two clustering but for some reasons I was not able to get standard error for when calculating marginal effects. However now I have got them with your coding.
          Thank you again.

          Comment

          Working...
          X