Announcement

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

  • xtmixed random slope Model

    Hello everyone,

    I want to calculate a random effects model that measures the variance of slopes between countries (the sample contains 29 countries) in clusters of countries (4 clusters in total). The idea behind the model is to measure the effect of different values (10 values by Shalom Schwartz) on trust in institutions for each country in one specific cluster.

    The relevant variables are:
    • "trust" (coded 1-30)
    • "cluster" (coded 1-4), representing the 4 clusters the countries are sorted into
    • "cid" (the country ID, 29 countries)
    The 10 values:
    • security
    • hedonism
    • benevolence
    • power
    • achievement
    • conformity
    • tradition
    • self-direction
    • stimulation
    • universalism
    These variables also exist as aggregated country mean variables:
    • cnt_se_mean
    • cnt_he_mean
    • cnt_be_mean
    • cnt_po_mean
    • cnt_ach_mean
    • cnt_co_mean
    • cnt_tr_mean
    • cnt_sd_mean
    • cnt_st_mean
    • cnt_un_mean
    When I want to calculate a random slope but fixed intercept model, I need to fix the intercepts but let the slopes remain random. For this, I want to use an xtmixed model.

    Do I need the aggregated values for this? If not, the model for Security in Cluster 4, not taking the fixed intercepts into account, would look like this, correct?

    Code:

    xtmixed trust || cid: security if cluster == 4, cov(uns)


    Then, when I want to include the fixed intercepts, I need to fix them in the model. As far as I understand it, I need to include them before the "||". So it would look like this:

    Code:

    xtmixed trust security || cid: security if cluster == 4, cov(uns)


    However, the values seem a bit high, and I am not sure if I did it the right way. Does it make sense to include the same variable in the fixed and the random part of the xtmixed model?

    Any help with my model is highly appreciated!


    Thank you very much for your help!

    Best regards,
    Philipp Weimer

  • #2
    I'm not sure I understand exactly what you are trying to do here. But let me just clarify the workings of random slopes in these models.

    When you run a model like this*
    Code:
    mixed outcome_variable ind_vars focal_variable || grouping_variable: focal_variable, cov(whatever)
    the coefficient of focal_variable in the fixed effects output will be the expectation (across the values of the grouping_variable) of the slope of the outcome variable: focal variable relationship. In the random effects output, the results in the focal variable row will give you the variance across the values of the grouping variable of the slope of the outcome variable.

    If, by contrast, you run:
    Code:
    mixed outcome_variable ind_vars  || grouping_variable: focal_variable, cov(whatever)
    Stata will estimate the slopes of the outcome variable:focal variable relationships for each value of the grouping variable subject to the constraint that the mean slope is zero. Unless you have reason to expect that the mean slope is, indeed, 0, you are imposing a counterfactual constraint on your model and your results will be incorrect.

    I do not know what you mean when you say "I need to fix the intercepts but let the slopes remain random." If you mean that you want the random intercepts at the grouping variable level to be constrained to be 0, the way to code that is:
    Code:
    mixed outcome_variable ind_vars  focal_variable || grouping_variable: focal_variable, noconstant cov(whatever)
    I hope this helps.


    *-xtmixed- was renamed to -mixed- back around version 13. If you code it as -xtmixed- Stata will still use -mixed- and everything works out OK, but this is not always true for other commands. For example, -xtmelogit- will not lead you to -melogit- but to -meqrlogit-. Probably that wouldn't be a serious problem, but my general point is that you should use the terminology that is current to your Stata version. I suggest you run -help xtmixed- in your Stata. If your version is recent enough, as I suspect it will turn out to be, the very first thing in the help file will be a sentence telling you how it has been renamed.

    Comment

    Working...
    X