Score_phi <- function(
z1 = 40, z2 = 77, m01 = 15, m02 = 12, y01 = 6, y02 = 1,
N0 = 0.7, N = 27.89, alpha = 0.05
) {
# browser()
data <- c(z1, z2, m01, m02, y01, y02, N0, N)
crit <- qchisq(1 - alpha, 1)
inits <- calculate_mles_pois(data)
if(
any(inits == 0) | any(is.nan(inits)) |
any(inits == Inf) | any(inits == -Inf)
) {
return(tibble(S_Lower = NaN, S_Upper = NaN))
}
lower <- tryCatch(
uniroot(
score_vals_phi, c(1e-5, inits[1]), data = data,
inits = inits, crit = crit
)$root,
error = function(e) NaN
)
upper <- tryCatch(
uniroot(
score_vals_phi, c(inits[1], 100), data = data,
inits = inits, crit = crit
)$root,
error = function(e) {
tryCatch(
uniroot(
score_vals_phi, c(inits[1], 1000), data = data,
inits = inits, crit = crit
)$root,
error = function(e) NaN
)
}
)
tibble(S_Lower = lower, S_Upper = upper)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.