Announcement

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

  • mixed model regression with different hierarchical levels

    I have this data and would like to conduct a mixed model analysis to determine the following:

    Effect of individual capacity measures on survival in each of the treated groups
    Effect of median capacity measures on survival in each of the treated groups

    I would also like to be able to graph this data if possible. In my real data, visit days can be up to 20 visits with corresponding measures. There are no missing values for any of the subjects.

    ----------------------- copy starting from the next line -----------------------
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input byte(id visitday treat D capacity1 capacity2 capacity13 died)
    30 1 0 . 22 32 30 1
    30 2 0 . 23 34 55 1
    30 3 0 . 28 28 43 1
    30 4 0 . 25 33 40 1
    44 1 1 .  6  4 10 0
    44 2 1 . 10  9 12 0
    44 3 1 .  6  8  8 0
    28 1 1 . 10  5  8 0
    28 2 1 . 11 12  9 0
    28 3 1 .  8 13 10 0
    28 4 1 .  9  8  6 0
    28 5 1 .  7  8  9 0
    28 6 1 . 11  8 10 0
    end
    ------------------ copy up to and including the previous line --------------


    The code I am using is

    ----------------------- copy starting from the next line -----------------------
    Code:
    xtmixed capacitymedian treat#visitday || id:
    ------------------ copy up to and including the previous line ------------------


    But this gives me the calculation for each individual visit. What I would like to compare is the treated groups and their differences in survival to see whether survival is improved in the treated groups with higher capacity values.
    Last edited by May Blake; 24 Oct 2022, 08:12.

  • #2
    In Stata's factor variable notation, if you don't apply any prefix to a variable that appears in an interaction term, Stata treats it as a categorical variable. That is why you are getting separate results for each value of visitday (except one which will be omitted as the reference value). To get visitday treated as a continuous variable, so you will get a single output for it, you need to prefix it with -c.-. Do read -help fvvarlist- before proceeding so you fully understand what you are specifying in your code. I also think when you finish reading that, you will realize that you are better off using the ## rather than the # operator in your interaction. So in short, I think the interaction term needs to be -i.treat##c.visitday-.

    Studying survival with a linear probability model on a dichotomous time-invariant ultimately survived/died outcome is suboptimal. If this is the best data you can get, then you work with what you have. But a much better approach would be to have information on when the person died, or, if unknown, the last date they were observed to be alive, and then use survival analysis techniques like -stcox-.

    I also note that your code refers to a variable capacitymedian that does not appear in your data set, or at least it does not appear in your example data.

    Finally, though it is harmless to use it, the name -xtmixed- has been obsolete since version 13. So unless you are using an ancient version of Stata, you should start calling the command by its current name: -mixed-.
    Last edited by Clyde Schechter; 24 Oct 2022, 15:27.

    Comment

    Working...
    X