# Interpreting intercept in multivariate linear regression when excluding some factors

This question may have already been asked, but I cannot find anything quite like what I am asking.

Background and model

I am using manyglm with a negative binomial distribution (from the package mvabund), a multivariate approach that takes a matrix of values as a response (species abundances as count data in this case). I wanted to determine the differences between two habitats (factor with two levels: log and litter) and also if they interacted with time of day (factor with two levels: day and night). However, there is a catch, because manyglm doesn't take random factors. My data spans two seasons and six sites, and so to account for that variation in some way, I included them as fixed effects in the model. All the predictor variables are thus categorical (no continuous variables), and are as follows (each factor is followed by a list of all levels in parentheses):

Habitat: factor with two levels (Litter and Log)
Time:  factor with two levels (Day and Night)
Site factor with six levels (D, G, H, K, L, N)
Season: factor with two levels (Spring, Autumn)


The final model looks like this:

species matrix ~ Habitat + Time + Season + Site.letter + Habitat:Time


To show the interaction effect of Habitat and Time on each species, I was planning to plot the coefficients for each Habitat:Time combination for each species (where significant). I am not interested in the effect size or exact estimates, only in the direction of change, hence the use of coefficients.

So, here are the coefficients from the model for one species:

                                                              Amphipoda
(Intercept)                                                 -3.06306004
HabitatLog                                                   0.27193202
TimeNight                                                   -0.37804705
SiteG                                                        1.09654160
SiteH                                                       -0.08874002
SiteK                                                        1.04800166
SiteL                                                       -1.04722016
SiteN                                                      -12.65469163
SeasonSpring                                                 1.69148980
HabitatLog:TimeNight                                         0.43371373


As is usual in R, each predictor variable is followed immediately by the factor level corresponding to the coefficient. Thus, the coefficient when Habitat=Log is 0.27193202.

The Problem

I understand (correct me if I am wrong) that to determine the coefficient of Litter at Night, I should add the coefficient for TimeNight to the intercept (which is LitterDay). Or is it? Is it actually HabitatLitter TimeDay SiteD SeasonAutumn?

In which case, adding the coefficients would only represent HabitatLitter TimeNight at SiteD in SeasonAutumn, which is fairly useless to me. How would I then determine the coefficient for HabitatLitter TimeNight without including the effect of Season and Site?

In addition, how do I compare the coefficients for HabitatLitter and HabitatLog, without any of the other variables?

• In your post, you have a Site.letter variable but then your question mentions Litter, which is confusing. Can you clean up the post to make it clear what variable(s) you are working with? Also, can you clarify what the other level of Time is? Is it Day? What are all the levels of Season and SiteLetter? Is HabitatLog continuous? – Isabella Ghement Jan 29 at 16:22
• I've cleared up the post a little. Site.letter (changed to Site) is the equivalent of subject in a clinical trial, so I am not interested its effect. The levels of Time are Day and Night, and the levels of Season and Site are in the list of predictor variables. Habitat is not continuous - it's a factor with two levels: Litter and Log. – Grubbmeister Jan 29 at 20:32

Are you modelling the log odds of presence of this particular species (i.e., Amphipoda)?

Then you can write out your model for the specific combinations of factors present in your model.

        Amphipoda
beta0 -> (Intercept)                                                 -3.06306004
beta1 -> HabitatLog                                                   0.27193202
beta2 -> TimeNight                                                   -0.37804705
beta3 -> SiteG                                                        1.09654160
beta4 -> SiteH                                                       -0.08874002
beta5 -> SiteK                                                        1.04800166
beta6 -> SiteL                                                       -1.04722016
beta7 -> SiteN                                                      -12.65469163
beta8 -> SeasonSpring                                                 1.69148980
beta9 ->  HabitatLog:TimeNight                                         0.43371373


Your model will look like this:

