| correct.loq {qpNCA} | R Documentation | 
Impute Concentrations Below the Limit of Quantitation
Description
Imputes LOQ values according to the chosen LOQ substitution rule.
Usage
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 
  | 
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
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