Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions R/impute.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ rcensnorm <- function(mean, sd, lower_lims, upper_lims) {

min_p <- pnorm(lower_lims[bounded_titer], mean[bounded_titer], sd[bounded_titer])
max_p <- pnorm(upper_lims[bounded_titer], mean[bounded_titer], sd[bounded_titer])

samples <- runif(sum(bounded_titer), min_p, max_p)
output <- lower_lims
output[bounded_titer] <- qnorm(samples, mean[bounded_titer], sd[bounded_titer])
Expand All @@ -23,7 +23,7 @@ impute_gmt_logtiters <- function(result, titers) {
mean = result["mean", "estimate"],
sd = result["sd", "estimate"],
lower_lims = titerlims$min_titers,
upper_lims = titerlims$max_titers
upper_lims = titerlims$max_titers,
)

attr(result, "censoring") <- titerlims$censoring
Expand All @@ -34,12 +34,12 @@ impute_gmt_logtiters <- function(result, titers) {
#' Impute censored titers
#'
#' This function takes a vector of titers and imputes censored titers based on
#' the results of a geometric mean titer estimate from the `impute_gmt_titers()`
#' the results of a geometric mean titer estimate from the `titertools::gmt()`
#' function. Censored titers are drawn from a censored normal distribution with
#' mean and standard deviation parameters equal to those provided in the
#' result argument.
#'
#' @param result Results from a titer GMT estimate from `impute_gmt_titers()`
#' @param result Results from a titer GMT estimate from `titertools::gmt()`
#' @param titers A vector of titers for which to impute censored cases
#'
#' @return Returns a vector of titers with imputed values in place of censored
Expand Down Expand Up @@ -73,7 +73,7 @@ impute_log2diff <- function(
mean = result["mean", "estimate"],
sd = result["sd", "estimate"],
lower_lims = titerlims$min_diffs,
upper_lims = titerlims$max_diffs
upper_lims = titerlims$max_diffs,
)

attr(result, "censoring") <- titerlims$censoring
Expand Down