Announcement

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

  • gsem command errors: 1) cannot compute an improvement -- discontinuous region encountered; 2) convergence not achieved.

    Hi everyone,

    I met some errors when trying to run a gsem model for 5 simultaneous equations with random coefficients for each individuals.

    The panel data has around 25 independent variables (including continuous variables, categorical variables, and factors). One of the IV has around 7000 dummies. I allowed for random coefficients for 3 main IVs. There are around 40,000 observations.

    The command that I used is similar as below:

    gsem (DV1 <-IV1 IV2 IV3...i.IV24 i.IV25 c.IV1#M1[ID] c.IV2#M1[ID] c.IV3#M1[ID]) ///
    gsem (DV2 <-IV1 IV2 ...i.IV24 c.IV1#M1[ID] c.IV2#M1[ID] c.IV3#M1[ID]) ///
    gsem (DV3 <-IV1 IV2 ...i.IV24 c.IV1#M1[ID] c.IV2#M1[ID] c.IV3#M1[ID]) ///
    gsem (DV4 <-IV1 IV2 ...i.IV24 c.IV1#M1[ID] c.IV2#M1[ID] c.IV3#M1[ID]) ///
    gsem (DV5 <-IV1 IV2 ...i.IV24 c.IV1#M1[ID] c.IV2#M1[ID] c.IV3#M1[ID]), ///
    covstruct(e.DV1 e.DV2 e.DV3 e.DV4 e.DV5, unstructured)

    There are no latent variables in my model but I want to allow for heterogeneous effect on the main variables for each individual, that's why I added c.IV1#M1[ID] c.IV2#M1[ID] c.IV3#M1[ID] in the model.

    However, when I tried the code, I met some errors.

    First, when I run the entire model, I got errors like this:

    Click image for larger version

Name:	convergence not achieved.PNG
Views:	1
Size:	36.7 KB
ID:	1666974


    Then I dropped c.IV3#M1[ID] and tried again, this time i got errors like below:

    Click image for larger version

Name:	cant compute improvement.PNG
Views:	1
Size:	51.6 KB
ID:	1666975

    I wonder if anyone knows why this happened and how to fix these errors.

    Thank you!



  • #2
    Your model might be too ambitious, for example, with 7000 categories split among 40 000 observations it leaves fewer than six observations on average to estimate the parameter for each level of just that predictor. (And that doesn't take into account that these six are simultaneously divvied among the categories of whatever ID represents.)

    Moreover, you've specified three random slopes, but neglected to specify any corresponding random intercept.

    There are no latent variables in my model
    Those random slopes are latent variables, and if your manifest variables in your dataset are in upper case as you're showing, then you might be confusing Stata.

    With only three "main variables" among the 25 assorted explanatory variables, you might have room to simplify the model in order to promote its convergence without sacrificing too much in explanatory power. So, I suggest starting with
    Code:
    rename *, lower
    and proceeding with a somewhat more parsimonious model, something perhaps like
    Code:
    gsem (dv? <- c.(iv1 iv2 iv3) M0[id] c.iv1#M1[id] c.iv2#M2[id] c.iv3#M3[id]), ///
        covstructure(e.dv1 e.dv2 e.dv3 e.dv4 e.dv5, unstructured)
    in order to see whether you've got any chance to fit something more involved to your data. Even this could be simplified further if you still don't get convergence to a sensible set of coefficients.

    Comment


    • #3
      Originally posted by Joseph Coveney View Post
      Your model might be too ambitious, for example, with 7000 categories split among 40 000 observations it leaves fewer than six observations on average to estimate the parameter for each level of just that predictor. (And that doesn't take into account that these six are simultaneously divvied among the categories of whatever ID represents.)

      Moreover, you've specified three random slopes, but neglected to specify any corresponding random intercept.

      Those random slopes are latent variables, and if your manifest variables in your dataset are in upper case as you're showing, then you might be confusing Stata.

      With only three "main variables" among the 25 assorted explanatory variables, you might have room to simplify the model in order to promote its convergence without sacrificing too much in explanatory power. So, I suggest starting with
      Code:
      rename *, lower
      and proceeding with a somewhat more parsimonious model, something perhaps like
      Code:
      gsem (dv? <- c.(iv1 iv2 iv3) M0[id] c.iv1#M1[id] c.iv2#M2[id] c.iv3#M3[id]), ///
      covstructure(e.dv1 e.dv2 e.dv3 e.dv4 e.dv5, unstructured)
      in order to see whether you've got any chance to fit something more involved to your data. Even this could be simplified further if you still don't get convergence to a sensible set of coefficients.
      Hi Joseph,

      Thank you so much for your helpful suggestions. I'll try your code and see if it works.

      Additionally, I was able to use sureg command to run 5 equations simultaneously with all these ivs. However, I don't know how to specify random effect within the sureg command. I wonder if you know anything about this?

      Thanks alot.

      Comment


      • #4
        Originally posted by Melody Brown View Post
        I don't know how to specify random effect within the sureg command. I wonder if you know anything about this?
        I do not, not having used it as a habit. I suppose that if it's not described in the command's documentation, then it's likely to be either infeasible or ill-advised.

        Comment


        • #5
          Random coefficients is not the same model as random effects. You mention both, so you need to decide which of these you want and why.

          If you really want random effects, see this blog post: https://blog.stata.com/tag/random-effects/ .

          If instead you want to model random coefficients, you could obtain consistent estimates of each equation separately using e.g. -xtrc- on each of the five equations. (Failure to model cross-eqution correlation among disturbances, without other confounders, will not bias coefficient estimates.) A new and innovative random coefficient estimator for Stata is presented in this World Bank blog by Jeffrey Michler and Emilia Tjernstrom .

          If you believe correlation among the five error terms is important enough to model, an alternative to -sureg- which I believe can handle both random effects and random coefficients for a set of equations is David Roodman 's program -cmp- documented in Roodman (2011) and greatly expanded since then. Download and install it from SSC. The help file is extensive. Also Chris Baum has a great expository PPT here. Also see Roodman and Bartus (2014) and Bartus (2017).

          Comment


          • #6
            Originally posted by Joseph Coveney View Post
            I do not, not having used it as a habit. I suppose that if it's not described in the command's documentation, then it's likely to be either infeasible or ill-advised.
            Thanks for your reply Joseph!

            Comment


            • #7
              Originally posted by Mead Over View Post
              Random coefficients is not the same model as random effects. You mention both, so you need to decide which of these you want and why.

              If you really want random effects, see this blog post: https://blog.stata.com/tag/random-effects/ .

              If instead you want to model random coefficients, you could obtain consistent estimates of each equation separately using e.g. -xtrc- on each of the five equations. (Failure to model cross-eqution correlation among disturbances, without other confounders, will not bias coefficient estimates.) A new and innovative random coefficient estimator for Stata is presented in this World Bank blog by Jeffrey Michler and Emilia Tjernstrom .

              If you believe correlation among the five error terms is important enough to model, an alternative to -sureg- which I believe can handle both random effects and random coefficients for a set of equations is David Roodman 's program -cmp- documented in Roodman (2011) and greatly expanded since then. Download and install it from SSC. The help file is extensive. Also Chris Baum has a great expository PPT here. Also see Roodman and Bartus (2014) and Bartus (2017).
              Hi Mead,

              Thanks a lot for your suggestion. I'm trying the cmp command now. Hopefully, it can help me achieve what I want.

              Comment

              Working...
              X