# Expected value from a regression table

My question is related to the discussion that take place in this post. The question is: how can I compute the expected values of conditions GroupB/Cond2 and GroupB/Cond3 in that case?

I know that GroupA/Cond1, 2 and 3 are calculated from coef A (6.1372) + coefs from conditions 1, 2 and 3) and I know that GroupB/Cond1 is calculated from coef B (6.0758).

The problem is that the coefficients from the R output to GroupB/Cond2 is -0.1055. So, the number in the table should be 6.1913 (6.0758 + 0.1055), but it is 6.0853. Similarly with GroupB/Cond3: it should be 6.1758 (6.0758 + 0.1000), but it is 6.1149. I don't understand that difference. Is there an error in the table or is it that I really don't understand how to calculate the values?

In other words, my question is about how to calculate the coefficients for the interactions terms in the lmer function output from R.

---------------------------------
Group

A - 6.1372
B - (6.1372 - 0.0614) = 6.0758
---------------------------------

Condition

1 - (6.1372)
2 - (6.1372 + 0.1150) = 6.2522
3 - (6.1372 + 0.1000) = 6.2372

---------------------------------
Interactions

A1 (6.1372)          = 6.1372
A2 (6.1372 + 0.1150) = 6.2522
A3 (6.1372 + 0.1000) = 6.2372

---------------------------------

B1 (6.0758) = 6.0758
B2 (6.0758 + ??????) = 6.0853
B3 (6.0758 + ??????) = 6.1149

---------------------------------
• Igor, I have made a few minor edits to your post; you should check it still says what you intend. Your signature has also been removed; please see this section of the faq – Glen_b -Reinstate Monica Jun 1 '13 at 15:15
• Hi, @Glen_b. I'm trying to do things the right way, but it seems it is hard. Sorry! Thank you for the tips and patiente. – Igor Costa Jun 1 '13 at 15:37

Here are the estimates from the above post again for reference:

Estimate MCMCmean HPD95lower HPD95upper  pMCMC Pr(>|t|)
(Intercept)                          6.1372   6.1367     6.0418     6.2299 0.0005   0.0000
groupB                              -0.0614  -0.0602    -0.1941     0.0706 0.3820   0.3880
condition2                           0.1150   0.1151     0.0800     0.1497 0.0005   0.0000
condition3                           0.1000   0.1004     0.0633     0.1337 0.0005   0.0000
groupB:condition2                   -0.1055  -0.1058    -0.1583    -0.0610 0.0005   0.0000
groupB:condition3                   -0.0609  -0.0612    -0.1134    -0.0150 0.0170   0.0148

First, let's understand what the estimates mean. Note that the variables are all dummy variables (1 if "true", 0 otherwise). Intercept is the expected value for group A in condition 1 - this is because it's the combination that is omitted; all other combinations can be "reached" with a combination of several of the available coefficients. For example, if we wanted the expectation of group A condition 2, we would use Intercept+condition2. Condition2 is $E[gA,c2]-E[gA,c1]$, so we add this to the Intercept: $E[gA,c2]-E[gA,c1]+Intercept=E[gA,c2]$ (because $Intercept=E[gA,c1]$).

Now we want the expected value of GroupB/Cond2. What we need to do is to add everything that takes value 1 in observations of this combination. The intercept is always 1, groupB and condition2 is 1 (because both are part of the combination we want), and because both of these are 1 simultaneously, so is the interaction groupB:condition2 (easier to see if written as groupB*condition2 - this is 1 if and only if both factors are 1). Now we just need to add all those coefficients, and we arrive at $$E[gB,c2]=6.1372-0.0614+0.115-0.1055=6.0853,$$ exactly as in the table.

You didn't arrive there because you neglected condition2 in your calculation. All coefficients except for the Intercept are relative to some reference category. condition2 is the effect in group A relative to gA/c1, and groupB:condition2 is the effect of condition 2 on group B relative to the effect of condition 2 on group A. So to get from gA/c1 to gB/c2, you need to add to the Intercept condition 2 to get $E[gA,c2]$; then you add both groupB and the interaction simultaneously, because you basically switch two things at once: group and the way condition2 affects the expectation (this effect differs by group).