log (odds of species presence) = beta0 +
beta1*HabitatLog +
beta2*TimeNight +
beta3*SiteG +
beta4*SiteH +
beta5*SiteK +
beta6*SiteL +
beta7*SiteN +
beta8*SeasonSpring +
beta9*HabitatLog*TimeNight


(Disclaimer: I do not know what you are modelling on the left hand side of the above equation, but the right hand side of the equation will look exactly like what I listed here.)

The variables that appear in your model are all dummy variables. Specifically:

HabitatLog = 1 if Habitat = Log and 0 if Habitat = Litter;

TimeNight = 1 if Time = Night and 0 if Time = Day;

SiteG = 1 if Site = G and 0 for all sites other than G;

SiteH = 1 if Site = H and 0 for all sites other than H;

SiteK = 1 if Site = K and 0 for all sites other than K;

SiteL = 1 if Site = L and 0 for all sites other than L;

SiteN = 1 if Site = N and 0 for all sites other than N;

SeasonSpring = 1 if Season = Spring and 0 if Season = Autumn.


If you write out all possible combinations of levels for the factors Habitat, Time, Site and Season in your model, you will get 48 such combinations:

Habitat <- c("Litter","Log")
Time <- c("Day", "Night")
Site <- c("D", "G", "H", "K", "L", "N")
Season <- c("Spring", "Autumn")

combinations <- expand.grid(Habitat, Time, Site, Season)

combinations


Specifically, here are the 48 combinations:

Habitat Time Site Season

1  Litter   Day    D Autumn
2     Log   Day    D Autumn
3  Litter Night    D Autumn
4     Log Night    D Autumn
5  Litter   Day    G Autumn
6     Log   Day    G Autumn
7  Litter Night    G Autumn
8     Log Night    G Autumn
9  Litter   Day    H Autumn
10    Log   Day    H Autumn
11 Litter Night    H Autumn
12    Log Night    H Autumn
13 Litter   Day    K Autumn
14    Log   Day    K Autumn
15 Litter Night    K Autumn
16    Log Night    K Autumn
17 Litter   Day    L Autumn
18    Log   Day    L Autumn
19 Litter Night    L Autumn
20    Log Night    L Autumn
21 Litter   Day    N Autumn
22    Log   Day    N Autumn
23 Litter Night    N Autumn
24    Log Night    N Autumn
25 Litter   Day    D Spring
26    Log   Day    D Spring
27 Litter Night    D Spring
28    Log Night    D Spring
29 Litter   Day    G Spring
30    Log   Day    G Spring
31 Litter Night    G Spring
32    Log Night    G Spring
33 Litter   Day    H Spring
34    Log   Day    H Spring
35 Litter Night    H Spring
36    Log Night    H Spring
37 Litter   Day    K Spring
38    Log   Day    K Spring
39 Litter Night    K Spring
40    Log Night    K Spring
41 Litter   Day    L Spring
42    Log   Day    L Spring
43 Litter Night    L Spring
44    Log Night    L Spring
45 Litter   Day    N Spring
46    Log   Day    N Spring
47 Litter Night    N Spring
48    Log Night    N Spring


The model equation I listed above is in effect a collection of 48 model equations (one model for each of the 48 combinations). So, if you wanted to, you could go through each of the combinations I listed above and determine what the equation would look like for that combination.

For example, let's say that you are concerned with the first combination, for which:

• Habitat = Litter (hence HabitatLog = 0);
• Time = Day (hence TimeNight=0);
• Site = D (hence SiteG = 0, SiteH = 0, SiteK = 0, SiteL = 0, SiteN = 0);
• Season = Autumn (hence SeasonSpring = 0).

Then the model equation for the first combination would become:

log (odds of species presence) = beta0 +
beta1*0 +
beta2*0 +
beta3*0 +
beta4*0 +
beta5*0 +
beta6*0 +
beta7*0 +
beta8*0 +
beta9*0*0


or, equivalently,

