R/pwr.lancova.R

Defines functions pwr.lancova

Documented in pwr.lancova

#' Power Calculation for LANCOVA
#'
#' Compute the statistical power of the LANCOVA test.
#'
#' @param k the number of groups.
#' @param n the number of observations per group.
#' @param rho_sqrd the pretest-posttest correlation
#' @param r_sqrd the expected explained variance (on the logged scale)
#' @param alpha the significance level (default=.05)
#' @return \item{power}{the statistical power of test}
#' @examples
#' pwr.lancova(3,40,.1,.4,.05)
#' @export
#' @importFrom stats pf qf
#' @references Cohen, J. (1988). Statistical power analysis for the behavioral sciences (2nd ed.). Hillsdale,NJ: Lawrence Erlbaum.


pwr.lancova<-function(k,n,r_sqrd,rho_sqrd,alpha=.05){
  lambda <- k * n * r_sqrd*(1-r_sqrd)/(1-rho_sqrd)
  power <- pf(qf(alpha, k - 1, (n - 1) * k-1, lower.tail = FALSE),
       k - 1, (n - 1) * k-1, lambda, lower.tail = FALSE)
  list('the number of group' = k,
       'the per-group sample size' = n,
       'pretest-posttest correlation'= rho_sqrd,
       'r squared' = r_sqrd,
       'significance level' = alpha,
       'power' = power)
}

Try the lamme package in your browser

Any scripts or data that you put into this service are public.

lamme documentation built on May 1, 2019, 7:32 p.m.