Discrete Response Models

November 2020

Introduction

In this tutorial we will go over the simulation of discrete responses. Many pharmacometrics scenarios have observables, such as pain scores or counts, which necessarily have to be discrete. Handling this discreteness can be paramount to getting an appropriate data fit and to properly understand the variation.

Luckily, in Pumas, discrete outputs are handled no differently from the rest of the Pumas toolchain. In Pumas, to have a discrete distribution as output, simply have that your derived or observed variables come from a discrete distribution like a Poisson process.

using PumasTutorials, Pumas, CSV

Poisson Response Example

Next let's use a Poisson counting process in our model. Here we generate a population where everyone is receiving the same doses as a covariate.

pop = map(i -> Subject(id=i, covariates=(dose=i.*10,), time=[0.0]), 1:10)
Population
  Subjects: 10
  Covariates: dose

Now we define our model without dynamics, and directly use the dose information to predict the count for some observable dv:

poisson_model = @model begin
  @param begin
    tvbase  RealDomain(init=3.0, lower=0.1)
    d50  RealDomain(init=50, lower=0.1)
    Ω   PSDDomain(fill(0.1, 1, 1))
  end

  @random begin
    η ~ MvNormal(Ω)
  end

 @covariates dose

  @pre begin
    _dose = dose
    baseline = tvbase*exp(η[1])
  end

  @derived begin
    dv ~ @. Poisson(baseline*(1-_dose/(_dose + d50)))
  end
end
PumasModel
  Parameters: tvbase, d50, Ω
  Random effects: η
  Covariates: dose
  Dynamical variables: 
  Derived: dv
  Observed: dv

and simulate runs from the model:

sim = simobs(poisson_model,pop)
simdf = DataFrame(sim, include_events=false)

10 rows × 4 columns

idtimedvdose
StringFloat64Int64?Int64
110.0010
220.0220
330.0330
440.0340
550.0150
660.0160
770.0570
880.0280
990.0290
10100.00100

Here dv is an integer output probabilistically dependent on the dose.

Let's read the data back in to re-estimate the model parameters

poisson_pop = read_pumas(simdf, observations=[:dv], covariates=[:dose], event_data=false)
Population
  Subjects: 10
  Covariates: dose
  Observables: dv
poisson_res = fit(poisson_model,poisson_pop, init_param(poisson_model),Pumas.FOCE())
coeftable(poisson_res)
Iter     Function value   Gradient norm 
     0     1.837736e+01     2.438069e+00
 * time: 8.893013000488281e-5
     1     1.804005e+01     6.986553e-01
 * time: 0.031138896942138672
     2     1.783401e+01     5.954670e-01
 * time: 0.038372039794921875
     3     1.749664e+01     1.271697e+00
 * time: 0.04592704772949219
     4     1.742326e+01     5.138982e-01
 * time: 0.053856849670410156
     5     1.733529e+01     1.702632e-01
 * time: 0.06073498725891113
     6     1.727485e+01     2.174638e-01
 * time: 0.06707382202148438
     7     1.724957e+01     2.066825e-01
 * time: 0.07513689994812012
     8     1.723941e+01     2.787934e-02
 * time: 0.08196592330932617
     9     1.723580e+01     1.267279e-01
 * time: 0.08817791938781738
    10     1.723449e+01     2.596766e-02
 * time: 0.09417104721069336
    11     1.723405e+01     3.361258e-02
 * time: 0.10069799423217773
    12     1.723361e+01     3.055200e-02
 * time: 0.10691094398498535
    13     1.723284e+01     2.770729e-02
 * time: 0.11296701431274414
    14     1.723131e+01     2.892494e-02
 * time: 0.11925697326660156
    15     1.722866e+01     3.060697e-02
 * time: 0.12533998489379883
    16     1.722719e+01     4.387555e-03
 * time: 0.1318349838256836
    17     1.722714e+01     1.509543e-02
 * time: 0.13791298866271973
    18     1.722709e+01     1.553463e-02
 * time: 0.144273042678833
    19     1.722695e+01     2.180326e-02
 * time: 0.15015888214111328
    20     1.722686e+01     1.032108e-02
 * time: 0.1558518409729004
    21     1.722678e+01     1.514685e-02
 * time: 0.16093087196350098
    22     1.722674e+01     1.496457e-03
 * time: 0.16606497764587402
    23     1.722672e+01     3.704382e-03
 * time: 0.1710219383239746
    24     1.722670e+01     2.409635e-03
 * time: 0.18017983436584473
    25     1.722670e+01     1.209760e-03
 * time: 0.1867969036102295
    26     1.722669e+01     7.732973e-04
 * time: 0.19261503219604492

3 rows × 2 columns

parameterestimate
StringFloat64
1tvbase1.84179
2d501.22131e6
3Ω₁,₁0.0627795

Negative Binomial Example

Next let's use a NegativeBinomial counting process in our model. We will use an internal dataset as an example.

pd_poisson = read_pumas(example_data("sim_poisson"), covariates = [:dose], event_data=false)
Population
  Subjects: 20
  Covariates: dose
  Observables: dv

Now we define our model without dynamics, and directly use the dose information to predict the count for some observable dv:

negativebinomial_model = @model begin
  @param begin
    θ₁  RealDomain(init=3.0, lower=0.1)
    θ₂  RealDomain(init=0.5, lower=0.1)
    ω   RealDomain(init=1.0, lower=0.0)
    θr   RealDomain(init=1.0, lower=0.0)
  end

  @random begin
    η ~ Normal(0.0, ω)
  end

  @pre begin
    baseline = θ₁*exp(η[1])
    d50 = θ₂
    dose_d50 = dose/(dose+d50)
    r = θr
  end

  @covariates dose

  @vars begin
    m = baseline*(1 - dose_d50)
    p = r/(m + r)
  end

  @derived begin
    dv ~ @. NegativeBinomial(r, p)
  end
end

param = init_param(negativebinomial_model)
(θ₁ = 3.0, θ₂ = 0.5, ω = 1.0, θr = 1.0)

and simulate runs from the model:

