0
$\begingroup$

Let's say I have a response variable Y, and I want to predict it using variables A, B and C using a linear regression model. My problem is that I suspect that A and B might interact as well as A and C, but not B and C. Thus, I think that interaction A*B*C might not be the most appropriate. However, I don't know how to set this type of relationship among explanatory variables.

In my real example, my response variable is the activity (Activity) of an animal, and my explanatory variables are the hour of the day (Hour), the moon illumination (moon) and the human presence (human). Following what I said in the first paragraph, I know that the moon effect changes depending on the hour of the day since not all the hours have the same type of moon. On the other side, the human presence occurs only at some specific hours of the day, so I also know that the "human presence" effect will depend on the hour of the day. But here, I don't want to consider the interaction between "moon" and "human". So, my doubt is what would be the right way of designing my model considering that Hour interact with Moon and Human but separately.

What is the correct way of designing a regression model considering these conditions?. Should I consider it as Hour*Moon*Human or as Hour*Moon + Hour*Human or none of them?

Any comment would be of great help

$\endgroup$
3
  • $\begingroup$ Your first comment to the answer confirms this really is an R question, as I pointed out yesterday. $\endgroup$
    – whuber
    Commented Sep 20, 2020 at 14:56
  • $\begingroup$ It is both, which is not a problem, isn't it? My doubt was that I didn't know how to consider interactions given my knowledge about the variables. This is a theoretical doubt. Then, I also had the doubt about how to write my desired interactions. $\endgroup$
    – Dekike
    Commented Sep 20, 2020 at 15:03
  • $\begingroup$ In my first comment, as I pointed out, is an extra doubt. In the post what I show is not a problem of code, at least not completely. $\endgroup$
    – Dekike
    Commented Sep 20, 2020 at 15:06

1 Answer 1

2
$\begingroup$

Hour*Moon + Hour*Human is fine, it includes the three varibles plus the two interaction terms you are interested to, for a total of five regressors. I'm assuming you are using R notation.

Mind that Hour is a circular variable, so modeling a linear relation on it, in most cases, is a bad idea. Whatever terms you want to use from Hour, just interact them with Moon and Human. For instance: (cos(Hour)+sin(Hour))*(Human+Moon).

$\endgroup$
7
  • $\begingroup$ Yes @carlo, I know that hour is circular, and notation is in R, however, I didn't specify exactly what because it is not the point. One doubt, Hour*Moon + Hour*Human and Hour*(Moon + Human) is the same in R is the same? $\endgroup$
    – Dekike
    Commented Sep 20, 2020 at 13:43
  • $\begingroup$ yes____________ $\endgroup$
    – carlo
    Commented Sep 20, 2020 at 13:50
  • $\begingroup$ @Dekike whenever I get confused with interaction terms, I find it helpful just to write them out individually as I want them to appear rather than to depend on R to parse them out in a way I might not have intended. If you want only Hour-Moon and Hour-Human interactions plus the individual contributions of those predictors, I'd write Hour + Moon + Human + Hour:Moon + Hour:Human (putting aside the issue of the circular-variable nature of Hour). $\endgroup$
    – EdM
    Commented Sep 20, 2020 at 14:32
  • $\begingroup$ Thanks, @EdM. One thing, I thought that writing hour*moon + hour*human' would also include the individual contribution of hour, moon` and human. However, what I extract from your comment is that I have to include those variables individually to include their contribution, is that true? $\endgroup$
    – Dekike
    Commented Sep 20, 2020 at 14:39
  • $\begingroup$ @Dekike when R encounters Hour*Moon + Hour*Human it effectively expands both of the "*" terms into their components--Hour + Moon + Hour:Moon + Hour + Human + Hour:Human--and then removes the redundant term to get Hour + Moon + Human + Hour:Moon + Hour:Human. Unlike the "*" syntax, ":" does not expand out an interaction but leaves it as is. So your are OK if you use "*", no need to specify individual predictors. If you use ":" you need to include the predictors individually yourself. $\endgroup$
    – EdM
    Commented Sep 20, 2020 at 14:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.