Skip to contents

Estimates the posterior distribution of individual parameters by Sequential Importance Resampling (SIR)

Usage

poso_estim_sir(
  dat = NULL,
  prior_model = NULL,
  n_sample = 10000,
  n_resample = 1000,
  return_model = TRUE,
  nocb = FALSE
)

Arguments

dat

Dataframe. An individual subject dataset following the structure of NONMEM/rxode2 event records.

prior_model

A posologyr prior population pharmacokinetics model, a list of six objects.

n_sample

Number of samples from the S-step

n_resample

Number of samples from the R-step

return_model

A boolean. Returns a rxode2 model using the estimated ETAs if set to TRUE.

nocb

A boolean. for time-varying covariates: the next observation carried backward (nocb) interpolation style, similar to NONMEM. If FALSE, the last observation carried forward (locf) style will be used. Defaults to FALSE.

Value

If return_model is set to FALSE, a list of one element: a dataframe $eta of ETAs from the posterior distribution, estimated by Sequential Importance Resampling. If return_model is set to TRUE, a list of the dataframe of the posterior distribution of ETA, and a rxode2 model using the estimated distributions of ETAs.

Examples

# model
mod_run001 <- function() {
  ini({
    THETA_Cl <- 4.0
    THETA_Vc <- 70.0
    THETA_Ka <- 1.0
    ETA_Cl ~ 0.2
    ETA_Vc ~ 0.2
    ETA_Ka ~ 0.2
    prop.sd <- sqrt(0.05)
  })
  model({
    TVCl <- THETA_Cl
    TVVc <- THETA_Vc
    TVKa <- THETA_Ka

    Cl <- TVCl*exp(ETA_Cl)
    Vc <- TVVc*exp(ETA_Vc)
    Ka <- TVKa*exp(ETA_Ka)

    K20 <- Cl/Vc
    Cc <- centr/Vc

    d/dt(depot) = -Ka*depot
    d/dt(centr) = Ka*depot - K20*centr
    Cc ~ prop(prop.sd)
  })
}
# df_patient01: event table for Patient01, following a 30 minutes intravenous
# infusion
df_patient01 <- data.frame(ID=1,
                        TIME=c(0.0,1.0,14.0),
                        DV=c(NA,25.0,5.5),
                        AMT=c(2000,0,0),
                        EVID=c(1,0,0),
                        DUR=c(0.5,NA,NA))
