Skip to content

Feature request: New logslope & c1 impute_start methods #350

@Gero1999

Description

@Gero1999

Hello PKNCA team!

In aNCA we developed some impute_start functions that I feel are very standard/intuitive:

PKNCA_impute_method_start_logslope <- function(conc, time, start, end, ..., options = list()) { # nolint

  ret <- data.frame(conc = conc, time = time)
  mask_start <- time %in% start
  if (!any(mask_start)) {
    all_concs <- conc[time >= start  &  time <= end]
    all_times <- time[time >= start  &  time <= end]
    if (!all(is.na(all_concs))) {
      c0 <- PKNCA::pk.calc.c0(all_concs, all_times, method = "logslope")
      if (!is.na(c0)) {
        ret <- rbind(ret, data.frame(time = start, conc = c0))
        ret <- ret[order(ret$time), ]
      }
    }
  }
  ret
}

PKNCA_impute_method_start_c1 <- function(conc, time, start, end, ..., options = list()) { # nolint
  ret <- data.frame(conc = conc, time = time)
  mask_start <- time %in% start
  if (!any(mask_start)) {
    all_concs <- conc[time >= start  &  time <= end]
    all_times <- time[time >= start  &  time <= end]
    if (!all(is.na(all_concs))) {
      c1 <- all_concs[which.min(all_times)]
      ret <- rbind(ret, data.frame(time = start, conc = c1))
      ret <- ret[order(ret$time), ]
    }
  }
  ret
}

Feel free to give a look to the pr to check the tests+documentation and merge if the functions could be of interest to you!
#351
If they are useless feel free to close the issue and pull request!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions