Reading Covariates with missing data

I am trying to include a covariate (Bili) into the data set. This covariate has missing rows and I get the error message : BoundsError: attempt to access 0-element Array{Float64,1} at index [0]
Any suggestions?
Here is the code:

par_glu_cov = read_pumas(df_belino,
                    cvs     =   [:Gender,:BSA, :Cohort, :Weight, :Bili],
                    dvs     =   [:Conc_B, :Conc_Glucu],
                    id      =   :Patient,
                    time    =   :Time,
                    evid    =   :evid,
                    amt     =   :Amt,
                    rate    =   :rate
                    )
 BoundsError: attempt to access 0-element Array{Float64,1} at index [0]

The problem is that for one of the subjects, there are no non-missing values of the covariate. Specifically,

julia> filter(i -> i.Patient == [xxx], df_belino)[!,[:Bili]]
14×1 DataFrame
│ Row │ Bili     │
│     │ Float64⍰ │
├─────┼──────────┤
│ 1   │ missing  │
│ 2   │ missing  │
│ 3   │ missing  │
│ 4   │ missing  │
│ 5   │ missing  │
│ 6   │ missing  │
│ 7   │ missing  │
│ 8   │ missing  │
│ 9   │ missing  │
│ 10  │ missing  │
│ 11  │ missing  │
│ 12  │ missing  │
│ 13  │ missing  │
│ 14  │ missing  │

and in that case, it’s not possible to use that covariate. The solution is probably to manually set the first entry to a reasonable value. However, we should provide a more informative error message. I’ll file an issue.

1 Like

Thanks Andreas. I get the problem now.