Skip to content
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ as.data.frame(o_nca) |>

**Known gotchas:**

- **Tobit half-life** — `pk.nca()` does not wire `lloq` through to `pk.calc.half.life()`. Use `pk.calc.half.life()` directly and add a note in the docs.
- **Tobit half-life** — `hl_method = "tobit"` through `pk.nca()` requires the LLOQ on the concentration object: `PKNCAconc(..., lloq = <scalar or column name>)` (≥ 0.12.2). Without `lloq`, `pk.nca()` stops with "lloq must be provided when hl_method is 'tobit'".
- **Sparse AUMC** — only set `sparse_aumclast = TRUE`. Explicitly requesting `sparse_auc_se = TRUE` alongside it triggers an internal type error.
- **`normalize()`** — replaces the original parameters (does not append). To keep both, `bind_rows()` before and after.
- **New option defaults** — always verify with `PKNCA.options("option_name")` before documenting the default.
Expand Down
30 changes: 28 additions & 2 deletions user/halflife.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ Tobit regression is most beneficial when:

### Using Tobit (PKNCA ≥ 0.12.2)

Tobit is available by calling `pk.calc.half.life()` directly. Supply the full concentration-time vector and the LLOQ for each timepoint:
The mechanics are easiest to see with a direct `pk.calc.half.life()` call. Supply the full concentration-time vector and the LLOQ for each timepoint:

```{r}
# Simulated profile — concentrations at 16h and 24h are below the LLOQ of 0.1 mg/L
Expand All @@ -270,7 +270,33 @@ data.frame(
)
```

> **Note:** Passing `hl_method = "tobit"` through the `pk.nca()` pipeline (via `PKNCAdata(options=...)`) also requires the LLOQ to be wired through from the concentration data, which is tracked for a future PKNCA update. For full pipeline support, use `hl_method = "log-linear"` (default) and call `pk.calc.half.life()` with `hl_method = "tobit"` directly for targeted analyses.
### Tobit through the `pk.nca()` pipeline (≥ 0.12.2)

The full pipeline supports Tobit end-to-end. Supply the LLOQ with the `lloq` argument of `PKNCAconc()` — either a numeric scalar or the name of a column in the concentration data — and select the method with `PKNCAdata(options = list(hl_method = "tobit"))`:

```{r}
d_conc_tobit <- data.frame(subject = 1, conc = conc_tobit, time = time_tobit)
d_dose_tobit <- data.frame(subject = 1, dose = 100, time = 0)

o_conc_tobit <- PKNCAconc(d_conc_tobit, conc ~ time | subject, lloq = 0.1)
o_dose_tobit <- PKNCAdose(d_dose_tobit, dose ~ time | subject)

tobit_interval <- data.frame(start = 0, end = Inf,
half.life = TRUE, lambda.z = TRUE,
lambda.z.n.points = TRUE)

o_nca_tobit <- pk.nca(PKNCAdata(o_conc_tobit, o_dose_tobit,
intervals = tobit_interval,
options = list(hl_method = "tobit")))

as.data.frame(o_nca_tobit) |>
filter(PPTESTCD %in% c("half.life", "lambda.z", "lambda.z.n.points",
"lambda.z.n.points_blq", "tobit_residual",
"adj_tobit_residual")) |>
select(PPTESTCD, PPORRES)
```

The λz and half-life match the direct `pk.calc.half.life()` call above, and `lambda.z.n.points_blq` confirms that the two BLQ observations entered the regression as censored points. The LLOQ must be set on `PKNCAconc()` — with `hl_method = "tobit"` and no `lloq`, `pk.nca()` stops with an error.

Tobit adds new output columns to the result:

Expand Down
Loading