Below, I'm trying to solve for ncp (there is one answer). But I'm wondering why when I extend the interval argument in optimize the answer drastically changes?
Could I use uniroot instead of optimize here?
f <- function(pwr, q, df1, df2, ncp){
abs(pwr - pf(q, df1, df2, ncp, lower.tail = FALSE))
}
optimize(f, interval = c(0, 1e2), pwr = .8, q = 2.5, df1 = 3, df2 = 108)[[1]]
# [1] 10.54639 !!! HERE
optimize(f, interval = c(0, 5e2), pwr = .8, q = 2.5, df1 = 3, df2 = 108)[[1]]
# [1] 499.9999 !!! HERE