Exercise: Power simulation for LMM
================

## Physical healing as a function of perceived time

Aungle and Langer (2023) investigate how perceived time influences
physical healing

- They used cupping to induce bruises on 33 subjects, then took a
  picture, waited for 28 min and took another picture
- Subjective time was manipulated to feel like 14, 28, or 56 min
- The pre and post pictures were presented to 25 raters who rated the
  amount of healing on a 10-point-scale with 0 = not at all healed, 5 =
  somewhat healed, 10 = completely healed
- Subjects participated in all three conditions over a two week period

Data: [healing.RData](../data/healing.RData)

``` r
load("../data/healing.RData")

str(dat)

# Subject ID
dat$Subject <- factor(dat$Subject)
# Rater ID
dat$ResponseId <- factor(dat$ResponseId)
```

1.  Visualize the data.

    - Aggregate the data over Raters and plot the data for each subject
      using `lattice::xyplot()`
    - Aggregate the data over Subjects and plot one panel for each rater
    - How would you choose the random effects for a model testing
      healing over the three conditions

2.  Fit the model you think fits the experimental design best

3.  Test the effects of condition

4.  Run a power simulation for a replication study:

    - Set up a data frame containing the study design and sample size.

    - Specify the minimum relevant effects.

    - Set the fixed effects and variance components to plausible values.

    - How many participants are required to detect the specified effect
      with a power of 80%?

    - Recover the parameters of the model for one simulated data set.

### Reference

<div id="refs" class="references csl-bib-body hanging-indent">

<div id="ref-Aungle23" class="csl-entry">

Aungle, P., and E. Langer. 2023. “Physical Healing as a Function of
Perceived Time.” *Scientific Reports* 13 (1): 22432.
<https://doi.org/10.1038/s41598-023-50009-3>.

</div>

</div>
