Closed joybaker1 closed 3 months ago
pk.calc.auxc()
is not usually the function you want to call. You probably want to use pk.calc.auc.last()
based on your data.
Depending on exactly what you're doing, though, you probably want to do something like:
library(tidyverse)
library(PKNCA)
#>
#> Attaching package: 'PKNCA'
#> The following object is masked from 'package:stats':
#>
#> filter
df <-
data.frame(
TAFD_AD=c(0,0.25,2,4,6,8,
0,0.25,2,4,6,8),
DV= c(0,0.1,0.6,0.5,0.2,0.1,
0,0.2,0.7,0.4,0.3,0.1),
ID=c(1,1,1,1,1,1,
2,2,2,2,2,2)
)
o_conc <- PKNCAconc(df, DV~TAFD_AD|ID)
o_data <- PKNCAdata(o_conc, intervals = data.frame(start = 0, end = 8, auclast = TRUE))
o_nca <- pk.nca(o_data)
#> No dose information provided, calculations requiring dose will return NA.
summary(o_nca)
#> start end N auclast
#> 0 8 2 2.80 [7.04]
#>
#> Caption: auclast: geometric mean and geometric coefficient of variation; N: number of subjects
as.data.frame(o_nca)
#> # A tibble: 2 × 6
#> ID start end PPTESTCD PPORRES exclude
#> <dbl> <dbl> <dbl> <chr> <dbl> <chr>
#> 1 1 0 8 auclast 2.67 <NA>
#> 2 2 0 8 auclast 2.94 <NA>
# Or, if you're doing this with simulations and need many NCA calculations and
# speed is vitally important:
df_calc <-
df |>
group_by(ID) |>
summarize(AUC = pk.calc.auc.last(
conc = DV,
time = TAFD_AD,
interval = c(0, 8),
method="lin up/log down")
)
df_calc
#> # A tibble: 2 × 2
#> ID AUC
#> <dbl> <dbl>
#> 1 1 2.67
#> 2 2 2.94
Created on 2024-07-31 with reprex v2.1.0
I don't understand what this error means. I made an easy dataset to reflect the same error message I had with my larger dataset. I have updated the pknca to the latest. Thanks
Error message:
Caused by error in
auc_integrate()
: ! argument "fun_linear" is missing, with no default Runrlang::last_trace()
to see where the error occurred.