Skip to main content
2 of 5
Added a R script to perform the calculations.
crsh
  • 378
  • 5
  • 11

As @ocram and @gung rightly point out, if your correlations vary greatly, a different statistical procedure may be more appropriate. That said, for your case I would suggest two possible ways to estimate a required sample size or achieved power using G*Power:

  1. Use the most conservative estimate. A null correlation among repeated measures will yield a sample size that is equivalent to that of a between subject design divided by the number of groups: A between subjects comparison of your three groups ($f = .25, α = .05, 1-β = .95$) would require a total sample size of $n = 252$. A within subjects comparison with an assumed correlation among repeated measures of $r = 0$ requires a total sample size of $n = 84$. Since each measurement is repeated in all three groups your effective sample size is $84\times3 = 252$. Thus, you could simply use 0 as an estimate for your correlation. However, that will most likely be an overly conservative estimate. Using the lowest correlation coefficient found in your data, would give you a more adequate but still conservative estimate of the required sample size. I am uncertain how you need to enter a negative correlation coefficient into G*Power. Entering a negative value will yield a much larger required sample size, which doesn't readily make sense to me, but I'm not terribly knowledgable concerning these calculations.
  2. Use the mean correlation. A less conservative estimate of the correlation among repeated measures is the mean correlation found in your data. Note, however, correlation coefficients are not normally distributed. The formulas you suggest are, therefore, not appropriate to determine the mean correlation. You need to perform a Fisher-transformation before averaging and afterwards retransform the mean to yield the correct mean correlation. But, I think, if the correlations you enter into the mean vary greatly, this approach may lead to sample size estimates that are too liberal. Comparing the results to those resulting from the most conservative estimate may be helpful.

Since it appears you are using R to conduct your analysis here is a function that will do the calculations for you:

rep.m.cor <- function(x, measure, formula, type = "min") {
  fisher.z <- function(r) {
    return(0.5 * log((1+r)/(1-r)))
  }

  inv.fisher.z <- function(z) {
    return((exp(2*z) - 1)/(exp(2*z) + 1))
  }

  melt.data <- melt(x, measure.vars = measure, na.rm = FALSE)
  wide.data <- dcast(melt.data, formula = formula, mean, value.var = "value")
  
  correlations <- cor(wide.data[, -1])
  correlations <- correlations[upper.tri(correlations)]

  if(type == "mean") {
    m.correlations <- inv.fisher.z(mean(fisher.z(correlations)))
  } else if(type == "min") {
    m.correlations <- inv.fisher.z(min(fisher.z(correlations)))
  } else {
    stop("Type must be either 'min' or 'mean'.")
  }
  
  return(m.correlations)
}

x = A data.frame resulting from aggregation, for example aggregate(measure ~ subject * factor1 * factor2, data, mean).

measure = A string providing the name of the measure.

formula = A formula giving the factor for which the correlation should be calculated, for example subject ~ factor1. It is also possible to determine the correlation for the interaction of two or more factors (subject ~ factor1 + factor2; yes, it needs to be a "+"). Note that GPower can be used to perform power analyses for up to two repeated measures factors as long as one of them has only two levels. To do so, enter the larger number of factor levels into the field "Number of measurements" and multiply the effect size $f$ by $\sqrt{2}$ (2 corresponding two the number of levels of the other factor). If both factor have more than two levels the required sample size will be underestimated!

type = A string naming the estimation procedure for the correlation among repeated measures. "min" corresponds to the above option 1, "mean" corresponds to the above option 2.

I hope this helps.

crsh
  • 378
  • 5
  • 11