My intution tells me that the following is a straight forward question, but I could not find relevant answers when I searched for it. I assume the reason for that is that I don't know the relevant terms, so I would appreciate some guidance in this respect.
Let's say we have used a sample $\{y_i, x_i\}_{i=1}^n$ to estimate a linear model, and the regression coefficient of the variable of interest is $\hat\beta$.
Let's say our sample consists of two groups of individuals, $A, B$. I would like to decompose $\hat\beta$ into the relative contributions of $A$ and $B$. Note that this is not about groups of regression coefficients (for which there are many decomposition techniques), but about groups of individuals in the data.
To see what I mean, consider:
$\hat\beta = \frac{\sum_i (x_i-\bar x)(y_i-\bar y) }{\sum_i (x_i-\bar x)^2}$
I would like to end up with a formula along the lines of
$\hat\beta = \phi_A \hat\beta_A + \phi_B \hat\beta_B$
where $\phi$ is the relative share in the sample (if neccessary), and $\hat\beta_X$ is the relevant contribution of group $X$ to $\hat\beta$.
If we expand the summation into two sums for each group, we are still left with the overall denominator and I am not sure what to do with the grand mean. At the same time, this should be a standard question and does not seem too hard intuitively. Anyone care to chime in to enlighten me? Any hints greatly appreciated!