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
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:
I also tried it without the if condition:
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
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).
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
Code:
xtmixed trust ib4.cluster || cid: cnt_se_mean, mle
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