Incorrect pred/ipred at dosing times

When using predict for multiple doses, I’m seeing the same pred and ipred values given across dosing times and onto the following id:

Is this a known issue?

Which version of Pumas are you using?

I’m using the version on JuliaHub. status doesn’t seem to show the version for Pumas.

I am observing that the dv_ipreds are the same, but the dv’s are also the same. Is this how the raw data looks as well, or is this part of the issue?

The raw data was generated from simulations and don’t have dv’s at those dosing times.

I am running the following lines of code on the dataframe from predict:

    indices_001 = findall(ipred_df.time .== 0.001)
    indices_0 = findall(ipred_df.time .== 0)

    # reorders b/c predict puts dosing events out of order
    for j in 1:length(indices_0)
        foreach((vals, col_names) -> insert!(ipred_df[!, col_names], indices_001[j], vals), collect(ipred_df[indices_0[j],:]), names(ipred_df))
        delete!(ipred_df, indices_0[j]+1)

    indices_92 = findall(ipred_df.time .== 92)
    indices_90 = findall(ipred_df.time .== 90)

    # reorders b/c predict puts dosing events out of order
    for j in 1:length(indices_90)
        foreach((vals, col_names) -> insert!(ipred_df[!, col_names], indices_92[j], vals), collect(ipred_df[indices_90[j],:]), names(ipred_df))
        delete!(ipred_df, indices_90[j]+1)

    indices_182 = findall(ipred_df.time .== 182)
    indices_180 = findall(ipred_df.time .== 180)

    # reorders b/c predict puts dosing events out of order
    for j in 1:length(indices_180)
        foreach((vals, col_names) -> insert!(ipred_df[!, col_names], indices_182[j], vals), collect(ipred_df[indices_180[j],:]), names(ipred_df))
        delete!(ipred_df, indices_180[j]+1)

    indices_272 = findall(ipred_df.time .== 272)
    indices_270 = findall(ipred_df.time .== 270)

    # reorders b/c predict puts dosing events out of order
    for j in 1:length(indices_270)
        foreach((vals, col_names) -> insert!(ipred_df[!, col_names], indices_272[j], vals), collect(ipred_df[indices_270[j],:]), names(ipred_df))
        delete!(ipred_df, indices_270[j]+1)

Could that code cause this to happen?

Yeah. I think it’s likely. I’d warn against mutating data frame columns like you do here. It’s very error prone. Try instead to call sort! on the data frame and select the appropriate columns to sort on. Please also try checking the individual predictions before you make any modifications to the data frame.

Using sort! instead fixed the issue. Thank you!

Would you be able to take a look at the other question I also posted?