Announcement

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

  • Need help with random slope models in Stata

    Hello everyone,

    right now I am struggling a bit with a task I want to do.

    To keep it short, I want to calculate a random effects model that measures the variance of slopes between countries (sample contains 29 countries) in clusters of countries (4 clusters in total). As far as I understand it, I should use an xtmixed model. I have the following variables
    • "trust" (coded 1-30),
    • "cluster" represents the 4 clusters the countries are sorted into,
    • "cid" is the country ID,
    • "cnt_se_mean" is a value that is aggregated with a pick-one variable, so I only have 29 observations in that variable (one mean per country).
    Unfortunately, I am making a mistake, and I don't really understand the problem.

    Following you can see the code in which I try to do the calculation of the between-country variance within cluster 4.

    The code I have is:
    Code:
    xtmixed trust i.cluster || cid: cnt_se_mean if cluster == 4, mle
    I also tried it without the if condition:
    Code:
    xtmixed trust ib4.cluster || cid: cnt_se_mean, mle
    However, here the problem arises that Stata only calculates the effects between the countries but doesn't distinguish between clusters.

    Can you help me with this problem? How could a code look like, that enables me to calculate the variance of the random slopes for the variable "cnt_se_mean" for all countries in one specific cluster?


    Thank you very much for your help!

    Best regards
    Philipp Weimer
Working...
X