sim_negativebinomial = simobs(negativebinomial_model, pd_poisson, param; ensemblealg = EnsembleSerial())
20-element Array{Pumas.SimulatedObservations{Pumas.Subject{NamedTuple{(:dv,
),Tuple{Array{Union{Missing, Float64},1}}},Pumas.ConstantInterpolationStruc
tArray{Array{Float64,1},StructArrays.StructArray{NamedTuple{(:dose,),Tuple{
Float64}},1,NamedTuple{(:dose,),Tuple{Array{Float64,1}}},Int64},Symbol},Arr
ay{Pumas.Event{Float64,Float64,Float64,Float64,Float64,Float64,Nothing,Int6
4},1},Array{Float64,1}},Array{Float64,1},NamedTuple{(:dv, :m, :p),Tuple{Arr
ay{Int64,1},Array{Float64,1},Array{Float64,1}}}},1}:
 Pumas.SimulatedObservations{Pumas.Subject{NamedTuple{(:dv,),Tuple{Array{Un
ion{Missing, Float64},1}}},Pumas.ConstantInterpolationStructArray{Array{Flo
at64,1},StructArrays.StructArray{NamedTuple{(:dose,),Tuple{Float64}},1,Name
dTuple{(:dose,),Tuple{Array{Float64,1}}},Int64},Symbol},Array{Pumas.Event{F
loat64,Float64,Float64,Float64,Float64,Float64,Nothing,Int64},1},Array{Floa
t64,1}},Array{Float64,1},NamedTuple{(:dv, :m, :p),Tuple{Array{Int64,1},Arra
y{Float64,1},Array{Float64,1}}}}(Subject
  ID: 1
  Events: 0
  Observables: dv: (n=90)
  Covariates: dose
, [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0  …  80.0, 81.0, 82.0, 8
3.0, 84.0, 85.0, 86.0, 87.0, 88.0, 89.0], (dv = [5, 0, 11, 5, 4, 0, 1, 4, 2
, 0  …  0, 2, 2, 1, 0, 2, 2, 0, 3, 1], m = [4.154333314642176, 4.1543333146
42176, 4.154333314642176, 4.154333314642176, 4.154333314642176, 4.154333314
642176, 4.154333314642176, 4.154333314642176, 4.154333314642176, 4.15433331
4642176  …  1.7309722144342397, 1.7309722144342397, 1.7309722144342397, 1.7
309722144342397, 1.7309722144342397, 1.7309722144342397, 1.7309722144342397
, 1.7309722144342397, 1.7309722144342397, 1.7309722144342397], p = [0.19401
151205321732, 0.19401151205321732, 0.19401151205321732, 0.19401151205321732
, 0.19401151205321732, 0.19401151205321732, 0.19401151205321732, 0.19401151
205321732, 0.19401151205321732, 0.19401151205321732  …  0.3661699649357892,
 0.3661699649357892, 0.3661699649357892, 0.3661699649357892, 0.366169964935
7892, 0.3661699649357892, 0.3661699649357892, 0.3661699649357892, 0.3661699
649357892, 0.3661699649357892]), :Success)
 Pumas.SimulatedObservations{Pumas.Subject{NamedTuple{(:dv,),Tuple{Array{Un
ion{Missing, Float64},1}}},Pumas.ConstantInterpolationStructArray{Array{Flo
at64,1},StructArrays.StructArray{NamedTuple{(:dose,),Tuple{Float64}},1,Name
dTuple{(:dose,),Tuple{Array{Float64,1}}},Int64},Symbol},Array{Pumas.Event{F
loat64,Float64,Float64,Float64,Float64,Float64,Nothing,Int64},1},Array{Floa
t64,1}},Array{Float64,1},NamedTuple{(:dv, :m, :p),Tuple{Array{Int64,1},Arra
y{Float64,1},Array{Float64,1}}}}(Subject
  ID: 2
  Events: 0
  Observables: dv: (n=90)
  Covariates: dose
, [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0  …  80.0, 81.0, 82.0, 8
3.0, 84.0, 85.0, 86.0, 87.0, 88.0, 89.0], (dv = [0, 0, 0, 2, 0, 0, 1, 1, 0,
 0  …  0, 2, 0, 0, 1, 0, 0, 0, 1, 0], m = [0.6588758872281433, 0.6588758872
281433, 0.6588758872281433, 0.6588758872281433, 0.6588758872281433, 0.65887
58872281433, 0.6588758872281433, 0.6588758872281433, 0.6588758872281433, 0.
6588758872281433  …  0.274531619678393, 0.274531619678393, 0.27453161967839
3, 0.274531619678393, 0.274531619678393, 0.274531619678393, 0.2745316196783
93, 0.274531619678393, 0.274531619678393, 0.274531619678393], p = [0.602817
8525585327, 0.6028178525585327, 0.6028178525585327, 0.6028178525585327, 0.6
028178525585327, 0.6028178525585327, 0.6028178525585327, 0.6028178525585327
, 0.6028178525585327, 0.6028178525585327  …  0.7846019546006504, 0.78460195
46006504, 0.7846019546006504, 0.7846019546006504, 0.7846019546006504, 0.784
6019546006504, 0.7846019546006504, 0.7846019546006504, 0.7846019546006504, 
0.7846019546006504]), :Success)
 Pumas.SimulatedObservations{Pumas.Subject{NamedTuple{(:dv,),Tuple{Array{Un
ion{Missing, Float64},1}}},Pumas.ConstantInterpolationStructArray{Array{Flo
at64,1},StructArrays.StructArray{NamedTuple{(:dose,),Tuple{Float64}},1,Name
dTuple{(:dose,),Tuple{Array{Float64,1}}},Int64},Symbol},Array{Pumas.Event{F
loat64,Float64,Float64,Float64,Float64,Float64,Nothing,Int64},1},Array{Floa
t64,1}},Array{Float64,1},NamedTuple{(:dv, :m, :p),Tuple{Array{Int64,1},Arra
y{Float64,1},Array{Float64,1}}}}(Subject
  ID: 3
  Events: 0
  Observables: dv: (n=90)
  Covariates: dose
, [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0  …  80.0, 81.0, 82.0, 8
3.0, 84.0, 85.0, 86.0, 87.0, 88.0, 89.0], (dv = [1, 0, 1, 2, 0, 2, 1, 5, 0,
 2  …  0, 0, 0, 0, 0, 0, 0, 0, 0, 1], m = [0.5622775745847337, 0.5622775745
847337, 0.5622775745847337, 0.5622775745847337, 0.5622775745847337, 0.56227
75745847337, 0.5622775745847337, 0.5622775745847337, 0.5622775745847337, 0.
5622775745847337  …  0.23428232274363903, 0.23428232274363903, 0.2342823227
4363903, 0.23428232274363903, 0.23428232274363903, 0.23428232274363903, 0.2
3428232274363903, 0.23428232274363903, 0.23428232274363903, 0.2342823227436
3903], p = [0.6400911184210067, 0.6400911184210067, 0.6400911184210067, 0.6
400911184210067, 0.6400911184210067, 0.6400911184210067, 0.6400911184210067
, 0.6400911184210067, 0.6400911184210067, 0.6400911184210067  …  0.81018741
13996368, 0.8101874113996368, 0.8101874113996368, 0.8101874113996368, 0.810
1874113996368, 0.8101874113996368, 0.8101874113996368, 0.8101874113996368, 
0.8101874113996368, 0.8101874113996368]), :Success)
 Pumas.SimulatedObservations{Pumas.Subject{NamedTuple{(:dv,),Tuple{Array{Un
ion{Missing, Float64},1}}},Pumas.ConstantInterpolationStructArray{Array{Flo
at64,1},StructArrays.StructArray{NamedTuple{(:dose,),Tuple{Float64}},1,Name
dTuple{(:dose,),Tuple{Array{Float64,1}}},Int64},Symbol},Array{Pumas.Event{F
loat64,Float64,Float64,Float64,Float64,Float64,Nothing,Int64},1},Array{Floa
t64,1}},Array{Float64,1},NamedTuple{(:dv, :m, :p),Tuple{Array{Int64,1},Arra
y{Float64,1},Array{Float64,1}}}}(Subject
  ID: 4
  Events: 0
  Observables: dv: (n=90)
  Covariates: dose
, [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0  …  80.0, 81.0, 82.0, 8
3.0, 84.0, 85.0, 86.0, 87.0, 88.0, 89.0], (dv = [2, 3, 0, 0, 0, 0, 0, 3, 1,
 1  …  1, 1, 0, 0, 0, 0, 0, 0, 0, 0], m = [0.79648453752687, 0.796484537526
87, 0.79648453752687, 0.79648453752687, 0.79648453752687, 0.79648453752687,
 0.79648453752687, 0.79648453752687, 0.79648453752687, 0.79648453752687  … 
 0.33186855730286247, 0.33186855730286247, 0.33186855730286247, 0.331868557
30286247, 0.33186855730286247, 0.33186855730286247, 0.33186855730286247, 0.
33186855730286247, 0.33186855730286247, 0.33186855730286247], p = [0.556642
6980644374, 0.5566426980644374, 0.5566426980644374, 0.5566426980644374, 0.5
566426980644374, 0.5566426980644374, 0.5566426980644374, 0.5566426980644374
, 0.5566426980644374, 0.5566426980644374  …  0.7508248426744737, 0.75082484
26744737, 0.7508248426744737, 0.7508248426744737, 0.7508248426744737, 0.750
8248426744737, 0.7508248426744737, 0.7508248426744737, 0.7508248426744737, 
0.7508248426744737]), :Success)
 Pumas.SimulatedObservations{Pumas.Subject{NamedTuple{(:dv,),Tuple{Array{Un
ion{Missing, Float64},1}}},Pumas.ConstantInterpolationStructArray{Array{Flo
at64,1},StructArrays.StructArray{NamedTuple{(:dose,),Tuple{Float64}},1,Name
dTuple{(:dose,),Tuple{Array{Float64,1}}},Int64},Symbol},Array{Pumas.Event{F
loat64,Float64,Float64,Float64,Float64,Float64,Nothing,Int64},1},Array{Floa
t64,1}},Array{Float64,1},NamedTuple{(:dv, :m, :p),Tuple{Array{Int64,1},Arra
y{Float64,1},Array{Float64,1}}}}(Subject
  ID: 5
  Events: 0
  Observables: dv: (n=90)
  Covariates: dose
, [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0  …  80.0, 81.0, 82.0, 8
3.0, 84.0, 85.0, 86.0, 87.0, 88.0, 89.0], (dv = [3, 3, 2, 3, 9, 14, 28, 15,
 4, 11  …  1, 2, 2, 1, 1, 2, 3, 5, 0, 0], m = [9.077738336678, 9.0777383366
78, 9.077738336678, 9.077738336678, 9.077738336678, 9.077738336678, 9.07773
8336678, 9.077738336678, 9.077738336678, 9.077738336678  …  3.7823909736158
328, 3.7823909736158328, 3.7823909736158328, 3.7823909736158328, 3.78239097
36158328, 3.7823909736158328, 3.7823909736158328, 3.7823909736158328, 3.782
3909736158328, 3.7823909736158328], p = [0.09922861326538843, 0.09922861326
538843, 0.09922861326538843, 0.09922861326538843, 0.09922861326538843, 0.09
922861326538843, 0.09922861326538843, 0.09922861326538843, 0.09922861326538
843, 0.09922861326538843  …  0.20910042811575646, 0.20910042811575646, 0.20
910042811575646, 0.20910042811575646, 0.20910042811575646, 0.20910042811575
646, 0.20910042811575646, 0.20910042811575646, 0.20910042811575646, 0.20910
042811575646]), :Success)
 Pumas.SimulatedObservations{Pumas.Subject{NamedTuple{(:dv,),Tuple{Array{Un
ion{Missing, Float64},1}}},Pumas.ConstantInterpolationStructArray{Array{Flo
at64,1},StructArrays.StructArray{NamedTuple{(:dose,),Tuple{Float64}},1,Name
dTuple{(:dose,),Tuple{Array{Float64,1}}},Int64},Symbol},Array{Pumas.Event{F
loat64,Float64,Float64,Float64,Float64,Float64,Nothing,Int64},1},Array{Floa
t64,1}},Array{Float64,1},NamedTuple{(:dv, :m, :p),Tuple{Array{Int64,1},Arra
y{Float64,1},Array{Float64,1}}}}(Subject
  ID: 6
  Events: 0
  Observables: dv: (n=90)
  Covariates: dose
, [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0  …  80.0, 81.0, 82.0, 8
3.0, 84.0, 85.0, 86.0, 87.0, 88.0, 89.0], (dv = [0, 8, 1, 1, 1, 0, 5, 5, 0,
 1  …  1, 0, 4, 0, 0, 1, 2, 0, 2, 2], m = [2.718436049368227, 2.71843604936
8227, 2.718436049368227, 2.718436049368227, 2.718436049368227, 2.7184360493
68227, 2.718436049368227, 2.718436049368227, 2.718436049368227, 2.718436049
368227  …  1.132681687236761, 1.132681687236761, 1.132681687236761, 1.13268
1687236761, 1.132681687236761, 1.132681687236761, 1.132681687236761, 1.1326
81687236761, 1.132681687236761, 1.132681687236761], p = [0.2689302671132136
, 0.2689302671132136, 0.2689302671132136, 0.2689302671132136, 0.26893026711
32136, 0.2689302671132136, 0.2689302671132136, 0.2689302671132136, 0.268930
2671132136, 0.2689302671132136  …  0.46889322770697395, 0.46889322770697395
, 0.46889322770697395, 0.46889322770697395, 0.46889322770697395, 0.46889322
770697395, 0.46889322770697395, 0.46889322770697395, 0.46889322770697395, 0
.46889322770697395]), :Success)
 Pumas.SimulatedObservations{Pumas.Subject{NamedTuple{(:dv,),Tuple{Array{Un
ion{Missing, Float64},1}}},Pumas.ConstantInterpolationStructArray{Array{Flo
at64,1},StructArrays.StructArray{NamedTuple{(:dose,),Tuple{Float64}},1,Name
dTuple{(:dose,),Tuple{Array{Float64,1}}},Int64},Symbol},Array{Pumas.Event{F
loat64,Float64,Float64,Float64,Float64,Float64,Nothing,Int64},1},Array{Floa
t64,1}},Array{Float64,1},NamedTuple{(:dv, :m, :p),Tuple{Array{Int64,1},Arra
y{Float64,1},Array{Float64,1}}}}(Subject
  ID: 7
  Events: 0
  Observables: dv: (n=90)
  Covariates: dose
, [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0  …  80.0, 81.0, 82.0, 8
3.0, 84.0, 85.0, 86.0, 87.0, 88.0, 89.0], (dv = [6, 2, 0, 8, 14, 3, 2, 33, 
1, 10  …  13, 13, 18, 5, 9, 5, 9, 1, 19, 4], m = [13.953250020519185, 13.95
3250020519185, 13.953250020519185, 13.953250020519185, 13.953250020519185, 
13.953250020519185, 13.953250020519185, 13.953250020519185, 13.953250020519
185, 13.953250020519185  …  5.813854175216327, 5.813854175216327, 5.8138541
75216327, 5.813854175216327, 5.813854175216327, 5.813854175216327, 5.813854
175216327, 5.813854175216327, 5.813854175216327, 5.813854175216327], p = [0
.0668750939513335, 0.0668750939513335, 0.0668750939513335, 0.06687509395133
35, 0.0668750939513335, 0.0668750939513335, 0.0668750939513335, 0.066875093
9513335, 0.0668750939513335, 0.0668750939513335  …  0.14675981820057837, 0.
14675981820057837, 0.14675981820057837, 0.14675981820057837, 0.146759818200
57837, 0.14675981820057837, 0.14675981820057837, 0.14675981820057837, 0.146
75981820057837, 0.14675981820057837]), :Success)
 Pumas.SimulatedObservations{Pumas.Subject{NamedTuple{(:dv,),Tuple{Array{Un
ion{Missing, Float64},1}}},Pumas.ConstantInterpolationStructArray{Array{Flo
at64,1},StructArrays.StructArray{NamedTuple{(:dose,),Tuple{Float64}},1,Name
dTuple{(:dose,),Tuple{Array{Float64,1}}},Int64},Symbol},Array{Pumas.Event{F
loat64,Float64,Float64,Float64,Float64,Float64,Nothing,Int64},1},Array{Floa
t64,1}},Array{Float64,1},NamedTuple{(:dv, :m, :p),Tuple{Array{Int64,1},Arra
y{Float64,1},Array{Float64,1}}}}(Subject
  ID: 8
  Events: 0
  Observables: dv: (n=90)
  Covariates: dose
, [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0  …  80.0, 81.0, 82.0, 8
3.0, 84.0, 85.0, 86.0, 87.0, 88.0, 89.0], (dv = [13, 2, 8, 6, 8, 0, 1, 1, 1
, 7  …  1, 8, 0, 1, 0, 0, 3, 1, 0, 10], m = [3.465546075676437, 3.465546075
676437, 3.465546075676437, 3.465546075676437, 3.465546075676437, 3.46554607
5676437, 3.465546075676437, 3.465546075676437, 3.465546075676437, 3.4655460
75676437  …  1.4439775315318486, 1.4439775315318486, 1.4439775315318486, 1.
4439775315318486, 1.4439775315318486, 1.4439775315318486, 1.443977531531848
6, 1.4439775315318486, 1.4439775315318486, 1.4439775315318486], p = [0.2239
3677795576677, 0.22393677795576677, 0.22393677795576677, 0.2239367779557667
7, 0.22393677795576677, 0.22393677795576677, 0.22393677795576677, 0.2239367
7795576677, 0.22393677795576677, 0.22393677795576677  …  0.4091690644034746
7, 0.40916906440347467, 0.40916906440347467, 0.40916906440347467, 0.4091690
6440347467, 0.40916906440347467, 0.40916906440347467, 0.40916906440347467, 
0.40916906440347467, 0.40916906440347467]), :Success)
 Pumas.SimulatedObservations{Pumas.Subject{NamedTuple{(:dv,),Tuple{Array{Un
ion{Missing, Float64},1}}},Pumas.ConstantInterpolationStructArray{Array{Flo
at64,1},StructArrays.StructArray{NamedTuple{(:dose,),Tuple{Float64}},1,Name
dTuple{(:dose,),Tuple{Array{Float64,1}}},Int64},Symbol},Array{Pumas.Event{F
loat64,Float64,Float64,Float64,Float64,Float64,Nothing,Int64},1},Array{Floa
t64,1}},Array{Float64,1},NamedTuple{(:dv, :m, :p),Tuple{Array{Int64,1},Arra
y{Float64,1},Array{Float64,1}}}}(Subject
  ID: 9
  Events: 0
  Observables: dv: (n=90)
  Covariates: dose
, [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0  …  80.0, 81.0, 82.0, 8
3.0, 84.0, 85.0, 86.0, 87.0, 88.0, 89.0], (dv = [0, 1, 1, 0, 15, 19, 1, 14,
 2, 4  …  1, 0, 1, 9, 1, 0, 4, 3, 0, 1], m = [3.5510330429635006, 3.5510330
429635006, 3.5510330429635006, 3.5510330429635006, 3.5510330429635006, 3.55
10330429635006, 3.5510330429635006, 3.5510330429635006, 3.5510330429635006,
 3.5510330429635006  …  1.4795971012347917, 1.4795971012347917, 1.479597101
2347917, 1.4795971012347917, 1.4795971012347917, 1.4795971012347917, 1.4795
971012347917, 1.4795971012347917, 1.4795971012347917, 1.4795971012347917], 
p = [0.21973033167626246, 0.21973033167626246, 0.21973033167626246, 0.21973
033167626246, 0.21973033167626246, 0.21973033167626246, 0.21973033167626246
, 0.21973033167626246, 0.21973033167626246, 0.21973033167626246  …  0.40329
1324829352, 0.403291324829352, 0.403291324829352, 0.403291324829352, 0.4032
91324829352, 0.403291324829352, 0.403291324829352, 0.403291324829352, 0.403
291324829352, 0.403291324829352]), :Success)
 Pumas.SimulatedObservations{Pumas.Subject{NamedTuple{(:dv,),Tuple{Array{Un
ion{Missing, Float64},1}}},Pumas.ConstantInterpolationStructArray{Array{Flo
at64,1},StructArrays.StructArray{NamedTuple{(:dose,),Tuple{Float64}},1,Name
dTuple{(:dose,),Tuple{Array{Float64,1}}},Int64},Symbol},Array{Pumas.Event{F
loat64,Float64,Float64,Float64,Float64,Float64,Nothing,Int64},1},Array{Floa
t64,1}},Array{Float64,1},NamedTuple{(:dv, :m, :p),Tuple{Array{Int64,1},Arra
y{Float64,1},Array{Float64,1}}}}(Subject
  ID: 10
  Events: 0
  Observables: dv: (n=90)
  Covariates: dose
, [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0  …  80.0, 81.0, 82.0, 8
3.0, 84.0, 85.0, 86.0, 87.0, 88.0, 89.0], (dv = [8, 14, 10, 15, 0, 0, 0, 1,
 3, 0  …  1, 0, 0, 2, 1, 1, 0, 0, 1, 0], m = [2.9248940385247453, 2.9248940
385247453, 2.9248940385247453, 2.9248940385247453, 2.9248940385247453, 2.92
48940385247453, 2.9248940385247453, 2.9248940385247453, 2.9248940385247453,
 2.9248940385247453  …  1.2187058493853105, 1.2187058493853105, 1.218705849
3853105, 1.2187058493853105, 1.2187058493853105, 1.2187058493853105, 1.2187
058493853105, 1.2187058493853105, 1.2187058493853105, 1.2187058493853105], 
p = [0.2547839483523665, 0.2547839483523665, 0.2547839483523665, 0.25478394
83523665, 0.2547839483523665, 0.2547839483523665, 0.2547839483523665, 0.254
7839483523665, 0.2547839483523665, 0.2547839483523665  …  0.450713194034733
64, 0.45071319403473364, 0.45071319403473364, 0.45071319403473364, 0.450713
19403473364, 0.45071319403473364, 0.45071319403473364, 0.45071319403473364,
 0.45071319403473364, 0.45071319403473364]), :Success)
 Pumas.SimulatedObservations{Pumas.Subject{NamedTuple{(:dv,),Tuple{Array{Un
ion{Missing, Float64},1}}},Pumas.ConstantInterpolationStructArray{Array{Flo
at64,1},StructArrays.StructArray{NamedTuple{(:dose,),Tuple{Float64}},1,Name
dTuple{(:dose,),Tuple{Array{Float64,1}}},Int64},Symbol},Array{Pumas.Event{F
loat64,Float64,Float64,Float64,Float64,Float64,Nothing,Int64},1},Array{Floa
t64,1}},Array{Float64,1},NamedTuple{(:dv, :m, :p),Tuple{Array{Int64,1},Arra
y{Float64,1},Array{Float64,1}}}}(Subject
  ID: 11
  Events: 0
  Observables: dv: (n=90)
  Covariates: dose
, [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0  …  80.0, 81.0, 82.0, 8
3.0, 84.0, 85.0, 86.0, 87.0, 88.0, 89.0], (dv = [5, 0, 1, 4, 0, 0, 10, 0, 1
, 9  …  0, 2, 0, 0, 1, 2, 0, 1, 0, 0], m = [2.6224877637453146, 2.622487763
7453146, 2.6224877637453146, 2.6224877637453146, 2.6224877637453146, 2.6224
877637453146, 2.6224877637453146, 2.6224877637453146, 2.6224877637453146, 2
.6224877637453146  …  1.092703234893881, 1.092703234893881, 1.0927032348938
81, 1.092703234893881, 1.092703234893881, 1.092703234893881, 1.092703234893
881, 1.092703234893881, 1.092703234893881, 1.092703234893881], p = [0.27605
33824318825, 0.2760533824318825, 0.2760533824318825, 0.2760533824318825, 0.
2760533824318825, 0.2760533824318825, 0.2760533824318825, 0.276053382431882
5, 0.2760533824318825, 0.2760533824318825  …  0.47785084063804634, 0.477850
84063804634, 0.47785084063804634, 0.47785084063804634, 0.47785084063804634,
 0.47785084063804634, 0.47785084063804634, 0.47785084063804634, 0.477850840
63804634, 0.47785084063804634]), :Success)
 Pumas.SimulatedObservations{Pumas.Subject{NamedTuple{(:dv,),Tuple{Array{Un
ion{Missing, Float64},1}}},Pumas.ConstantInterpolationStructArray{Array{Flo
at64,1},StructArrays.StructArray{NamedTuple{(:dose,),Tuple{Float64}},1,Name
dTuple{(:dose,),Tuple{Array{Float64,1}}},Int64},Symbol},Array{Pumas.Event{F
loat64,Float64,Float64,Float64,Float64,Float64,Nothing,Int64},1},Array{Floa
t64,1}},Array{Float64,1},NamedTuple{(:dv, :m, :p),Tuple{Array{Int64,1},Arra
y{Float64,1},Array{Float64,1}}}}(Subject
  ID: 12
  Events: 0
  Observables: dv: (n=90)
  Covariates: dose
, [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0  …  80.0, 81.0, 82.0, 8
3.0, 84.0, 85.0, 86.0, 87.0, 88.0, 89.0], (dv = [3, 0, 0, 5, 1, 1, 3, 0, 1,
 2  …  0, 0, 0, 0, 0, 0, 1, 0, 0, 0], m = [1.6742413262438771, 1.6742413262
438771, 1.6742413262438771, 1.6742413262438771, 1.6742413262438771, 1.67424
13262438771, 1.6742413262438771, 1.6742413262438771, 1.6742413262438771, 1.
6742413262438771  …  0.6976005526016154, 0.6976005526016154, 0.697600552601
6154, 0.6976005526016154, 0.6976005526016154, 0.6976005526016154, 0.6976005
526016154, 0.6976005526016154, 0.6976005526016154, 0.6976005526016154], p =
 [0.37393783058635044, 0.37393783058635044, 0.37393783058635044, 0.37393783
058635044, 0.37393783058635044, 0.37393783058635044, 0.37393783058635044, 0
.37393783058635044, 0.37393783058635044, 0.37393783058635044  …  0.58906672
62492787, 0.5890667262492787, 0.5890667262492787, 0.5890667262492787, 0.589
0667262492787, 0.5890667262492787, 0.5890667262492787, 0.5890667262492787, 
0.5890667262492787, 0.5890667262492787]), :Success)
 Pumas.SimulatedObservations{Pumas.Subject{NamedTuple{(:dv,),Tuple{Array{Un
ion{Missing, Float64},1}}},Pumas.ConstantInterpolationStructArray{Array{Flo
at64,1},StructArrays.StructArray{NamedTuple{(:dose,),Tuple{Float64}},1,Name
dTuple{(:dose,),Tuple{Array{Float64,1}}},Int64},Symbol},Array{Pumas.Event{F
loat64,Float64,Float64,Float64,Float64,Float64,Nothing,Int64},1},Array{Floa
t64,1}},Array{Float64,1},NamedTuple{(:dv, :m, :p),Tuple{Array{Int64,1},Arra
y{Float64,1},Array{Float64,1}}}}(Subject
  ID: 13
  Events: 0
  Observables: dv: (n=90)
  Covariates: dose
, [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0  …  80.0, 81.0, 82.0, 8
3.0, 84.0, 85.0, 86.0, 87.0, 88.0, 89.0], (dv = [12, 0, 2, 2, 5, 3, 14, 3, 
6, 2  …  1, 0, 7, 5, 4, 2, 6, 1, 1, 1], m = [5.858793929349986, 5.858793929
349986, 5.858793929349986, 5.858793929349986, 5.858793929349986, 5.85879392
9349986, 5.858793929349986, 5.858793929349986, 5.858793929349986, 5.8587939
29349986  …  2.4411641372291606, 2.4411641372291606, 2.4411641372291606, 2.
4411641372291606, 2.4411641372291606, 2.4411641372291606, 2.441164137229160
6, 2.4411641372291606, 2.4411641372291606, 2.4411641372291606], p = [0.1457
9822783723304, 0.14579822783723304, 0.14579822783723304, 0.1457982278372330
4, 0.14579822783723304, 0.14579822783723304, 0.14579822783723304, 0.1457982
2783723304, 0.14579822783723304, 0.14579822783723304  …  0.2905993321217174
, 0.2905993321217174, 0.2905993321217174, 0.2905993321217174, 0.29059933212
17174, 0.2905993321217174, 0.2905993321217174, 0.2905993321217174, 0.290599
3321217174, 0.2905993321217174]), :Success)
 Pumas.SimulatedObservations{Pumas.Subject{NamedTuple{(:dv,),Tuple{Array{Un
ion{Missing, Float64},1}}},Pumas.ConstantInterpolationStructArray{Array{Flo
at64,1},StructArrays.StructArray{NamedTuple{(:dose,),Tuple{Float64}},1,Name
dTuple{(:dose,),Tuple{Array{Float64,1}}},Int64},Symbol},Array{Pumas.Event{F
loat64,Float64,Float64,Float64,Float64,Float64,Nothing,Int64},1},Array{Floa
t64,1}},Array{Float64,1},NamedTuple{(:dv, :m, :p),Tuple{Array{Int64,1},Arra
y{Float64,1},Array{Float64,1}}}}(Subject
  ID: 14
  Events: 0
  Observables: dv: (n=90)
  Covariates: dose
, [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0  …  80.0, 81.0, 82.0, 8
3.0, 84.0, 85.0, 86.0, 87.0, 88.0, 89.0], (dv = [2, 0, 3, 0, 1, 0, 1, 1, 0,
 3  …  0, 0, 0, 0, 0, 0, 1, 1, 2, 0], m = [1.262738566319693, 1.26273856631
9693, 1.262738566319693, 1.262738566319693, 1.262738566319693, 1.2627385663
19693, 1.262738566319693, 1.262738566319693, 1.262738566319693, 1.262738566
319693  …  0.526141069299872, 0.526141069299872, 0.526141069299872, 0.52614
1069299872, 0.526141069299872, 0.526141069299872, 0.526141069299872, 0.5261
41069299872, 0.526141069299872, 0.526141069299872], p = [0.4419423502497169
, 0.4419423502497169, 0.4419423502497169, 0.4419423502497169, 0.44194235024
97169, 0.4419423502497169, 0.4419423502497169, 0.4419423502497169, 0.441942
3502497169, 0.4419423502497169  …  0.6552474211697592, 0.6552474211697592, 
0.6552474211697592, 0.6552474211697592, 0.6552474211697592, 0.6552474211697
592, 0.6552474211697592, 0.6552474211697592, 0.6552474211697592, 0.65524742
11697592]), :Success)
 Pumas.SimulatedObservations{Pumas.Subject{NamedTuple{(:dv,),Tuple{Array{Un
ion{Missing, Float64},1}}},Pumas.ConstantInterpolationStructArray{Array{Flo
at64,1},StructArrays.StructArray{NamedTuple{(:dose,),Tuple{Float64}},1,Name
dTuple{(:dose,),Tuple{Array{Float64,1}}},Int64},Symbol},Array{Pumas.Event{F
loat64,Float64,Float64,Float64,Float64,Float64,Nothing,Int64},1},Array{Floa
t64,1}},Array{Float64,1},NamedTuple{(:dv, :m, :p),Tuple{Array{Int64,1},Arra
y{Float64,1},Array{Float64,1}}}}(Subject
  ID: 15
  Events: 0
  Observables: dv: (n=90)
  Covariates: dose
, [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0  …  80.0, 81.0, 82.0, 8
3.0, 84.0, 85.0, 86.0, 87.0, 88.0, 89.0], (dv = [1, 2, 3, 1, 0, 0, 0, 0, 0,
 0  …  1, 0, 0, 2, 0, 0, 1, 0, 0, 0], m = [1.524854424182481, 1.52485442418
2481, 1.524854424182481, 1.524854424182481, 1.524854424182481, 1.5248544241
82481, 1.524854424182481, 1.524854424182481, 1.524854424182481, 1.524854424
182481  …  0.6353560100760337, 0.6353560100760337, 0.6353560100760337, 0.63
53560100760337, 0.6353560100760337, 0.6353560100760337, 0.6353560100760337,
 0.6353560100760337, 0.6353560100760337, 0.6353560100760337], p = [0.396062
4384607, 0.3960624384607, 0.3960624384607, 0.3960624384607, 0.3960624384607
, 0.3960624384607, 0.3960624384607, 0.3960624384607, 0.3960624384607, 0.396
0624384607  …  0.6114876478507615, 0.6114876478507615, 0.6114876478507615, 
0.6114876478507615, 0.6114876478507615, 0.6114876478507615, 0.6114876478507
615, 0.6114876478507615, 0.6114876478507615, 0.6114876478507615]), :Success
)
 Pumas.SimulatedObservations{Pumas.Subject{NamedTuple{(:dv,),Tuple{Array{Un
ion{Missing, Float64},1}}},Pumas.ConstantInterpolationStructArray{Array{Flo
at64,1},StructArrays.StructArray{NamedTuple{(:dose,),Tuple{Float64}},1,Name
dTuple{(:dose,),Tuple{Array{Float64,1}}},Int64},Symbol},Array{Pumas.Event{F
loat64,Float64,Float64,Float64,Float64,Float64,Nothing,Int64},1},Array{Floa
t64,1}},Array{Float64,1},NamedTuple{(:dv, :m, :p),Tuple{Array{Int64,1},Arra
y{Float64,1},Array{Float64,1}}}}(Subject
  ID: 16
  Events: 0
  Observables: dv: (n=90)
  Covariates: dose
, [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0  …  80.0, 81.0, 82.0, 8
3.0, 84.0, 85.0, 86.0, 87.0, 88.0, 89.0], (dv = [4, 4, 0, 1, 7, 0, 1, 2, 4,
 3  …  0, 1, 0, 0, 0, 0, 1, 0, 0, 0], m = [1.7650301045711294, 1.7650301045
711294, 1.7650301045711294, 1.7650301045711294, 1.7650301045711294, 1.76503
01045711294, 1.7650301045711294, 1.7650301045711294, 1.7650301045711294, 1.
7650301045711294  …  0.7354292102379705, 0.7354292102379705, 0.735429210237
9705, 0.7354292102379705, 0.7354292102379705, 0.7354292102379705, 0.7354292
102379705, 0.7354292102379705, 0.7354292102379705, 0.7354292102379705], p =
 [0.3616597151498664, 0.3616597151498664, 0.3616597151498664, 0.36165971514
98664, 0.3616597151498664, 0.3616597151498664, 0.3616597151498664, 0.361659
7151498664, 0.3616597151498664, 0.3616597151498664  …  0.5762263272397468, 
0.5762263272397468, 0.5762263272397468, 0.5762263272397468, 0.5762263272397
468, 0.5762263272397468, 0.5762263272397468, 0.5762263272397468, 0.57622632
72397468, 0.5762263272397468]), :Success)
 Pumas.SimulatedObservations{Pumas.Subject{NamedTuple{(:dv,),Tuple{Array{Un
ion{Missing, Float64},1}}},Pumas.ConstantInterpolationStructArray{Array{Flo
at64,1},StructArrays.StructArray{NamedTuple{(:dose,),Tuple{Float64}},1,Name
dTuple{(:dose,),Tuple{Array{Float64,1}}},Int64},Symbol},Array{Pumas.Event{F
loat64,Float64,Float64,Float64,Float64,Float64,Nothing,Int64},1},Array{Floa
t64,1}},Array{Float64,1},NamedTuple{(:dv, :m, :p),Tuple{Array{Int64,1},Arra
y{Float64,1},Array{Float64,1}}}}(Subject
  ID: 17
  Events: 0
  Observables: dv: (n=90)
  Covariates: dose
, [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0  …  80.0, 81.0, 82.0, 8
3.0, 84.0, 85.0, 86.0, 87.0, 88.0, 89.0], (dv = [7, 15, 9, 38, 3, 0, 9, 6, 
2, 8  …  3, 1, 0, 8, 0, 1, 0, 3, 0, 0], m = [7.084502652010831, 7.084502652
010831, 7.084502652010831, 7.084502652010831, 7.084502652010831, 7.08450265
2010831, 7.084502652010831, 7.084502652010831, 7.084502652010831, 7.0845026
52010831  …  2.9518761050045126, 2.9518761050045126, 2.9518761050045126, 2.
9518761050045126, 2.9518761050045126, 2.9518761050045126, 2.951876105004512
6, 2.9518761050045126, 2.9518761050045126, 2.9518761050045126], p = [0.1236
9344696191961, 0.12369344696191961, 0.12369344696191961, 0.1236934469619196
1, 0.12369344696191961, 0.12369344696191961, 0.12369344696191961, 0.1236934
4696191961, 0.12369344696191961, 0.12369344696191961  …  0.2530443701748737
5, 0.25304437017487375, 0.25304437017487375, 0.25304437017487375, 0.2530443
7017487375, 0.25304437017487375, 0.25304437017487375, 0.25304437017487375, 
0.25304437017487375, 0.25304437017487375]), :Success)
 Pumas.SimulatedObservations{Pumas.Subject{NamedTuple{(:dv,),Tuple{Array{Un
ion{Missing, Float64},1}}},Pumas.ConstantInterpolationStructArray{Array{Flo
at64,1},StructArrays.StructArray{NamedTuple{(:dose,),Tuple{Float64}},1,Name
dTuple{(:dose,),Tuple{Array{Float64,1}}},Int64},Symbol},Array{Pumas.Event{F
loat64,Float64,Float64,Float64,Float64,Float64,Nothing,Int64},1},Array{Floa
t64,1}},Array{Float64,1},NamedTuple{(:dv, :m, :p),Tuple{Array{Int64,1},Arra
y{Float64,1},Array{Float64,1}}}}(Subject
  ID: 18
  Events: 0
  Observables: dv: (n=90)
  Covariates: dose
, [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0  …  80.0, 81.0, 82.0, 8
3.0, 84.0, 85.0, 86.0, 87.0, 88.0, 89.0], (dv = [8, 3, 8, 1, 2, 2, 1, 0, 9,
 2  …  1, 3, 0, 0, 4, 0, 0, 3, 0, 1], m = [1.9549057101292306, 1.9549057101
292306, 1.9549057101292306, 1.9549057101292306, 1.9549057101292306, 1.95490
57101292306, 1.9549057101292306, 1.9549057101292306, 1.9549057101292306, 1.
9549057101292306  …  0.8145440458871793, 0.8145440458871793, 0.814544045887
1793, 0.8145440458871793, 0.8145440458871793, 0.8145440458871793, 0.8145440
458871793, 0.8145440458871793, 0.8145440458871793, 0.8145440458871793], p =
 [0.3384202739776308, 0.3384202739776308, 0.3384202739776308, 0.33842027397
76308, 0.3384202739776308, 0.3384202739776308, 0.3384202739776308, 0.338420
2739776308, 0.3384202739776308, 0.3384202739776308  …  0.5511026322378816, 
0.5511026322378816, 0.5511026322378816, 0.5511026322378816, 0.5511026322378
816, 0.5511026322378816, 0.5511026322378816, 0.5511026322378816, 0.55110263
22378816, 0.5511026322378816]), :Success)
 Pumas.SimulatedObservations{Pumas.Subject{NamedTuple{(:dv,),Tuple{Array{Un
ion{Missing, Float64},1}}},Pumas.ConstantInterpolationStructArray{Array{Flo
at64,1},StructArrays.StructArray{NamedTuple{(:dose,),Tuple{Float64}},1,Name
dTuple{(:dose,),Tuple{Array{Float64,1}}},Int64},Symbol},Array{Pumas.Event{F
loat64,Float64,Float64,Float64,Float64,Float64,Nothing,Int64},1},Array{Floa
t64,1}},Array{Float64,1},NamedTuple{(:dv, :m, :p),Tuple{Array{Int64,1},Arra
y{Float64,1},Array{Float64,1}}}}(Subject
  ID: 19
  Events: 0
  Observables: dv: (n=90)
  Covariates: dose
, [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0  …  80.0, 81.0, 82.0, 8
3.0, 84.0, 85.0, 86.0, 87.0, 88.0, 89.0], (dv = [2, 26, 46, 60, 7, 12, 12, 
9, 24, 12  …  0, 7, 8, 0, 19, 18, 4, 4, 2, 0], m = [19.880723312862816, 19.
880723312862816, 19.880723312862816, 19.880723312862816, 19.880723312862816
, 19.880723312862816, 19.880723312862816, 19.880723312862816, 19.8807233128
62816, 19.880723312862816  …  8.28363471369284, 8.28363471369284, 8.2836347
1369284, 8.28363471369284, 8.28363471369284, 8.28363471369284, 8.2836347136
9284, 8.28363471369284, 8.28363471369284, 8.28363471369284], p = [0.0478910
6129211463, 0.04789106129211463, 0.04789106129211463, 0.04789106129211463, 
0.04789106129211463, 0.04789106129211463, 0.04789106129211463, 0.0478910612
9211463, 0.04789106129211463, 0.04789106129211463  …  0.10771643120824824, 
0.10771643120824824, 0.10771643120824824, 0.10771643120824824, 0.1077164312
0824824, 0.10771643120824824, 0.10771643120824824, 0.10771643120824824, 0.1
0771643120824824, 0.10771643120824824]), :Success)
 Pumas.SimulatedObservations{Pumas.Subject{NamedTuple{(:dv,),Tuple{Array{Un
ion{Missing, Float64},1}}},Pumas.ConstantInterpolationStructArray{Array{Flo
at64,1},StructArrays.StructArray{NamedTuple{(:dose,),Tuple{Float64}},1,Name
dTuple{(:dose,),Tuple{Array{Float64,1}}},Int64},Symbol},Array{Pumas.Event{F
loat64,Float64,Float64,Float64,Float64,Float64,Nothing,Int64},1},Array{Floa
t64,1}},Array{Float64,1},NamedTuple{(:dv, :m, :p),Tuple{Array{Int64,1},Arra
y{Float64,1},Array{Float64,1}}}}(Subject
  ID: 20
  Events: 0
  Observables: dv: (n=90)
  Covariates: dose
, [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0  …  80.0, 81.0, 82.0, 8
3.0, 84.0, 85.0, 86.0, 87.0, 88.0, 89.0], (dv = [3, 4, 0, 0, 2, 5, 4, 0, 0,
 4  …  0, 1, 0, 0, 1, 0, 1, 0, 2, 0], m = [2.326711202723234, 2.32671120272
3234, 2.326711202723234, 2.326711202723234, 2.326711202723234, 2.3267112027
23234, 2.326711202723234, 2.326711202723234, 2.326711202723234, 2.326711202
723234  …  0.9694630011346809, 0.9694630011346809, 0.9694630011346809, 0.96
94630011346809, 0.9694630011346809, 0.9694630011346809, 0.9694630011346809,
 0.9694630011346809, 0.9694630011346809, 0.9694630011346809], p = [0.300597
17813238596, 0.30059717813238596, 0.30059717813238596, 0.30059717813238596,
 0.30059717813238596, 0.30059717813238596, 0.30059717813238596, 0.300597178
13238596, 0.30059717813238596, 0.30059717813238596  …  0.5077526205995557, 
0.5077526205995557, 0.5077526205995557, 0.5077526205995557, 0.5077526205995
557, 0.5077526205995557, 0.5077526205995557, 0.5077526205995557, 0.50775262
05995557, 0.5077526205995557]), :Success)

