# nlme - multiple regression with categorical factor - proper coding?

I am certain this question has been asked several times, yet I can't seem to find the correct code or explanation. (will remove it if I find a solution)

I have a rather simple design, yet I can't seem to code things correctly in R. I have one repeated measures factor (Group: A, B, C), and 4 dependent measures (Accuracy, Bias, Confidence, Intensity).

I would like to predict Accuracy using the three other DVs, while controlling for Group and Subject.

My issue is both from a theoretical point and from a coding point. First, my predicting model would ideally be used to predict ALL Groups (e.g., I will be able to claim that using Intensity is a good predictor of Accuracy under all groups). However, from my analyses (ANOVAs) I know that there are significant differences between the Groups on all ratings, therefore, I may run into a Simpsons' paradox, where I claim that Intensity is a predictor, yet for Group A and B it is negative, but looks positive overall, or it simply becomes useless because the predictions all difer based on Group.

Would I run a model that predicts Accuray based on the other DVs at each Group level? Or is there a way to make an "overall/parsimonious" predicting model?

Now for the coding. I am using NLME, where I think the code should either be:

 m1 <- lme(Accuracy ~ Bias + Intensity + Confidence, random=~Group|Subjects, data = my_data)


Or

m2 <- lme(Accuracy ~ Bias:Group + Intensity:Group + Confidence:Group, random=~1|Subjects, data = my_data)


Thank you in advance!

• Can you provide more details on your study design? For example, were your subjects randomly assigned to the three groups? Or was each subject assigned, in turns, to all three groups? – Isabella Ghement Jul 2 '19 at 14:44
• Hi. It is a repeated-measures design. You can take Group as reflecting Stimulus Type (Type 1, Type 2, Type 3). The order is randomized between participants. Part of the reason I want to use mixed-effects modeling for this is due to the correlational nature of the data. Running separate regressions (as some papers report) ignores the fact that the data is drawn from the same sample. – Hubris555 Jul 2 '19 at 14:48
• I still don't understand from your explanation if each subject is exposed to all three stimulus types (with the order of exposure randomized)? Can you clarify? The "repeated measures design" explanation can mean a myriad of things so best to be specific and explicit. If each subject is exposed to all three stimulus types, does that mean that Accuracy, Bias, Intensity and Confidence are also measured under all three stimulus types for that subject? – Isabella Ghement Jul 2 '19 at 14:49
• Yes, you are correct. Each Subject sees every Group condition. For each Group condition trial, they provide 4 responses. (the randomization refers to the order of Groups; each participant sees a different random order, e.g., ABC, BCA, CBA....). Imagine if the Groups were Dogs, Cats, Horses. A participant would see pictures of Dogs and rate each picture of a dog on 4 DVs, then they would see Cats, and do the same, and then Horses, and do the same. In the end, each Subject has 3 scores for each DV. – Hubris555 Jul 2 '19 at 15:33
• Thanks! Why and how do subjects provide 3 scores for each variable? Also, are the 3 groups the only ones you are interested in or do they represent a (representative) subset of all groups you are targetting? – Isabella Ghement Jul 2 '19 at 16:11