Skip to main content
deleted 1 character in body
Source Link
crsh
  • 378
  • 5
  • 11

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 twoto the number of levels of the other factor). If both factor have more than two levels GPower will underestimate the required sample size!

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 GPower will underestimate the required sample size!

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 to the number of levels of the other factor). If both factor have more than two levels GPower will underestimate the required sample size!

Added link to book supplement
Source Link
crsh
  • 378
  • 5
  • 11
  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.

I hope this helps.

P.S.: If you understand German, there are detailed step-by-step instructions (including screenshots) in this book supplement.

  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.

I hope this helps.

  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.
  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.

I hope this helps.

P.S.: If you understand German, there are detailed step-by-step instructions (including screenshots) in this book supplement.

Typo
Source Link
crsh
  • 378
  • 5
  • 11
  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$$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.
rep.m.cor <- function(x, measure, formula, type = "min") {
  require("reshape2")

  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)
}

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 GPower will underestimate the required sample size will be underestimated!

  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.
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)
}

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!

  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.
rep.m.cor <- function(x, measure, formula, type = "min") {
  require("reshape2")

  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)
}

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 GPower will underestimate the required sample size!

Added a R script to perform the calculations.
Source Link
crsh
  • 378
  • 5
  • 11
Loading
Source Link
crsh
  • 378
  • 5
  • 11
Loading