0
$\begingroup$

I have a question about showing specific results in R. I am using a linear mixed model and checking the stats between each condition (adding 1, then adding 2, then adding 3...) in a repeated test, which the values are function of time. I have 5 repeated measurement on 6 materials and recorded the value as a function of time (dynamic measurement). I want to see the p values of condition 1 versus condition 2, condition 1 versus condition 3... condition 2 versus condition 3 and so on at each time point. Please see my structure, enter image description here Please see my code below,

library(nlme)
stresseffect= lme(stress~ Condition + Time, data=dt,random=~1| Specimen)
library(emmeans)
emmeans(stresseffect, list(pairwise ~ Condition+Time), adjust = "tukey")

When I run this, I obtain results as seen on the image below, however, I dont want to see results between 1,0 (condition 1 at time 0 sec) versus 2,1 (condition 2 at time 1 sec). I want comparison ie. 1,0 (condition 1 at time 0 sec) versus 2,0 or 1,1 versus 2,1 (condition 2 at time 0 sec), 4,1 (condition 4 at time 0 sec) verus 5,1 (condition 5 at time 0 sec) and so on. However, this code give me what I want plus all the time points, which is not my interest.

enter image description here

Helps are much appreciated.

$\endgroup$

1 Answer 1

1
$\begingroup$

Try specifying pairwise ~ Condition | Time. See the documentation and vignettes that come with the package.

However, I note that the model is additive (no interaction). So every set of comparisons will be exactly the same. If that’s not what you want, then you need to include the interactions in the model.

$\endgroup$
9
  • $\begingroup$ I tried this as well and received same results in each time points and I didnt understand why it is giving the same values for each time point? I definitely need different p values for each time point comparison. I didnt understand very well what you meant by 'However, I note that the model is additive (no interaction). So every set of comparisons will be exactly the same. If that’s not what you want, then you need to include the interactions in the model.' May I ask what is the solution for my case? $\endgroup$
    – Tim
    Commented Nov 27, 2018 at 7:07
  • $\begingroup$ Include the interaction of conditiuon and time in your model $\endgroup$
    – Russ Lenth
    Commented Nov 27, 2018 at 13:54
  • $\begingroup$ 'library(emmeans) ml=emmeans(MCLPassiven_Linear_mixed, list(pairwise ~ Condition| Time), adjust = "tukey") Do you mean interaction like this? condition based on Time?? However, it always gives same results in each time point!! $\endgroup$
    – Tim
    Commented Nov 27, 2018 at 14:55
  • $\begingroup$ Fit a different MODEL that includes Condition:Time $\endgroup$
    – Russ Lenth
    Commented Nov 27, 2018 at 15:01
  • $\begingroup$ I am so sorry if I miss anything here. stresseffect= lme(stress~ Condition + Time, data=dt,random=~1| Specimen) This is my model and as you see, Condition and Time is a fixed effect while Specimen is a random. I do not understand how I should I fit what you mean. May I kindly ask if you can edit the code? Otherwise, unfortunately, I am not able to fix this issue :(. Thank you for your time and effort. $\endgroup$
    – Tim
    Commented Nov 27, 2018 at 15:08

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.