Announcement

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

  • Longitudinal mixed models

    I am attempting to write a do file for a longitudinal mixed model, where I have (n=1000) participants with measurements at 2 distinct time points. I want to see the effects of a change in my exposure from the first to the second test to the outcome variable at the second test.

    My current code reads:

    mixed outcome i.exposure confounder confounder confounder || Patient_ID:

    the code starts to run but I get this output for hundreds and hundreds of iterations. It actually still hasnt stopped.
    Iteration 0: log likelihood = -337.23526 (not concave)
    Iteration 1: log likelihood = 4706.0132 (not concave)
    Iteration 2: log likelihood = 4706.0654 (not concave)
    Iteration 3: log likelihood = 4706.0769 (not concave)
    Iteration 4: log likelihood = 4706.077 (not concave)
    Iteration 5: log likelihood = 4706.077 (not concave)
    Iteration 6: log likelihood = 4706.077 (not concave)

    I get the feeling there is a mistake in my coding so was hoping for some advice.

    Kind regards

    Adam


  • #2
    Do this:
    Code:
    xtreg outcome i.exposure confounder confounder confounder, i(Patient_ID) fe
    Time-invariant confounders don't confound here, so they can be omitted, and Stata will omit them automatically with this estimation command.

    TIme-varying confounders must not covary closely with your exposure indicator variable. If they do, hope that Stata drops one or the other as collinear. Otherwise, you're liable to get inflated standard errors.

    But you won't get convergence problems, because this estimation command is noniterative.

    Comment


    • #3
      I tried to use this code but got this error:

      no; data are mi set
      Use mi xtset to set or query these data; mi xtset has the same syntax
      as xtset.

      Perhaps you did not type xtset. Some commands call xtset to obtain
      information about the settings. In that case, that command is not
      appropriate for running directly on mi data. Use mi extract to select
      the data on which you want to run the command, which is probably m=0.

      So I tried alternative code:

      mi xtset, xtreg BMP6_5y i.frailty_change education_level_bl bmi_BL smoke_s
      > tatus_BL time_between_exams_5, i(Patient_ID) fe

      but got this error

      invalid 'i'.

      I tried moving things around but cannot get a code to work.


      Comment


      • #4
        Code:
        mi extract 0
        xtreg outcome i.exposure confounder confounder confounder, i(Patient_ID) fe

        Comment


        • #5
          Now I get this error message

          no; data in memory would be lost

          Comment


          • #6
            Code:
            mi extract 0, clear
            xtreg outcome i.exposure confounder confounder confounder, i(Patient_ID) fe

            Comment


            • #7
              I still get no results... all my variables are omitted for collinearity...

              Comment


              • #8
                Originally posted by Adam Mitchell View Post
                I still get no results... all my variables are omitted for collinearity...
                I don't see how that's possible. If you have collinear predictors, then all but one would be omitted. And then you would still get results for that one predictor.

                Maybe you should just attach your dataset, and a do-file of what you're trying to do.

                Comment

                Working...
                X