martinig / Fitness-and-dispersal-MA

https://martinig.github.io/Fitness-and-dispersal-MA/
0 stars 0 forks source link

how to convert ANOVA #9

Closed martinig closed 9 months ago

martinig commented 1 year ago
itchyshin commented 1 year ago

Use the function for F (in the func.R)

martinig commented 1 year ago

Either of these:


# F values (sign required)
F_vals <- function(F_val, n1, n2, reverse = FALSE){ # m2 = higher/larger group
  n12 <- n1 + n2
  #h <- n12/n1 + n12/n2
  p <- n1/n12 # prop for n1
  q <- n2/n12 # prop for n2
  #t <- est/se
  r_pb <- sqrt(F_val)/sqrt(F_val + n12 -2)

  r_b <- r_pb*(sqrt(p*q)/dnorm(qnorm(p)))
  if(reverse == TRUE){
  r_b = r_b*(-1)}
  r_b
}
​
​
#adjusting for continuous n and assumed balanced design
F_vals_b <- function(F_val, N, reverse = FALSE){
  n12 <- N
  n1 <- N/2
  n2 <- N/2
  #h <- n12/n1 + n12/n2
  p <- n1/n12 # prop for n1
  q <- n2/n12 # prop for n2
  #t <- est/se
  r_pb <- sqrt(F_val)/sqrt(F_val + n12 -2)

  r_b <- r_pb*(sqrt(p*q)/dnorm(qnorm(p)))
  if(reverse == TRUE){
    r_b = r_b*(-1)}
  r_b
}
itchyshin commented 1 year ago

N here is n1 + n2 as you could make it out from the function but just noting this