How do I approach a linear mixed effects model with a 2-level group?

My data looks something like this:

> head(my_data,n=8)

Subject Group     Value1     Value2   Outcome
1         A        12.404    5.00     1.33
2         A        14.898    4.34     6.77
3         A        13.870    2.53     5.01
4         A        14.313    9.33     6.82
5         B        13.407    4.99     8.42
6         B        13.480    2.59     9.11
7         B        13.761    1.42     8.21
8         B        12.607    0.55     8.32
...
...

I'm interested in performing a mixed linear effects model with a comparison between the Groups. I want to see the effect the group difference has on the different fixed variables (i.e. Value1 and Value2). I wasn't sure how to go about that. Initially this is what I had:

lme(outcome*Group~ (Value1+Value2)*Group, random= ~ 1|Subject, data=my_data)

But once I read further, I thought it should look something like this:

lme(outocme~Value1+Value2+Group, random=1|Subject, data=my_data)

However, when I do that I get an output that only lists group A but not group B for some reason.

Any help/guidance would be greatly appreciated.

Thanks.

Hello @s75moham, welcome in this group.

I have no experience at all with 'linear mixed effect models' but being interested I tried to reproduce your problem. However I run into errors such as object 'Subject' not found , but maybe I am not using the same packages as you. Therefore I enclose a REPRoducible EXample (reprex) of what I did.
A reprex consists of the minimal code and data needed to recreate the issue/question one is having. See e.g. whats-a-reproducible-example-reprex-and-how-do-i-do-one:

library(tibble)
library(nlme)

my_data = tribble(
  ~Subject, ~Group, ~Value1, ~Value2, ~Outcome,
 1,        "A",        12.404,    5.00,     1.33,
 2,        "A",        14.898,    4.34,     6.77,
 3,        "A",        13.870,    2.53,     5.01,
 4,        "A",        14.313,    9.33,     6.82,
 5,        "B",        13.407,    4.99,     8.42,
 6,        "B",        13.480,    2.59,     9.11,
 7,        "B",        13.761,    1.42,     8.21,
 8,        "B",        12.607,    0.55,     8.32
)

lme(Outcome~Value1+Value2+Group, random=1|Subject, data=my_data)
#> Error in reStruct(random, REML = REML, data = NULL): object 'Subject' not found

Created on 2020-09-03 by the reprex package (v0.3.0)

I would be helpful if you present your problem in the same way.

By the way 'googling' on linear mixed-effects models using r also produced some results, but probably you are already familiar with these.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.