metrumresearchgroup / pmtables

TeX tables for pharmacometrics.
https://metrumresearchgroup.github.io/pmt-book
11 stars 1 forks source link

Check BLQ calculation #248

Closed kylebaron closed 2 years ago

kylebaron commented 3 years ago

An example calculation ahead of release.

Repex

library(tidyverse)
library(pmtables)

5 missing observations

a <- tibble(DV = rep(NA_real_, 5), BQL = 0)

10 observations BQL

b <- tibble(DV = rep(NA_real_, 5), BQL = 1)
c <- tibble(DV = rep(NA_real_, 5), BQL = 2)

85 non-BQL observations

d <- tibble(DV = rnorm(85), BQL =0)

Combined

data <- bind_rows(a,b,c,d) %>% mutate(ID = 1)
nrow(data)
#> [1] 100

Create table

pt_data_inventory(data)$data
#> # A tibble: 1 × 6
#>   Number.SUBJ Number.MISS Number.OBS Number.BQL Percent.OBS Percent.BQL
#>         <int>       <int>      <int>      <int> <chr>       <chr>      
#> 1           1           5         85         10 89.5        10.5

Check result

100 * 85/(85+10)
#> [1] 89.47368
100 * 10/(85+10)
#> [1] 10.52632

Created on 2021-08-28 by the reprex package (v2.0.0)

callistosp commented 3 years ago

how does this work with multiple rows now? I think that’s where Percent.OBS and Percent.BQL can draw a better picture of what the data look like

kylebaron commented 3 years ago

You could make that by passing by

curtisKJ commented 3 years ago

So in this context would it be counting dosing records as missing (CV=NA_real and BQL =0) or does it ignore anything that isn't EVID==0?

kylebaron commented 3 years ago

It assumes you've passed in the records for observations you want summarized; doesn't have concept of EVID.

timwaterhouse commented 3 years ago

This makes sense to me. I'd tend to agree that Percent.OBS isn't really meaningful.