I have a dataset of temperature measurements within a day 6 am, 6 pm, for two groups of patients health and flue, There are repeated measurements on the same patient and same timepoint - measurements taken in the ear, mouth, and armpit. Within the group, the measurement is repeated for both time points on a patient. However, in the flue and healthy group, there are different subjects.
p1 <- data.frame(patient_id = "h1", time = rep(c("6am","6pm"),each=3), group = "health", body_part=rep(c("ear", "mouth", "armpit"),2), temperature = rnorm(6,36,3), stringsAsFactors = F )
p2 <- data.frame(patient_id = "h2", time = rep(c("6am","6pm"),each=3), group = "health", body_part=rep(c("ear", "mouth", "armpit"),2), temperature = rnorm(6,36.5,3), stringsAsFactors = F )
p3 <- data.frame(patient_id = "h3", time = rep(c("6am","6pm"),each=3), group = "health", body_part=rep(c("ear", "mouth", "armpit"),2), temperature = rnorm(6,36.2,3), stringsAsFactors = F )
f1 <- data.frame(patient_id = "f1", time = rep(c("6am","6pm"),each=3), group = "flue", body_part=rep(c("ear", "mouth", "armpit"),2), temperature = rnorm(6,37,3), stringsAsFactors = F )
f2 <- data.frame(patient_id = "f2", time = rep(c("6am","6pm"),each=3), group = "flue", body_part=rep(c("ear", "mouth", "armpit"),2), temperature = rnorm(6,37.5,3), stringsAsFactors = F )
f3 <- data.frame(patient_id = "f3", time = rep(c("6am","6pm"),each=3), group = "flue", body_part=rep(c("ear", "mouth", "armpit"),2), temperature = rnorm(6,38.8,3), stringsAsFactors = F )
df <- bind_rows(p1,p2,p3,f1, f2,f3)
What I want to find out are the folowing contrasts
- flue - health
- 6am - 6pm
but also contrasts:
- 6am : flue - health,
- 6pm : flue - health,
As well as these:
- flue : 6pm - 6am
- healt: 6pm - 6am
If the interaction term, after running a likelihood ratio test is significant.
This is how I modelled the data with mixed effects models:
m1 <-lmer(temperature ~ group + time + (1 | patient_id) + (1 | body_part), data=df)
m2 <- lmer(temperature ~ group + time + group * time + (1 | patient_id) + (1 | body_part), data=df)
anova(m1, m2)
QUESTION: I am wondering if using this specification I am correctly capturing the repeated measurements on the subjects over time and the repeated measurements (ear, mouth, etc) on a single subject?
And this is how I computed the contrasts for the model without interactions:
glt1time <- multcomp::glht(m1, mcp(time="Tukey"))
summary(glt1time)
glt1 <-multcomp::glht(m1, mcp(group="Tukey"))
summary(glt1)
QUESTION: Is it better to remove the (1|patient_Id)
term if computing the contrast for the group
factor, since there is no repeated measurement between those groups?
m3 <- lmer(temperature ~ group + time + (1|body_part), data=df)
glt3 <-multcomp::glht(m3, mcp(group="Tukey"))
summary(glt3)
The summary(glt1)
and summary(glt3)
differ with respect to the standard error estimate.