3
$\begingroup$

Let's say I am trying to see if there are speed differences among different types of cars (e.g., jeep, SUV, truck, sports car). I also want to see whether the car store (A, B, C, D, E) has an effect on this. I don't have a specific hypothesis about the car stores, but I assume that certain stores tend to sell certain types of cars (e.g., SUVs at Store A and trucks at Store B).

So, I tried to fit a linear mixed effect model with lme4 and nlme. I have a question about the difference between these two models:

nlme:

m1 <- lme(speed ~ car_type + car_store + car_type:car_store, 
          data = data1, random = ~ 1 | car_owner, method = "ML")

lme4 equivalent is:

m2 <- lmer(speed ~ car_type * car_store + (1 | car_owner), 
           data = data1, REML = FALSE)

Now, my question is, can I have interaction as the main effect in nlme like this:

m3 <- lme(speed ~ car_type + car_type:car_store, data = data1, 
          random = ~ 1 | car_owner, method = "ML")

So far, I can't find the equivalent of m3 in lme4. Can anyone help me understand why?

Also, ideally, I think I can achieve my purpose with m3. But is there anything else that I should consider? like perhaps it's better to use lme4 and car_store as main/fixed effect as well?

$\endgroup$
2
  • 2
    $\begingroup$ This is more about understanding how R handles main effects and interactions rather than about mixed models. In principle, the syntax with lmer() for the fixed effects will be the same as in lme(), e.g., lmer(speed ~ car_type + car_type:car_store + (1 | car_owner), data = data1). $\endgroup$ Commented Sep 30 at 13:24
  • $\begingroup$ @DimitrisRizopoulos Thanks a lot. But, here it means the interaction is a fixed effect right? Theoritical (stat) wise, can I have a suggestion if I should keep car_store as individual fixed effect or not? $\endgroup$ Commented Sep 30 at 14:55

1 Answer 1

6
$\begingroup$

There should be no difference between lme4 and nlme regarding the specification of the fixed effects. As mentioned by Dimitris Rizopoulos in a comment to the question, there is nothing specific to mixed models here.

I agree that your models m1 and m2 indeed have the same fixed effects.

Now, my question is, can I have interaction as the main effect in nlme like this:

m3 <- lme(speed ~ car_type + car_type:car_store, data = data1, random = ~ 1 | car_owner, method = "ML")

Yes, you do that, but it is not (usually) a good idea. Models that include an interaction, but exclude one or both main effects, have been discussed here many times, for example:

Including the interaction but not the main effects in a model

Unless you have a very good reason, I suggest your model's fixed effects should be:

car_type + car_store + car_type:car_store

or just:

car_type * car_store

which is shorthand for the same thing.

$\endgroup$
1
  • $\begingroup$ Thanks a lot for this and the reference. $\endgroup$ Commented Oct 1 at 8:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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