Here dv is an integer output probabilistically dependent on the dose.

Let's read the data back in to re-estimate the model parameters

pd_negativebinomial  = Subject.(sim_negativebinomial)
Population
  Subjects: 20
  Covariates: dose
  Observables: dv

And fit the data

ngebin_res = fit(negativebinomial_model, pd_negativebinomial, param, Pumas.FOCE())
coeftable(ngebin_res)
Iter     Function value   Gradient norm 
     0     3.402313e+03     1.288545e+01
 * time: 7.581710815429688e-5
     1     3.402294e+03     1.488486e+01
 * time: 0.07180500030517578
     2     3.401969e+03     8.546168e+00
 * time: 0.12686991691589355
     3     3.401865e+03     3.784037e+00
 * time: 0.1716749668121338
     4     3.401826e+03     1.148101e+00
 * time: 0.21163582801818848
     5     3.401813e+03     1.537499e+00
 * time: 0.2538290023803711
     6     3.401806e+03     1.057946e-01
 * time: 0.2890310287475586
     7     3.401806e+03     8.346833e-03
 * time: 0.3241159915924072
     8     3.401806e+03     4.236033e-03
 * time: 0.36141490936279297
     9     3.401806e+03     4.236033e-03
 * time: 0.45877599716186523
    10     3.401806e+03     4.236033e-03
 * time: 0.5728969573974609
    11     3.401806e+03     4.236033e-03
 * time: 0.6939699649810791

