@@ -757,6 +757,38 @@ test_that("do not give rbind error when interval columns have attributes (#381)"
757757 )
758758})
759759
760+
761+ test_that(" pk.nca can be run for each parameter independently (#473)" , {
762+
763+ d_conc <- Theoph [Theoph $ Subject %in% " 1" , ]
764+ d_conc <- rbind(d_conc , mutate(d_conc , Time = Time + 25 ))
765+ d_conc $ volume <- 1
766+ d_conc $ duration <- 1
767+ d_dose <- data.frame (Subject = " 1" , Time = c(0 , 25 ), Dose = 5 , duration = 1 )
768+
769+ o_conc <- PKNCAconc(d_conc , formula = conc ~ Time | Subject , volume = " volume" , duration = " duration" )
770+ o_dose <- PKNCAdose(d_dose , formula = Dose ~ Time | Subject , route = " intravascular" , duration = " duration" )
771+
772+ non_pknca_covered_params <- c(
773+ " f" , " time_above" , " mrt.md.obs" , " mrt.md.pred" , " sparse_auclast" , " sparse_auc_se" , " sparse_auc_df" ,
774+ " vss.md.obs" , " vss.md.pred" , " ceoi"
775+ )
776+ all_params <- setdiff(names(get.interval.cols()), c(" start" , " end" , non_pknca_covered_params ))
777+ intervals <- data.frame (start = c(0 , 25 ), end = c(25 , Inf ))
778+
779+ for (param in all_params ){
780+ intervals_with_param <- intervals
781+ intervals_with_param [[param ]] <- TRUE
782+ o_data <- PKNCAdata(o_conc , o_dose , intervals = intervals_with_param )
783+
784+ expect_no_error(param_res <- pk.nca(o_data ))
785+ expect_false(
786+ all(is.na(param_res $ result $ PPORRES )),
787+ info = paste0(" Parameter " , param , " can be calculated independently" )
788+ )
789+ }
790+ })
791+
760792test_that(" Cannot include and exclude half-life points at the same time (#406)" , {
761793 o_conc <- PKNCAconc(data = data.frame (conc = 1 , time = 0 , inex = TRUE ), conc ~ time , include_half.life = " inex" , exclude_half.life = " inex" )
762794 d_interval <- data.frame (start = 0 , end = Inf , half.life = TRUE )
0 commit comments