nlmixr2 / nonmem2rx

nonmem2rx
https://nlmixr2.github.io/nonmem2rx/
9 stars 0 forks source link

Remove binary linkage to dparser #184

Closed mattfidler closed 1 month ago

mattfidler commented 3 months ago

Like rxode2

mattfidler commented 2 months ago
rxui <- function() {
    ini({
        theta1 <- c(0, 6.20684)
        label("1. TVCL (lower bound,initial estimate)")
        theta2 <- c(0, 26.5004)
        label("2. TVV1  (lower bound,initial estimate)")
        theta3 <- c(0, 2.15099)
        label("3. TVQ")
        theta4 <- c(0, 21.151)
        label("4. TVV2")
        theta5 <- c(0, 0.270697)
        label("5. TVQ2")
        theta6 <- c(0, 147.893)
        label("6. TVV3")
        theta7 <- fix(55.4)
        label("7. T50")
        theta8 <- fix(3.33)
        label("8. Hill")
        theta9 <- -0.129934
        label("9. power exponent on creatinine")
        theta10 <- c(0, 1.70302)
        label("10. PNA50")
        eta1 ~ 0.175278
        eta2 ~ c(0.115896, 0.112362)
        eta3 ~ fix(0)
        eta4 ~ 0.131759
        eta5 ~ fix(0)
        eta6 ~ 0.177214
        eta7 ~ 0.0140684
        eta8 ~ fix(0.0140684)
        eta9 ~ fix(0.0140684)
        eta10 ~ fix(0.0140684)
        eta11 ~ fix(0.0140684)
        eta12 ~ fix(0.0140684)
        eta13 ~ fix(0.0140684)
        eta14 ~ fix(0.0140684)
        eta15 ~ fix(0.0140684)
        eta16 ~ fix(0.0140684)
        eta17 ~ fix(0.0140684)
        eta18 ~ fix(0.0140684)
        eta19 ~ fix(0.0140684)
        eta20 ~ fix(0.0140684)
        eta21 ~ fix(0.0140684)
        eta22 ~ fix(0.0140684)
        eta23 ~ fix(0.0140684)
        eta24 ~ fix(0.0140684)
        eta25 ~ fix(0.0140684)
        eta26 ~ fix(0.0140684)
        eta27 ~ fix(0.0140684)
        eta28 ~ fix(0.0140684)
    })
    model({
        cmt(rxddta1)
        cmt(rxddta2)
        cmt(rxddta3)
        cmt(rxddta4)
        cmt(rxddta5)
        if (newind != 2)
            OTIM1 <- 0
        if (newind != 2)
            OCOV1 <- 0
        if (newind != 2)
            OTIM2 <- 0
        if (newind != 2)
            OCOV2 <- 0
        STUDY <- 0
        if (nmid < 2000)
            STUDY <- 1
        if (nmid >= 2000 && nmid < 3000)
            STUDY <- 2
        if (nmid >= 3000)
            STUDY <- 3
        WTKG <- WT/1000
        T50 <- theta7
        HILL <- theta8
        MF <- PMA^HILL/(PMA^HILL + T50^HILL)
        CREAT2 <- CREAT
        if (CREAT < 0)
            CREAT2 <- TCREA
        P50 <- theta10
        CRPWR <- theta9
        BOVC <- 0
        if (OCC == 1)
            BOVC <- eta7
        if (OCC == 2)
            BOVC <- eta8
        if (OCC == 3)
            BOVC <- eta9
        if (OCC == 4)
            BOVC <- eta10
        if (OCC == 5)
            BOVC <- eta11
        if (OCC == 6)
            BOVC <- eta12
        if (OCC == 7)
            BOVC <- eta13
        if (OCC == 8)
            BOVC <- eta14
        if (OCC == 9)
            BOVC <- eta15
        if (OCC == 10)
            BOVC <- eta16
        if (OCC == 11)
            BOVC <- eta17
        if (OCC == 12)
            BOVC <- eta18
        if (OCC == 13)
            BOVC <- eta19
        if (OCC == 14)
            BOVC <- eta20
        if (OCC == 15)
            BOVC <- eta21
        if (OCC == 16)
            BOVC <- eta22
        if (OCC == 17)
            BOVC <- eta23
        if (OCC == 18)
            BOVC <- eta24
        if (OCC == 19)
            BOVC <- eta25
        if (OCC == 20)
            BOVC <- eta26
        if (OCC == 21)
            BOVC <- eta27
        if (OCC == 22)
            BOVC <- eta28
        TVCL <- theta1 * MF * (WTKG/70)^(0.632)
        TVV1 <- theta2 * (WTKG/70)
        TVQ <- theta3 * (WTKG/70)^(0.75)
        TVV2 <- theta4 * (WTKG/70)
        TVQ2 <- theta5 * (WTKG/70)^(0.75)
        TVV3 <- theta6 * (WTKG/70)
        CL <- TVCL * exp(eta1 + BOVC)
        V1 <- TVV1 * exp(eta2)
        Q <- TVQ * exp(eta3)
        V2 <- TVV2 * exp(eta4)
        Q2 <- TVQ2 * exp(eta5)
        V3 <- TVV3 * exp(eta6)
        K <- CL/V1
        K12 <- Q/V1
        K21 <- Q/V2
        K13 <- Q2/V1
        K31 <- Q2/V3
        if (nmevid == 1)
            TM <- t
        if (nmevid == 1)
            TAD <- 0
        if (nmevid != 1)
            TAD <- t - TM
        SL1 <- 0
        if (t > OTIM1)
            SL1 <- (PNA - OCOV1)/(t - OTIM1)
        rxini.rxddta4. <- PNA
        rxddta4(0) <- rxini.rxddta4.
        SL2 <- 0
        if (t > OTIM2)
            SL2 <- (CREAT2 - OCOV2)/(t - OTIM2)
        rxini.rxddta5. <- CREAT2
        rxddta5(0) <- rxini.rxddta5.
        d/dt(rxddta4) <- SL1
        TCOV1 <- rxddta4
        d/dt(rxddta5) <- SL2
        TCOV2 <- rxddta5
        PNAF <- TCOV1/(P50 + TCOV1)
        OF <- (TCOV2/TCREA)^CRPWR
        d/dt(rxddta1) <- rxddta3 * K31 + rxddta2 * K21 - rxddta1 *
            (K * PNAF * OF + K12 + K13)
        d/dt(rxddta2) <- rxddta1 * K12 - rxddta2 * K21
        d/dt(rxddta3) <- rxddta1 * K13 - rxddta3 * K31
        F <- rxddta1
        IPRED <- rxddta1/V1
        Y <- IPRED * (1 + eps1) + eps2
        OCOV1 <- PNA
        OTIM1 <- t
        OCOV2 <- CREAT2
        OTIM2 <- t
    })
}

rxode2::rxRename(rxui, study = STUDY, wtkg = WTKG, t50 = T50,
    hill = HILL, mf = MF, creat2 = CREAT2, p50 = P50, crpwr = CRPWR,
    bovc = BOVC, tvcl = TVCL, tvv1 = TVV1, tvq = TVQ, tvv2 = TVV2,
    tvq2 = TVQ2, tvv3 = TVV3, cl = CL, v1 = V1, q = Q, v2 = V2,
    q2 = Q2, v3 = V3, k = K, k12 = K12, k21 = K21, k13 = K13,
    k31 = K31, tm = TM, tcov1 = TCOV1, tcov2 = TCOV2, pnaf = PNAF,
    of = OF, f = F, ipred = IPRED, y = Y)