0
$\begingroup$

I'm grateful for advice on which R analysis to choose for the following study:

I measured stress in one subject on 27 days in the night and in the morning.

Now I want to predict stress in the night via stress in the morning. All data stem from the same subject. There are 27 timepoints in total.

How do I account for the repeated measures in this?

A normal lm doesn't work since it's repeated. When i use lme4, R gives a warning: If i cluster within ID (always the same participant) the warning is: I have to have more than 1 observation. If I cluster within video (27 videos) R warns that the number of clusters has to be smaller than the number of observations.

I have thought about uSEM, lme4, gee or dynamic linear regression.

Do you have any ideas how I model this? I always want to predict the stress in the night by the stress the former day.

Any advice is very welcome and thank you so much for reading this far.

head(data)

dailystress nightstress dailystress.l1 Video

1 0.333 0.166 0.183 1
2 1 0.142 0.166 2
3 0 0.0741 0.142 3
4 NA 0.138 0.0741 4
5 1 0.0567 0.138 5
6 0.667 0.102 0.0567 6

str(data) is

dailystress: num [1:26] 0.333 1 0 NA 1
..- attr("format.spss")= chr "F8.2"
..- attr("display_width")= int 14
nightstress: num [1:26] 0.1658 0.1424 0.0741 0.138 0.0567
..- attr("format.spss")= chr "F20.8"
..- attr("display_width")= int 22
dailystress.l1: num [1:26] 0.1834 0.1658 0.1424 0.0741 0.138
..- attr("format.spss")= chr "F20.8"
..- attr("display_width")= int 25
Video: num [1:26] 1 2 3 4 5 6 7 8 9 10
..- attr(*, "format.spss")= chr "F8.0"

$\endgroup$

1 Answer 1

0
$\begingroup$

Consider a model like the following for your data

stress$_{td} \sim N(\mu_t+\pi_d, ~\sigma^2),~\pi_d \sim N(0,~\tau^2)$,

where $t$ codes the time (morning, afternoon) and $d$ indexes the 27 days. If Gaussianity is a reasonable assumption, you can analyze the data with the above model formulation using lme4 or nlme:

m1 <- lmer(stress ~ time+(1|day), data=...)
summary(m1)

m2 <- lme(stress ~ time, random=~1|day, data=...)
summary(m2)

P.S.

The previous recommendation was based on the assumption that the primary focus is on comparing dailystress and nightstress, and this additional information has been incorporated following the OP's update.

Lacking direct access to the dataset, providing a specific recommendation is challenging. Instead, I offer a more general approach:

  1. Theoretical Hypothesis: Clearly formulate your theoretical hypothesis regarding the relationship between dailystress and nightstress. Define the expected patterns or trends.

  2. Data Visualization: Plot the data to gain insights. Visualization can reveal patterns, trends, or anomalies that align with or challenge your theoretical hypothesis. Tools like scatter plots, or time-series plots can be insightful.

  3. Modeling: Consider employing an autoregressive model or its derivatives. In R, the ar function could be a good starting point. Such models can capture temporal dependencies in the data, which might be crucial when studying stress patterns over time.

This approach encourages a structured exploration of the data, ensuring that your analysis is guided by your theoretical expectations. Visualization aids in uncovering nuances, and an autoregressive model provides a statistical framework for capturing temporal dependencies, a common consideration in stress-related studies.

$\endgroup$
6
  • $\begingroup$ Thank you so much @bluepole, that was beyond helpful. If I may ask: If I cluster for days, like in the formula, R gives me the error: number of levels of each grouping factor must be < number of observations (problems: day). I will try to split up daypoints so there are three measurements a day instead of using mean and having only one pair of observation each day. Then I can still cluster for 27 days but the levels are < number of observations. Does that make sense to you? Again, thank you so much. $\endgroup$
    – larilimone
    Commented Nov 7, 2023 at 17:15
  • $\begingroup$ Would you mind sharing in your original post the output of str() and head() for your data frame? $\endgroup$
    – bluepole
    Commented Nov 7, 2023 at 18:08
  • $\begingroup$ For sure, again thank you so much for asking. I put it in the original post. Video contains 27 videos from the same person. Video is the same variable as day in the model (27 days = 27 videos). Using your model : m1 <- lmer(nightstress ~ dailystress+(1|Video), data=data) I get this error: number of levels of each grouping factor must be < number of observations (problems: Video). If anything is unclear, please feel free to ask. $\endgroup$
    – larilimone
    Commented Nov 10, 2023 at 16:55
  • $\begingroup$ Your reply suggests that you may be interested in examining the relationship or dependence between nightstress and dailystress. Could you clarify if this is indeed the aspect of interest, or if you are focusing on the difference between the two? $\endgroup$
    – bluepole
    Commented Nov 12, 2023 at 14:02
  • $\begingroup$ Exactly, I want to predict dailystress by nightstress. So I would like to examine this relationship, but dailystress and nightstress is repeatedly measured on the 27 days. $\endgroup$
    – larilimone
    Commented Nov 12, 2023 at 20:16

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.