Skip to content

Commit

Permalink
use log1p() for numerical stability (in get_stat()), see
Browse files Browse the repository at this point in the history
  • Loading branch information
fweber144 committed Jan 8, 2025
1 parent 1ee2bbd commit df4bad0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion R/summary_funs.R
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ get_stat <- function(summaries, summaries_baseline = NULL,
# log-normal approximation
# https://en.wikipedia.org/wiki/Log-normal_distribution#Arithmetic_moments
mul <- log(value^2 / sqrt(value_se^2 + value^2))
varl <- log(1 + value_se^2 / value^2)
varl <- log1p(value_se^2 / value^2)
lq <- qnorm(alpha_half, mean = mul, sd = sqrt(varl))
uq <- qnorm(one_minus_alpha_half, mean = mul, sd = sqrt(varl))
# Go back to linear scale
Expand Down

0 comments on commit df4bad0

Please sign in to comment.