4 rows × 2 columns

parameterestimate
StringFloat64
1θ₁2.8551
2θ₂0.472419
3ω0.945253
4θr1.04473

and make an inference

infer(ngebin_res)  |> coeftable

4 rows × 5 columns

parameterestimateseci_lowerci_upper
StringFloat64Float64Float64Float64
1θ₁2.85510.6161981.647374.06282
2θ₂0.4724190.047140.3800270.564812
3ω0.9452530.1293570.6917181.19879
4θr1.044730.04755930.9515141.13794

Ordinal data example

Next, we look at a simple example for ordinal data. Again, we will use an internal dataset

df = copy(CSV.read(example_data("pain_remed"), DataFrame))

1,920 rows × 8 columns

idarmdosetimeconcpainorddvremed
Int64Int64Int64Float64Float64Int64Int64Int64
112200.00.0300
212200.51.15578110
312201.01.37211010
412201.51.30058010
512202.01.19195110
612202.51.13602110
712203.00.873224010
812204.00.739963110
912205.00.600143200
1012206.00.425624110
1112207.00.363418110
1212208.00.304177110
1323800.00.0300
1423800.54.93492110
1523801.04.56849010
1623801.54.23436010
1723802.03.35444010
1823802.52.70046110
1923803.02.38586110
2023804.01.84095110
2123805.01.64535110
2223806.01.36486010
2323807.01.20802110
2423808.00.983679010

