NLME: How do I write PML for 2-cpt closed form ?

Below is code illustrating how to write a closed-form population model for a 2-comparment extravascular model (with random effect on clearance). In this case, Dose and Time are defined as covariates test(){ covariate(Time,D) Ke = CL1/V1 K12 = CL2/V1 K21 = CL2/V2 beta = - 1/2 * (-(K12 + K21 + Ke) - sqrt((K12 + K21 + Ke) ^ (2) - 4 * K21 * Ke)) alpha = - 1/2 * (-(K12 + K21 + Ke) + sqrt((K12 + K21 + Ke) ^ (2) - 4 * K21 * Ke)) A = (K21-alpha)/((alpha-beta)(alpha-Ka)) B = (K21-beta)/((alpha-beta)(beta-Ka)) C = (K21-Ka)/((beta-Ka)*(alpha-Ka)) Cp = Ka * D / V1 ( A * exp(-alpha * Time) -B * exp(-beta * Time) + C exp(-Ka * Time)) error(CEps = 0.01) observe(CObs(Time) = Cp + CEps, bql) stparm(Ka = tvKa) stparm(V1 = tvV1) stparm(V2 = tvV2) stparm(CL1 = tvCL1 * exp(nCL1)) stparm(CL2 = tvCL2) fixef(tvKa = c(0, 1, )) fixef(tvV1 = c(0, 1, )) fixef(tvV2 = c(0, 1, )) fixef(tvCL1 = c(0, 1, )) fixef(tvCL2 = c(0, 1, )) ranef(diag(nCL1) = c(0.1)) }