correct.loq: Impute Concentrations Below the Limit of Quantitation

Description Usage Arguments Details Value Examples

View source: R/correct.loq.r

Description

Imputes LOQ values according to the chosen LOQ substitution rule.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
correct.loq(
  x,
  by = character(0),
  nomtimevar = "ntad",
  timevar = "time",
  depvar = "dv",
  bloqvar = "bloq",
  loqvar = "loq",
  loqrule = 1
)

Arguments

x

input dataset name contains all uncorrected data, including LOQ

by

column names in x indicating grouping variables

nomtimevar

variable name containing the nominal sampling time after dose

timevar

variable name containing the actual sampling time after dose

depvar

variable name containing the dependent variable (e.g., concentration)

bloqvar

variable name containing the BLOQ flag (0: no, 1: yes)

loqvar

variable name containing the LOQ value

loqrule

rule number to be applied to the LOQ values in the curve. x$loqrule overrides if provided

  • 1: 0 before first measurable concentration (FMC); NA after FMC

  • 2: 0 before FMC; 0 after FMC

  • 3: 0 before FMC; 0.5xLOQ for first consecutive LOQ after FMC, NA for other LOQ

  • 4: 0 before FMC; 0.5xLOQ for first consecutive LOQ after FMC, 0 for other LOQ

Details

Imputations will be applied to the original depvar (no new concentration variable will be created).

Value

A dataset with imputed BLOQ concentrations using the chosen imputation rule

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
library(magrittr)
library(dplyr)
library(qpNCA)
x <- Theoph
ntad <- c(0,0.25,0.5,1,2,4,5,7,9,12,24)
for(i in 1:nrow(x)){
  time  <- x$Time[[i]]
  delta <- abs(ntad - time)
  best  <- min(delta)
  index <- match(best, delta)
  nom   <- ntad[[index]]
  x$ntad[[i]] <- nom
}
rm(list = c('time','delta','best','index','nom', 'i','ntad'))
x %<>% rename(time = Time, dv = conc)
x %<>% mutate(bloq = ifelse(dv==0,1,0), loq = 0.01, tad = time, loqrule = 1, 
              subject=as.numeric(Subject), ntad=as.numeric(ntad))
x %>% head
x %<>% correct.loq('subject')
x %>%  head

qpNCA documentation built on Aug. 16, 2021, 5:08 p.m.