The dependent variable is coded 0:3 but Categorical distribution in julia starts indexing at 1

df.painord .+= 1
1920-element Array{Int64,1}:
 4
 2
 1
 1
 2
 2
 1
 2
 3
 2
 ⋮
 4
 3
 2
 3
 4
 4
 4
 3
 4

Now, that we made this change, lets read the data into Pumas

data = read_pumas(df,
  observations = [:painord],
  covariates = [:arm, :dose, :conc, :painord, :remed],
  event_data=false)
Population
  Subjects: 160
  Covariates: arm, dose, conc, painord, remed
  Observables: painord

the ordinal model is below

ordinal_model = @model begin
  @param begin
    b₁     RealDomain(init=2.90692)
    b₂     RealDomain(init=-2.97771, lower=-1000000, upper=1)
    b₃     RealDomain(init=-2.7541 , lower=-1000000, upper=1)
    slope  RealDomain(init=0.01)
    ω      RealDomain(init=sqrt(3.10532), lower = 0.001)
  end

  @random begin
    η ~ Normal(0.0, ω)
  end

  @covariates conc

  @pre begin
    effect = slope * conc
    #Logit of cumulative probabilities
    lge₀ = @. b₁ + η + effect
    lge₁ = @. lge₀ + b₂
    lge₂ = @. lge₁ + b₃

    #Probabilities of >=0 and >=1 and >=2
    pge₀ = @. exp(lge₀) / (1.0 + exp(lge₀))
    pge₁ = @. exp(lge₁) / (1.0 + exp(lge₁))
    pge₂ = @. exp(lge₂) / (1.0 + exp(lge₂))

    #Probabilities of Y=0,1,2,3
    p₀ = @. 1.0 - pge₀
    p₁ = @. pge₀ - pge₁
    p₂ = @. pge₁ - pge₂
    p₃ = @. pge₂
  end

  @derived begin
    painord ~ @. Categorical(p₀, p₁, p₂, p₃)
  end
