Hello all,
That's my first post in here, so let me know if I do something wrong. Well, my problem is the following.
I am fitting a linear multilevel model of the following form:
The units in the first level are 10000 students and the clusters of the second level are 30 schools.
So, what I am trying to do is to plot each of the 30 versions of `b3`, i.e. the random effects slope of each cluster. I also need to plot that if confidence intervals of any type.
In R, I know how to do it. Assuming the model fitted is saved in the `mymodel` object, one can get the random + fixed effects of a multilevel model in R as follows:
In the end, each column of `myranef` represents one of the 30 schools and each line is one of the 1000 simulation-iterations. From then on, it's easy to make the plot using the mean or median of each col and the desired percentiles of each col.
My problem is how to achieve a similar thing in Stata. I guess I should start by doing the following:
However, then I don't know how to:
1) get the combined version of random and fixed effects for each of the 30 schools
2) get a version with confidence intervals of some sort
Would anyone be able to kindly shed some light on how to proceed in Stata similarly to what I have in R?
That's my first post in here, so let me know if I do something wrong. Well, my problem is the following.
I am fitting a linear multilevel model of the following form:
Code:
Y = b0 * X0 + b1 * X1 + b2 * X2 + b3 * X3 + u b0 = e0 b3 = e3
So, what I am trying to do is to plot each of the 30 versions of `b3`, i.e. the random effects slope of each cluster. I also need to plot that if confidence intervals of any type.
In R, I know how to do it. Assuming the model fitted is saved in the `mymodel` object, one can get the random + fixed effects of a multilevel model in R as follows:
Code:
#This will extract simulated random effects from the model: myranef <- ranef(arm::sim(mymodel, 1000)) myranef <- as.data.frame(myranef) myranef <- myranef[,grep("X3",colnames(bb))] #This will extract simulated fixed effects from the model: myfixef <- as.data.frame(fixef(arm::sim(mymodel, 1000))) names(myfixef) <- names(fixef(mymodel)) #Sum random and fixed effects for(c in 1:ncol(myranef)){ myranef[,c] <- myranef[,c] + myfixef[,"X3"] }
My problem is how to achieve a similar thing in Stata. I guess I should start by doing the following:
Code:
predict re*, reffects // linear predictor for the random effects predict fe, xb // linear predictor for the fixed effects
1) get the combined version of random and fixed effects for each of the 30 schools
2) get a version with confidence intervals of some sort
Would anyone be able to kindly shed some light on how to proceed in Stata similarly to what I have in R?
Comment