Skip to content

Commit

Permalink
add conversion for lnorm median and dispersion to convert_summary_sta…
Browse files Browse the repository at this point in the history
…ts_to_params
  • Loading branch information
joshwlambert committed Sep 20, 2024
1 parent b6ae203 commit 8b9aeeb
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions R/convert_params.R
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,16 @@ convert_params_to_summary_stats.epiparameter <- function(x, ...) {
return(list(meanlog = meanlog, sdlog = sdlog))
}

if (checkmate::test_number(x$median) &&
checkmate::test_number(x$dispersion)) {
# median and dispersion to params
checkmate::assert_number(x$median, lower = 0)
checkmate::assert_number(x$dispersion, lower = 0)
meanlog <- log(x$median)
sdlog <- log(x$dispersion)
return(list(meanlog = meanlog, sdlog = sdlog))
}

if (!(checkmate::test_number(x$median) && checkmate::test_number(x$sd))) {
stop("Cannot calculate lognormal parameters from given input")
}
Expand Down

0 comments on commit 8b9aeeb

Please sign in to comment.