end
PumasModel
  Parameters: b₁, b₂, b₃, slope, ω
  Random effects: η
  Covariates: conc
  Dynamical variables: 
  Derived: painord
  Observed: painord
ordinal_res = fit(ordinal_model, data, init_param(ordinal_model), Pumas.FOCE())
coeftable(ordinal_res)
Iter     Function value   Gradient norm 
     0     2.041783e+03     1.964595e+02
 * time: 7.295608520507812e-5
     1     2.003093e+03     3.820730e+01
 * time: 0.42134809494018555
     2     2.002227e+03     1.627452e+01
 * time: 0.7927181720733643
     3     2.001863e+03     5.842769e+01
 * time: 1.176826000213623
     4     2.000221e+03     1.919622e+01
 * time: 1.5226960182189941
     5     1.998995e+03     1.015010e+01
 * time: 1.7766990661621094
     6     1.998415e+03     7.972649e+00
 * time: 2.048776149749756
     7     1.998241e+03     8.369980e-01
 * time: 2.433204174041748
     8     1.998240e+03     2.052405e-02
 * time: 2.6344521045684814
     9     1.998240e+03     4.308395e-04
 * time: 2.781684160232544

5 rows × 2 columns

parameterestimate
StringFloat64
1b₁3.36015
2b₂-3.03195
3b₃-2.76651
4slope-0.434051
5ω1.63814

and get the paremter precision with

ordinal_res |> infer |> coeftable

5 rows × 5 columns

parameterestimateseci_lowerci_upper
StringFloat64Float64Float64Float64
1b₁3.360150.1865692.994483.72582
2b₂-3.031950.117161-3.26158-2.80232
3b₃-2.766510.106537-2.97532-2.5577
4slope-0.4340510.0537037-0.539308-0.328794
5ω1.638140.1059161.430541.84573