Getting prediction when EVID = 1


I have a question about getting prediction when EVID = 1. Seems both inspect() and predict() don’t provide predictions at the time points when EVID = 1. Currently, I am working around by setting dense obstimes and imputing prediction. Is there any methods getting prediction when EVID = 1? Thank you.

Hello @Dawoon.

EVIDs equal to 1 are dosing events. I don’t know if that should be covered on a prediction or inspection.

EVID, event ID:

  • 0 = observation. The DV value of this record will be used in the estimation if MDV = 0.
  • 1 = dose. The AMT, II, RATE, and ADDL of this record will be used for the drug input information. Dose records for each dose event may occur throughout the individual’s data set.

Hello @storopoli,
Sorry my question was confusing.
Actually my question was that if there are any methods to get prediction at the time points our data already have when we use obstimes inside of predict(). If we use obstimes, it provides prediction at obstimes only and we can’t get prediction at the time points our data already have. Currently I am running two predict() with/without obstimes to get prediction at both obstimes and the time points my data have. Thank you.


That is certainly annoying. Luckily, we have changed this is the version of Pumas that we are getting ready for release. In v2.2 predict(...; obstimes=[t1, t2, t3]) will produce predictions at the data points in the subject as well as the the time points given as the obstimes keyword argument.

Let me show you a simple example of how it will be in v2.2

_m = @model begin    
    @derived begin
        mydv ~ Normal.(t)

This is a very simple, almost empty, model. The only content is a dependent variable that is just a normally distributed variable around the current time point. So the observations will be the time plus some standard normal noise. Let us create a simple subject with an observation at time zero and an empty random effect NamedTuple (because there are none in the model)

sub = [Subject(id = 1, time = [0.0], observations=(mydv=[0.4],))]
eta = NamedTuple()

then we predict at obstime 0.3 and create a dataframe from it

julia> DataFrame(predict(_m, sub, eta; obstimes=[0.3]))
2×6 DataFrame
 Row │ id      time     evid    mydv       mydv_pred   mydv_ipred 
     │ String  Float64  Int64?  Float64?   Float64?    Float64?    
   1 │ 1           0.0       0        0.4         0.0          0.0
   2 │ 1           0.3       0  missing           0.3          0.3

We see here, that we get a DataFrame with the observation at time 0.0 filled out, and we also get predictions at both time 0.0 (the time point “in the subject”) and 0.3 (the time point we asked for).

Again, this is in v2.2. For now, you have to predict twice.

Hope this helped.

Hello @patrick,
Thank you for your kind explanation. Good to hear that it will be updated in the next release!