log (odds of species presence) = beta0.


In other words, beta0 represents the log odds of species presence when Habitat = Litter, Time = Day, Site = D and Season = Autumn.

As another example, if you were concerned with the model equation for the second combination, then:

• Habitat = Log (hence HabitatLog = 1);
• Time = Day (hence TimeNight=0);
• Site = D (hence SiteG = 0, SiteH = 0, SiteK = 0, SiteL = 0, SiteN = 0);
• Season = Autumn (hence SeasonSpring = 0).

The model equation for the second combination would then become:

log (odds of species presence) = beta0 +
beta1*1 +
beta2*0 +
beta3*0 +
beta4*0 +
beta5*0 +
beta6*0 +
beta7*0 +
beta8*0 +
beta9*1*0


or, equivalently,

log (odds of species presence) = beta0 + beta1


In other words, beta0 + beta1 represents the log odds of species presence when Habitat = Log, Time = Day, Site = D and Season = Autumn.

Furthermore, beta1 = (beta0 + beta1) - beta0 represents the difference in the log odds of species presence between the Log and Litter habitats assuming Time = Day, Site = D and Season = Autumn.

I am not saying you have to spell out all 48 model equations, but it helps to know how to map out the R output to the underlying model.

Your model is stating that the effect of Habitat on log odds of species presence depends on Time, all else in the model being the same. In other words, for the same site and season, the effect of Habitat on log odds of species presence in the Autumn is different from the one in the Spring.

The effect of Habitat is given by the coefficient of the quantity obtained by grouping all terms which involve HabitatLog in the model:

(beta1 + beta9*TimeNight)*HabitatLog

Thus, you can see that the effect of Habitat depends on TimeNight:

• If TimeNight=0, the effect of Habitat is given by beta1;
• If TimeNight=1, the effect of Habitat is given by beta1 + beta9.

In other words, for the same site and the same season, changing the habitat from Litter to Log when Time = Day is associated with a change in the log odds of species presence of beta1 units, assuming all else in the model is the same. On the other hand, for the same site and the same season, changing the habitat from Litter to Log when Time = Night is associated with a change in the log odds of species presence of beta1 + beta9 units, assuming all else in the model is the same. Note that it doesn't matter what site and what season you are considering - the effects described here would be the same whether you are looking at Site = D and Season = Spring, Site = G and Season = Autumn, etc.

Of course, you can exponentiate the coefficients beta1 and beta1 + beta9 to express the effects on the odds scale, rather than the log odds scale.

You can't NOT include the effect of Season and Site, since you are controlling for them in your model. Like I said, the effect of Habitat (controlling for Season and Site) depends on Time.

I hope this answers your questions, but see the above Disclaimer.

The coefficients beta0, beta1, ..., beta9 are unknown but you have estimated them from the data. For example, beta0 was estimated to be -3.06306004, beta1 was estimated to be 0.27193202, and so on.

• Thank-you so much. That clears things up - so, the only way to obtain the effect of Litter at Night regardless of site and season is to exclude them from the model. – Grubbmeister Jan 29 at 23:28
• Yes, that's pretty much what you have to do - exclude site and season from the model. Then say something like: ignoring the effect of site and season, the effect of habitat on log odds of species presence is ... etc. – Isabella Ghement Jan 30 at 1:00
• I've been thinking. Could I solve the equation for each combination of the effect I am interested in, then plot the average coefficient of all those combinations? For instance, to plot the overall effect of litter during the day in autumn, I would solve the equation for each of the six sites, then plot an average of those six numbers? Is that a legitimate way to represent the information? – Grubbmeister Jan 30 at 4:09
• What are your research questions? The model and its interpretation should reflect the research questions. – Isabella Ghement Jan 30 at 5:32
• I have created a new question, since it's getting beyond the OP, which hopefully answers the question above: stats.stackexchange.com/questions/389868/… – Grubbmeister Jan 30 at 5:41