# estimate the posterior distribution of population parameters
poso_estim_sir(dat=df_patient01,prior_model=mod_run001,
n_sample=1e3,n_resample=1e2)
#>  
#>  
#>  
#>  
#> $eta
#>        ETA_Cl      ETA_Vc      ETA_Ka
#> 1   0.6504014 -0.46513521  0.43653693
#> 2   0.7998906 -0.03341945  0.16662057
#> 3   0.5739246 -0.05601440  0.71549851
#> 4   0.7089199 -0.17563653  0.37654151
#> 5   0.6224641 -0.44103680  0.11062341
#> 6   0.5756166 -0.54744862 -0.11639086
#> 7   0.2097388 -0.80535811 -0.39535473
#> 8   0.4410245 -0.51368224  0.18837049
#> 9   0.8041649 -0.20072306  0.23829165
#> 10  0.3270809 -0.20504934  0.30219971
#> 11  0.6224641 -0.44103680  0.11062341
#> 12  0.6901039 -0.30108197 -0.14402225
#> 13  0.5756166 -0.54744862 -0.11639086
#> 14  0.6224641 -0.44103680  0.11062341
#> 15  0.7089199 -0.17563653  0.37654151
#> 16  0.7740971 -0.30891172  0.57370521
#> 17  0.6504014 -0.46513521  0.43653693
#> 18  0.6280538 -0.23392662  0.44682453
#> 19  0.7089199 -0.17563653  0.37654151
#> 20  0.3976482 -0.64529135  0.23007851
#> 21  0.3425794 -0.70136613  0.12968425
#> 22  0.5716248 -0.36818884  0.36830570
#> 23  0.2097388 -0.80535811 -0.39535473
#> 24  0.8530497 -0.23492316  0.25581125
#> 25  0.6354166 -0.31357126  0.73866202
#> 26  0.6280538 -0.23392662  0.44682453
#> 27  0.5756166 -0.54744862 -0.11639086
#> 28  0.8530497 -0.23492316  0.25581125
#> 29  0.6354166 -0.31357126  0.73866202
#> 30  0.5480420 -0.78238693 -0.54016365
#> 31  0.6504014 -0.46513521  0.43653693
#> 32  0.6956159 -0.25114851  0.92671472
#> 33  0.3653215 -0.46129773  0.18425818
#> 34  0.4621170 -0.71068616  0.26608879
#> 35  0.2319779 -0.86032500 -0.48170475
#> 36  0.6956159 -0.25114851  0.92671472
#> 37  0.3313779 -0.54665431  0.48542548
#> 38  0.7089199 -0.17563653  0.37654151
#> 39  0.6947877 -0.46349506  0.19509695
#> 40  0.4179024 -0.58931306  0.22519506
#> 41  0.6224641 -0.44103680  0.11062341
#> 42  0.5480420 -0.78238693 -0.54016365
#> 43  0.3653215 -0.46129773  0.18425818
#> 44  0.4796500 -0.65544436 -0.11063743
#> 45  0.4737102 -0.05879126  0.68993753
#> 46  0.6224641 -0.44103680  0.11062341
#> 47  0.8041649 -0.20072306  0.23829165
#> 48  0.6441458 -0.17385456  0.07400396
#> 49  0.5480420 -0.78238693 -0.54016365
#> 50  0.5480420 -0.78238693 -0.54016365
#> 51  0.7089199 -0.17563653  0.37654151
#> 52  0.3769539 -0.82826593  0.23448758
#> 53  0.6834596 -0.07578277  0.01909532
#> 54  0.2527094 -0.21569803  0.25635943
#> 55  0.6431052 -0.37166373 -0.12400846
#> 56  0.4410245 -0.51368224  0.18837049
#> 57  0.7740971 -0.30891172  0.57370521
#> 58  0.2319779 -0.86032500 -0.48170475
#> 59  0.5716248 -0.36818884  0.36830570
#> 60  0.6280538 -0.23392662  0.44682453
#> 61  0.5756166 -0.54744862 -0.11639086
#> 62  0.5716248 -0.36818884  0.36830570
#> 63  0.6014266 -0.46330347  0.48532615
#> 64  0.4621170 -0.71068616  0.26608879
#> 65  0.2708922 -0.52232311 -0.08780402
#> 66  0.5739246 -0.05601440  0.71549851
#> 67  0.5716248 -0.36818884  0.36830570
#> 68  0.3946202 -0.37801414  0.10956928
#> 69  0.6631807  0.37417320  1.32753128
#> 70  0.6224641 -0.44103680  0.11062341
#> 71  0.6177660  0.34344899  0.79709830
#> 72  0.4796500 -0.65544436 -0.11063743
#> 73  0.6280538 -0.23392662  0.44682453
#> 74  0.2324490 -0.80580463 -0.28471752
#> 75  0.3270809 -0.20504934  0.30219971
#> 76  0.6224641 -0.44103680  0.11062341
#> 77  0.7089199 -0.17563653  0.37654151
#> 78  0.6224641 -0.44103680  0.11062341
#> 79  0.5716248 -0.36818884  0.36830570
#> 80  0.5716248 -0.36818884  0.36830570
#> 81  0.5756166 -0.54744862 -0.11639086
#> 82  0.3769539 -0.82826593  0.23448758
#> 83  0.6947877 -0.46349506  0.19509695
#> 84  0.6504014 -0.46513521  0.43653693
#> 85  0.5756166 -0.54744862 -0.11639086
#> 86  0.6224641 -0.44103680  0.11062341
#> 87  0.2944519 -0.31777262  0.32041506
#> 88  0.5065188 -0.43510689  0.59017798
#> 89  0.6354166 -0.31357126  0.73866202
#> 90  0.5065188 -0.43510689  0.59017798
#> 91  0.3951683 -0.42558280  0.21811956
#> 92  0.2486862 -0.80758491 -0.05621151
#> 93  0.7089199 -0.17563653  0.37654151
#> 94  0.4796500 -0.65544436 -0.11063743
#> 95  0.5065188 -0.43510689  0.59017798
#> 96  0.3946202 -0.37801414  0.10956928
#> 97  0.2196114 -0.43600196  0.46038729
#> 98  0.1867108 -0.72833532  0.32243635
#> 99  0.2496268 -0.29416330  0.40590506
#> 100 0.6014266 -0.46330347  0.48532615
#> 
#> $model
#> ── Solved rxode2 object ──
#> ── Parameters ($params): ──
#> # A tibble: 100 × 8
#>    sim.id THETA_Cl THETA_Vc THETA_Ka prop.sd ETA_Cl  ETA_Vc ETA_Ka
#>     <int>    <dbl>    <dbl>    <dbl>   <dbl>  <dbl>   <dbl>  <dbl>
#>  1      1        4       70        1   0.224  0.650 -0.465   0.437
#>  2      2        4       70        1   0.224  0.800 -0.0334  0.167
#>  3      3        4       70        1   0.224  0.574 -0.0560  0.715
#>  4      4        4       70        1   0.224  0.709 -0.176   0.377
#>  5      5        4       70        1   0.224  0.622 -0.441   0.111
#>  6      6        4       70        1   0.224  0.576 -0.547  -0.116
#>  7      7        4       70        1   0.224  0.210 -0.805  -0.395
#>  8      8        4       70        1   0.224  0.441 -0.514   0.188
#>  9      9        4       70        1   0.224  0.804 -0.201   0.238
#> 10     10        4       70        1   0.224  0.327 -0.205   0.302
#> # ℹ 90 more rows
#> ── Initial Conditions ($inits): ──
#> depot centr   AUC 
#>     0     0     0 
#> 
#> Simulation without uncertainty in parameters, omega, or sigma matricies
#> 
#> ── First part of data (object): ──
#> # A tibble: 200 × 14
#>   sim.id  time  TVCl  TVVc  TVKa    Cl    Vc    Ka   K20  rxCc    Cc   depot
#>    <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>   <dbl>
#> 1      1     1     4    70     1  7.67  44.0  1.55 0.174 28.5  28.5  6.42e+2
#> 2      1    14     4    70     1  7.67  44.0  1.55 0.174  4.66  4.66 1.18e-6
#> 3      2     1     4    70     1  8.90  67.7  1.18 0.131 16.2  16.2  8.37e+2
#> 4      2    14     4    70     1  8.90  67.7  1.18 0.131  5.45  5.45 1.79e-4
#> 5      3     1     4    70     1  7.10  66.2  2.05 0.107 22.2  22.2  4.50e+2
#> 6      3    14     4    70     1  7.10  66.2  2.05 0.107  7.30  7.30 1.20e-9
#> # ℹ 194 more rows
#> # ℹ 2 more variables: centr <dbl>, AUC <dbl>
#>