[R-sig-ME] pooled within-cluster regression line
Simon Harmel
@|m@h@rme| @end|ng |rom gm@||@com
Tue Oct 27 08:37:13 CET 2020
Dear All,
Top panel of Figure 3 of this open access paper (see **link below**) shows
3 clusters of datapoints, each with five datapoints.
The authors note:
> "The dotted line represents the regression of well-being (y) on workload
(x) within each cluster (i.e., the pooled within-cluster regression,
Beta_w)".
Say I have the hypothetical data blow with 3 clusters (`group`). How can I
find and draw the **the pooled within-cluster, $\beta_w$** regression line?
THE LINK: (
https://www.researchgate.net/publication/6274186_Centering_Predictor_Variables_in_Cross-Sectional_Multilevel_Models_A_New_Look_at_An_Old_Issue
)
## R code: ---------------------------------------------------
set.seed(2)
pop_mean <- 80
n_groups <- 3
groups <- gl(n_groups, 5)
x <-rnorm(length(groups), 55, 15)
Z <-model.matrix(~groups-1)
group_means <-rnorm(n_groups, 0, 2.5)
y <- pop_mean + -.3*x + Z%*%group_means + rnorm(length(groups), 0, 2)
data <- data.frame(y, groups, x)
[[alternative HTML version deleted]]
More information about the R-sig-mixed-models
mailing list