Announcement

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

  • -xtdpdml- questions about vce() and wide vs.long

    Dear Statalisters:

    I have been using the -xtdpdml- user-written command by Richard Williams, Paul Allison, and Enrique Moral-Benito. I'm a big fan of it, but I've been having some trouble specifying the vce() option.

    First, running a model with vce(robust) works fine. So if I have syntax that goes:

    Code:
    xtdpdml y, pre(x1 x2 x3)  vce(robust)
    Everything works perfectly.

    However, if I try to specify a cluster-robust standard error, like this, I get an error code:
    Code:
    xtdpdml y, pre(x1 x2 x3)  vce(cluster clvar)
    variable clvar not found
    If I try to bootstrap a cluster variable:
    Code:
    xtdpdml y, pre(x1 x2 x3)  vce(bootstrap, cluster(clvar))
    variable clvar not found
    (error in option cluster())
    If I recall correctly, the code for the vce(bootstrap, cluster) option is different in the command than if you run it before. I also tried it like this, and I got a different error message:
    Code:
    bootstrap, cluster(clvar): xtdpdml y, pre(x1 x2 x3)
    .........repeated time values within panel
    the most likely cause for this error is misspecifying the cluster(), idcluster(), or group()
    option
    In any case, if I reshape it to wide and run it with wide option, like this:
    Code:
    xtdpdml y, pre(x1 x2 x3) showcmd wide
    I get the same estimates for everything when it works, and it doesn't work in the same places as before. So that code is doing the same thing as when it's long.

    I decided that the best option was just to convert everything using the showcmd option because I know how to specify the different standard error options with the -sem- command. However, a strange thing happened when I tried to replicate the findings using this:
    Code:
    sem (y2 <- y1@b1 x1_2@b2 x2_2@b3 ///
        x3_2@b4 Alpha@1 E2@1 ) (y3 <- y2@b1 ///
        x1_3@b2 x2_3@b3 x3_3@b4 Alpha@1 E3@1 ) (y4 <- ///
        y3@b1 x1_4@b2 x2_4@b3 x3_4@b4 Alpha@1 ), ///
        var(e.y2@0 e.y3@0) var(Alpha) ///
        cov(Alpha*(E2 E3)@0 _OEx*(E2 E3)@0 E2*(E3)@0 x1_3*(E2) ///
        x2_3*(E2) x3_3*(E2) x1_4*(E2 E3) x2_4*(E2 E3) ///
        x3_4*(E2 E3)) iterate(250) technique(nr 25 bhhh 25) noxconditional
    This gives me slightly different estimates than when I used the "wide" option and basic syntax. It's not different enough for there to be any substantive differences, but it is enough that I noticed it. So while these are probably sensible settings, it does appear they are slightly different than the ones taken in the basic xtdpdml command.

    For what it works, this code:
    Code:
    bootstrap, cluster(schoolname): sem (y2 <- y1@b1 x1_2@b2 x2_2@b3 ///
        x3_2@b4 Alpha@1 E2@1 ) (y3 <- y2@b1 ///
        x1_3@b2 x2_3@b3 x3_3@b4 Alpha@1 E3@1 ) (y4 <- ///
        y3@b1 x1_4@b2 x2_4@b3 x3_4@b4 Alpha@1 ), ///
        var(e.y2@0 e.y3@0) var(Alpha) ///
        cov(Alpha*(E2 E3)@0 _OEx*(E2 E3)@0 E2*(E3)@0 x1_3*(E2) ///
        x2_3*(E2) x3_3*(E2) x1_4*(E2 E3) x2_4*(E2 E3) ///
        x3_4*(E2 E3)) iterate(250) technique(nr 25 bhhh 25) noxconditional
    Works perfectly, except that it has the slightly different parameter estimates as before.

    I think that there are two ways to solve this. One solution is to figure out why xtdpdml seems unable to handle cluster variables. The other possible solution is to figure out why the showcmd option gives what must be slightly different code than what xtdpdml is using.

    Thanks for reading this. I'm stumped and would love to hear some input.

    Best,
    Jonathan
    Last edited by Jonathan Horowitz; 23 Nov 2023, 08:59. Reason: vce

  • #2
    Update: It appears that xtdpdml is dropping a few extra cases compared to the sem output it produces. This accounts for the discrepancy.

    Does anyone know how to fix this in a more elegant way than tagging the missing data and dropping it before running?

    Thanks,
    Jonathan

    Comment


    • #3
      There is an undocumented option in xtdpdml called othervars, or other for short. I added this because a few commands, like svy, may require you to use a time-invariant variable that is not part of the model, which would be the case here. So, you would do something like

      Code:
      xtdpdml y x ..., vce(cluster clvar) other(clvar)
      I haven't actually tested this so let me know if it works.

      An example of othervars being used with svy is at https://www3.nd.edu/~rwilliam/dynami...vy_xtdpdml.pdf

      I don't know if this solves every problem mentioned. If not, let me know what problems remain.

      This issue never got mentioned for years, and now it has come up twice in the last month -- I guess I should break down and turn othervars into a documented option!

      EDIT: With regards to the Ns being a little different, it might be because of missing data on clvar.
      Last edited by Richard Williams; 23 Nov 2023, 21:04.
      -------------------------------------------
      Richard Williams, Notre Dame Dept of Sociology
      StataNow Version: 19.5 MP (2 processor)

      EMAIL: [email protected]
      WWW: https://academicweb.nd.edu/~rwilliam/

      Comment


      • #4
        This othervars option would be helpful to me in a number of ways, so it's good to know about it.

        It appears that using othervars fixes the problem with cluster robust standard errors. If I bootstrap using something like:

        Code:
        bootstrap, cluster(clvar):
        I still get some weird errors, but that might be a problem with using prefixes on it specifically. Using it in the vce() freezes Stata entirely, but that could be due to the difficulty of the model.

        Comment


        • #5
          I’ve never tried bootstrap like this. I have a feeling it would be painfully slow, if it ran at all. If you really really really want to use it, you might start with a simpler model and, if it runs ok, gradually add variables to it.
          -------------------------------------------
          Richard Williams, Notre Dame Dept of Sociology
          StataNow Version: 19.5 MP (2 processor)

          EMAIL: [email protected]
          WWW: https://academicweb.nd.edu/~rwilliam/

          Comment

          Working...
          X