# Roger Palay copyright 2016-02-20 # Saline, MI 48176 # ci_2popvar <- function ( n_top, s_top, n_bot, s_bot, cl=0.95) { # generate a confidence interval for the ratio # of the top variance to the bottom variance from # a sample of the top population with size n_top # and standard deviation s_top and a sample of the # bottom population with size n_bot and standard # deviation s_bot. cl gives the confidence level. alpha <- 1-cl alphadiv2 <- alpha/2 v_top <- s_top^2 v_bot <- s_bot^2 quotient <- v_top / v_bot xlow <- qf( alphadiv2, n_top-1,n_bot-1) xhigh <- qf( alphadiv2, n_top-1,n_bot-1, lower.tail=FALSE) c_low <- quotient/xhigh c_high <- quotient/xlow result <- c( c_low, c_high, quotient, xlow, xhigh, v_top, s_top, n_top, v_bot, s_bot, n_bot, cl, alphadiv2) names(result) <- c( "CI Low", "CI_HIGH", "Quotient", "F Low", "F High", "Top Var.", "Top sd", "Top size", "Bot Var.", "Bot sd", "Bot size", "C level", "Alpha/2") return( result) }