Skip to main content
Became Hot Network Question
added 76 characters in body
Source Link
Dimitris Rizopoulos
  • 21.5k
  • 2
  • 25
  • 51

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 dofit 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_typespeed ~ car_type + car_store + car_type :car_store , random=~1|car_owner
          data = data1, data=data1random = ~ 1 | car_owner, method="ML"method = "ML")

lme4 equivalent is  :

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

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

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

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

Also, ideally, I think I can achieve my purpose with m3m3. 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?

Thanks.

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 do 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 , random=~1|car_owner, data=data1, method="ML")

lme4 equivalent is  :

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

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

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

So far, I cant find the equivalent of m3 in lme4, can anyone help me to 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?

Thanks.

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?

Source Link

Interaction as main effect in lme4 vs. nlme

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 do 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 , random=~1|car_owner, data=data1, method="ML")

lme4 equivalent is :

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

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

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

So far, I cant find the equivalent of m3 in lme4, can anyone help me to 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?

Thanks.