Analyzing multiple repeated measurements from same individuals under different conditions I have 4 participants who are exposed to two different environments A and B and their skin temperature is measured every 10 minutes for 1 h. Hence there is 7 measurements per one experiment (0min, 10min, 20min, 30min, 40min, 50min, 60min). During the exposure the temperature decreases.
Participant 1 is measured once in both environment totaling 2 time series
Participant 2 is measured twice in both environments totaling 4 time series
Participant 3 is measured once in both environments totaling 2 time series
Participant 4 is measured three times in both environments totaling 6 time series
I wish to examine whether there is a difference in the two environments.
In a simpler setting I would construct a linear model, include the environment as covariate (A=0, B=1) and calcuate the coefficient and its CI as evidence for treatment effect.
Linear mixed model would seem the best for this one I can´t come up with right model spesification. I could also just compare the groups in the final time point but the measurements are dependent due to multiple measurement from single participants.
What would be the best way to assess the difference between A and B?
 A: The "classical" repeated measurement or longitudinal design for mixed models has time as fixed effect and random slope, and the subject ID as grouping factor in the random effects. If you use R, you'll find some examples in ?lme4::lmer.
Translated into your example, I would suggest using an interaction between environment and time, because this shows you how the effect / difference of the levels of environment changes over time:
library(lme4)
lmer(temperatur ~ environment * time + (1 + time | participant_id), data = data)

In this case you may also think about using a non-linear, like quadratic or cubic trend for time, e.g.
lmer(temperatur ~ environment * poly(time, 2) + (1 + time | participant_id), data = data)

If you're only interested in the difference between the levels of environment, and not how these differences change over time, you can omit the interaction term:
lmer(temperatur ~ environment + time + (1 + time | participant_id), data = data)

Using the summary()-function shows you some more details, and there's a confint()-function to compute CIs.
