# Codification of Matrix $X$ in $Y=XB+\epsilon$

The variables for the data below is age, group (treatment 1,2,3), Y response variable.

\begin{bmatrix}60&1&5.5\\57&2&4.5\\59&3&8.1\\68&1&0.6\\67&2&1.9\\68&3&4.3\\79&1&0.6\\80&2&3.4\\75&3&4.4\end{bmatrix}

Write the equation of a model to explain the Y's behavior according to the different treatment groups . Explicitly define $X$ and $B$ interpreting the parameters and using the encodings (cell means model,offset from reference group, differential effect )

The model is $$Y=XB+\epsilon$$

I already found a litle about that Matrix Design, but I don't understand well.

For differential effect for example I found that matrix is $$\begin{bmatrix}1&1&0&60&60&0\\1&1&0&68&68&0\\1&1&0&79&79&0\\1&0&1&57&0&57\\1&0&1&67&0&67\\1&0&1&80&0&80\\1&-1&-1&59&-59&-59\\1&-1&-1&68&-68&-68\\1&-1&-1&75&-75&-75\\\end{bmatrix}$$

$$B=\begin{bmatrix}B_1\\B_2\\B_3\\B_4\\B_5\\B_6\end{bmatrix}$$

where

$B_1$:intercept for mean of groups

$B_2$:differential effect in intercept in Group 1

$B_3$:differential effect in intercept in Group 2

$B_4$:slope of groups

$B_5$:differential effect in slope in Group 1

$B_6$:differential effect in slope in Group 2

what are the interpretations of the model parameters for different types of matrix coding?

From where comes the interpretation of the model parameters?

• This seems a lot like a self-study question. Please tag it as such if it is.
– sheß
Apr 15, 2016 at 9:13

Alternative parametrization with heterogeneous treatment effects

The solution you propose allows for heterogeneous treatment effects, which is good and should probably be the default, but what the "right" choice is depends on what you want to study. In your case, age is allowed to affect the outcome differently by treatment group [or treatment affects the outcome differently by age]. If that is what you want to study, this is the way to go. You could however still parametrize your model in a slightly different way, which would lead to a different interpretation of coefficients.

Model: $$Y=XB+\epsilon$$

$$X = \begin{bmatrix}1&1&0&60&60&0\\1&1&0&68&68&0\\1&1&0&79&79&0\\1&0&1&57&0&57\\1&0&1&67&0&67\\1&0&1&80&0&80\\1&0&0&59&0&0\\1&0&0&68&0&0\\1&0&0&75&0&0\\\end{bmatrix}$$

$$B=\begin{bmatrix}B_1\\B_2\\B_3\\B_4\\B_5\\B_6\end{bmatrix}$$

where

$B_1$: Mean outcome (intercept) for Group 3 (reference group)

$B_2$: Difference in mean for Group 1 (to reference group)

$B_3$: Difference in mean for Group 2 (to reference group)

$B_4$: Slope (of age) in Group 3 (reference group)

$B_5$: Difference in slope for Group 1

$B_6$: Difference in slope for Group 2

UPDATE: Where do these interpretations come from?

Note that the equation implies on the individual level: \begin{align}y_i &= B_1 + B_21_{(group_i=1)} + B_31_{(group_i=2)}\\ &+ B_4age_i + B_51_{(group_i=1)}age_i+ B_61_{(group_i=2)}age_i+\epsilon_i\end{align} where $1_{(group_i=j)}$ is a dummy taking the value 1 if observation i belongs to group j. Now you can check how the line looks (slope and intercept) for each group: \begin{align}E[y|group=1] &= B_1 + B_21 + B_30 + B_4age_i + B_51age_i+ B_60age_i\\&=(B_1+B_2) + (B_4+B_5)age\end{align} Similarly \begin{align} E[y|group=3] &= B_1 + B_20 + B_30 + B_4age_i + B_50age_i+ B_60age_i\\&=B_1 + B_4age\end{align} Hence the slope and intercept for observations of group 3 are $B_4$ and $B_1$ respectively. And if you add $B_5$ and $B_2$ you get the line for observations of group 1.

Constant treatment effect

An alternative approach would possible if you assume that age does not interact with the treatment. In this case you would/could use age only as a control variable (i.e. to filter out what would otherwise be noise in your regression).

Model: $$Y=XB+\epsilon$$

$$X = \begin{bmatrix}1&1&0&60\\1&1&0&68\\1&1&0&79\\1&0&1&57\\1&0&1&67\\1&0&1&80\\1&0&0&59\\1&0&0&68\\1&0&0&75\\\end{bmatrix}$$

$$B=\begin{bmatrix}B_1\\B_2\\B_3\\B_4\end{bmatrix}$$

where

$B_1$: Mean outcome (intercept) for Group 3 (reference group)

$B_2$: Difference in mean for Group 1 (to reference group)

$B_3$: Difference in mean for Group 2 (to reference group)

$B_4$: Average slope of age (across groups)

Other models...

...are possible, but that really depends on finer details of the question you want to answer. E.g. using higher polynomials for age (to allow for non-linear effects).

– user72621
Apr 15, 2016 at 21:25
• I can not tell how advanced you are from your question. If you need a primer in matrix algebra a good start could be Simon and Blume's "Mathematics for Economists". If you want to better understand the interpretation of regression equations, I suggest to start with one of the Wooldridge textbooks (econ.msu.edu/faculty/wooldridge)
– sheß
Apr 16, 2016 at 9:35
• @PRAGAKHAM, Is there anything amiss with the answer? Please let me know if I'm overlooking or misinterpreting part of your question.
– sheß
Apr 17, 2016 at 22:34
• Taking your first model as example, why $B_1$ is Mean outcome (intercept) for Group 3 (reference group)? How you see it?
– user72621
Apr 20, 2016 at 0:08
• Thanks for clarifying. Since you already had that X-matrix in your question, I assumed you knew how it was composed. I edited and hopefully clarified my answer. Please let me know if anything is still unclear.
– sheß
Apr 20, 2016 at 5:31