# Example I: Single-subject nonlinear non-compartmental analysis
df <- data.frame(
time = c(0.25, 0.5, 1, 2, 4, 6, 8, 12),
concentration = c(18.4, 16.9, 14.3, 10.9, 7.1, 4.7, 3.2, 2.0)
)
non_compartmental_nl(
data = df,
time_col = "time",
conc_col = "concentration",
dose = 100,
terminal_points = 3,
plot = TRUE,
annotate = TRUE
)
# Example II: Two-group nonlinear NCA (e.g., formulation comparison)
df_groups <- data.frame(
time = rep(c(0.25, 0.5, 1, 2, 4, 6, 8), 2),
concentration = c(
17.8, 16.3, 13.9, 10.5, 6.6, 4.3, 3.0, # Group A
20.1, 18.7, 16.2, 12.7, 8.4, 5.9, 4.1 # Group B
),
formulation = rep(c("Reference", "Test"), each = 7)
)
non_compartmental_nl(
data = df_groups,
time_col = "time",
conc_col = "concentration",
dose = 100,
group_col = "formulation",
terminal_points = 3,
plot = TRUE,
annotate = TRUE
)
# Example III: Six-subject nonlinear NCA
df_subjects <- data.frame(
time = rep(c(0.5, 1, 2, 4, 8, 12, 24), 6),
concentration = c(
15.6, 14.1, 11.7, 7.9, 4.3, 2.8, 1.4, # S1
14.9, 13.5, 11.1, 7.4, 4.0, 2.6, 1.3, # S2
16.3, 14.9, 12.4, 8.4, 4.7, 3.1, 1.6, # S3
15.1, 13.7, 11.3, 7.6, 4.2, 2.7, 1.3, # S4
14.6, 13.2, 10.8, 7.2, 3.9, 2.5, 1.2, # S5
16.0, 14.6, 12.0, 8.1, 4.5, 3.0, 1.5 # S6
),
subject = rep(paste0("S", 1:6), each = 7)
)
non_compartmental_nl(
data = df_subjects,
time_col = "time",
conc_col = "concentration",
dose = 150,
group_col = "subject",
terminal_points = 4,
plot = TRUE,
annotate = FALSE
)
Run the code above in your browser using DataLab