Stratum-varying fixed effects
Assume we have three strata, \(s_0\) , \(s_1\) , and \(s_2\) , where \(s_0\) is the “reference” stratum – in other words, \(s_0\) is the stratum for which the 0/1 indicator is 0 across the board in the indicator matrix below (the first row):
\[\begin{bmatrix} 1 & 0 & 0 \\ 1 & 1 & 0 \\ 1 & 0 & 1 \end{bmatrix}\]B_0 + (B_1 + B_1_s1_offset * s1 + B_1_s2_offset * s2) * x_1
# in stratum s0
B_0 + (B_1) * x_1
# in stratum s1
B_0 + (B_1 + B_1_s1_offset * s1) * x_1
# in stratum s2
B_0 + (B_1 + B_1_s2_offset * s2) * x_1
# lm(y~x1*x2)
model.matrix(~x1*x2, tibble(x1 = runif(5), x2 = runif(5)))