monolix2rx 0.0.7
CRAN release: 2026-11-06
Added a Monolix stress kit (
inst/stress, like the nonmem2rx and babelmixr2 kits): it simulates each case with rxode2, writes the Monolix project, runs Monolix and checks themonolix2rx()import; a translate mode and a mock Monolix check it without Monolix.Translated discrete observations, which stopped the import: a
type=countPoisson probability becomespois(lambda)and any other count probability (log(P(Y=k))orP(Y=k), with intermediate statements andif/else)ll(Y); atype=categoricalendpoint given byP(Y=c)for all but one category, or cumulativeP(Y<=c), underlogit()/probit()/log()or not, becomes rxode2’s ordinalc(p0=0, p1=1, 2)(fitting it needs nlmixr2/rxode2#1450 fixed). Markov dependence is still not supported.Translated time-to-event observations (
type=event), which stopped the import: the hazard is integrated in a new state and each event record givesll()of an exact event, an interval censored event (eventType=intervalCensored) or no event, from the hazard since the previous record of the endpoint; the first record starts the observation. The records are found by their compartment, so the imported data gives a single event endpoint’s observations itscmt.Imported Monolix MAP priors (
[POPULATION] DEFINITION:withmethod=MAP) on typical values and covariate coefficients asini()priors on the imported theta (theiniDfpriorcolumn), the inverse of babelmixr2:ka_pop = {distribution=logNormal, typical=3, sd=0.25}becomesprior(ka_pop) ~ dnorm(log(3), 0.25). Omega and residual error priors, and a prior whose distribution differs from its parameter’s, are skipped with a warning. The import’srxSolve()keeps simulating uncertainty (nStud > 1) from Monolix’sthetaMatwithusePrior = FALSEunlessusePrioris given (nlmixr2/rxode2#1502).Matched Monolix’s steady state (
nbdoses=N: the N doses before the steady-state dose and that dose) in the validation and in the import’srxSolve()on Monolix’s data: a steady-state dose that starts its subject (on one or more routes,EVID=1or4) is written out as those doses, since rxode2’sminSSdoes not give a whole number of doses (nlmixr2/rxode2#1492). A later steady-state dose still uses rxode2’sss, exact with rxode2 newer than 5.1.8 (#1492 fixed), where the import usesminSS = maxSS = N. The start is written out with either rxode2: it also keeps steady-state doses on several routes, a lag longer thaniiand annbdosesbelow what the regimen needs.Switched
$etaDataand the validation to Monolix’s conditional modes (eta_*_mode,indivPred_mode,indWRes_mode), which reproduce each other where the_SAEMcolumns do not. The SAEM random effects are kept in$etaSaemData; a run without the modes still uses_SAEM.Dropped the re-exports (
rxode2(),rxode(),RxODE(),ini(),model(),model<-,rxRename(),rxSolve(),rxUiGet(),logit(),expit(),lotri(),autoplot()and%>%). Loadnlmixr2(orrxode2/magrittr) to get them; this also works around a roxygen2 8.1.0 re-export failure (issue #47, r-lib/roxygen2#1915).monolix2rx(),mlxtran()andmlxTxt()now havedirnto giving the actual directory of the Monolix project, in case the project moved for some reason. This makes it possible to translate project files outside the project directory (#44)The project directory in mlxtran is now absolute.
Import
Monolix2024 Excel (.xls,.xlsx; first sheet) and SAS (.sas7bdat,.xpt) data sets, usingreadxl/havenwhen they are installed (issue #10).The data set regressor columns (
use=regressorin[CONTENT]) are now matched to the model regressors (use=regressorin[LONGITUDINAL]) by their column order in the data set, as Monolix does, and renamed to the model names on import. A mismatched regressor count or a missing regressor column is now an error (issue #2).Imported
amt/time/dvcharacter columns now matchna.stringsliterally (ignoring surrounding whitespace); the default"."was a regular expression wildcard, so any single-character value was silently turned intoNA. GenuineNA, blank and"NaN"values no longer keep such a column as character (issue #56).Imported data sets now cast the continuous covariates to double; previously the categorical covariates were cast instead, turning character categories into
NA.Support the
Monolix2024 file specificationfile={path='data.csv'}in addition to the olderfile='data.csv'; the two are equivalent. This applies to the data file in<DATAFILE> [FILEINFO](and<DATA_FORMATTING> [FILEINFO]) as well as the model file in<MODEL> [LONGITUDINAL](issue #43).Categorical covariate transformations (
[COVARIATE] DEFINITION:transform=/categories=/reference=) without areferencenow fall back to the first category instead of assigning an empty label; the transformation translation is now tested end-to-end (issue #6).Range-check the input length in all 13
trans_*parser entry-points before narrowing it fordparse()’sintbuffer length. A buffer ofINT_MAXbytes or more now raises a clean R error instead of handing the parser a truncated (possibly negative) length. This is defensive: every current caller passes an R string, which R already caps atINT_MAXbytes.Removed the dparser ambiguities in the
EQUATION:/PK:,[LONGITUDINAL] DEFINITION:andfile=grammars, and made the equation statement list plain left recursive. Parsing long equation blocks is now linear instead of quadratic;if/elseblocks with function calls parse up to ~80x faster. SettingMONOLIX2RX_STRICT_AMBIGUITY(as the tests do) makes any remaining grammar ambiguity an error (issue #51).Added a warning for autocorrelated residuals (
autoCorrCoef=), which are not translated (the residuals stay independent); before, the coefficient was dropped silently.Translated the Monolix functions
rem(a, b)(toa %% b, with the sign ofalike Monolix) andsinh(), and the negations~aand!a, which were syntax errors (also after a sign or as an exponent,-~a,b^~a). In a PK macro argumentrem()is translated too and a negation is an error.Fixed implicit
ptrdiff_ttointtruncation inrc_dup_str(src/shared.c); pointer differences are now range-checked before conversion toint.Fixed
intindex/column overflow ingetLine(src/parseSyntaxErrors.h): both are nowsize_twith explicit bounds checks before use. The line buffer is nowR_alloc()’d so it is reclaimed if an error longjmps out of the syntax-error highlighter.A syntax error reported on an empty line no longer writes a NUL byte into the error report, which silently cut off the rest of the report.
rc_dup_str()now gives each duplicated string its own allocation. It used to append into one growing buffer, so a reallocation left pointers from earlier calls (held across calls, e.g. both operands of a logical operator) pointing at freed memory.A syntax error’s R error message now includes the highlighted source line and caret. They were only printed to the console because the header written to the error report first suppressed them.
Added thread-safety comment to
src/shared.cdocumenting that the global parser state is intentionally not mutex-protected, consistent with R’s single-threaded execution model.Latent categorical covariates (between-subject mixtures,
lcat = {type=categorical, categories={1, 2}, P(lcat=1)=plcat1}in[COVARIATE] DEFINITION:) are translated to rxode2’smix()(lcat <- mix(1, plcat1, 2), rxode2 >= 5.1.8) with the class probabilities inini(). Monolix’s class per subject is not read yet, so these models are not validated.Structural model mixtures in
EQUATION:are translated:wsmm(f1, p1, f2, p2)is the weighted predictionp1*f1 + p2*f2(Monolix’s definition), andbsmm(f1, p1, f2, p2)ismix(f1, p1_pop, f2)(rxode2 >= 5.1.8). Absmm()probability must be a number or an individual parameter without variability or covariates; its typical value becomes the probability inini()on its natural scale, and the model needs at least one random effect. Like the latent covariates,bsmm()models are not validated until Monolix’s class per subject is read.Fixed categorical covariate effects with numeric categories:
coefficient={0, beta}for categories{1, 2}was translated asbeta*lcatinstead ofbeta*(lcat == 2). Coefficients now follow the declared categories by position.delay(x, T)inEQUATION:is translated to rxode2’sdelay()(needs rxode2 >= 5.1.7); models with a delay are solved withdop853.pkmodel()accepts the peripheral clearances and volumesQ2,V2,Q3andV3(ask12 = Q2/V,k21 = Q2/V2, …).Fixed the order of
EQUATION:lines written beforepkmodel()or a PK macro: they were translated after the macro’s ODEs, so a rate computed there (k12 = Q/V) was used before it was defined. Lines between macros in aPK:block are no longer dropped.Fixed the inter-occasion variability level name:
varlevel={id, id*occ}gavegamma ~ ... | occ2, but the data’s occasion column isocc(id*occ*occis nowocc2).Added nested occasions (several
use=occasioncolumns): only the last column was kept, sogamma1 | occused the inner level and the inner level had no data column. The first occasion column is nowoccand the k-thocck, numbering each combination of the first k columns, for theid*occ*...levels. The parsed[CONTENT]gainedocc, every occasion column in order.Fixed
amtDose, which became a parameterdoseinstead of rxode2’s last dose amountdose().PK:macro arguments (likedepot(p=)) were copied as written; their dose keywords,t,~=, Monolix function names and chained powers are now translated.Fixed chained powers:
a^b^cwas written unchanged, which rxode2 does not parse; it is nowa^(b^c)(right associative, as in Monolix).Fixed a project without
<MONOLIX> [SETTINGS] exportpath, which stopped the import: its results are read from the directory named like the project (Monolix’s default).Fixed a categorical covariate whose categories mix numbers and strings (
categories={'U', '1', '3'}): the numbers were compared unquoted with the character data column, which rxode2 matches by level order, so a coefficient could silently apply to another category.Fixed a model without
EQUATION:orPK:(onlyDEFINITION:), whose data set was not imported, so the import was not validated.Fixed a project with continuous and discrete observations: the discrete endpoint (no prediction) translated to
NA <- Cc, and the continuous predictions were not read, so the import was not validated.Fixed
.getNbdoses()and.getStiff(), which did not recognize the parsed project and always returned 7 andFALSE: the validation andrxSolve()now use the project’snbdoses=andodeType=. The new.getSsLimits()gives the matchingminSS/maxSS:minSS = maxSS = nbdoseswith an rxode2 newer than 5.1.8, otherwise raised to rxode2’s floor (5 and 7) whennbdosesis smaller; babelmixr2, which calls.getNbdoses()directly, needs it fornbdosesbelow 6.-
Fixed the dose routing of the imported data (
$monolixData):- Without an administration column no dose was routed, because
data$admpartially matched theadmdcolumn added during the import; doses now default toadm=1, as in Monolix. - Doses went to the Monolix compartment number instead of the rxode2 compartment, so an
iv(adm=2, cmt=1)dose next tooral(adm=1, cmt=1)went to the depot; they are now routed by compartment name. - Observation rows with an
ADMvalue orAMT=0could become doses; only dose rows (an amount, and EVID 1 or 4 when there is an EVID column) are routed now. - A second macro on one administration copied only a single dose, and copied it after the first route had changed it; it now copies every unmodified dose.
-
Tk0(zero-order absorption) doses got norate=-2, sodur()was ignored; a data infusion time still takes precedence. - Transit doses (
Mtt,Ktr) were also added to the depot; they now getevid=7(anEVID=4dose becomes a reset followed byevid=7). The administration table ($admd) gained atransitcolumn. - With an
MDVcolumn and noEVIDcolumn, rxode2 read theMDV=1rows as doses; they are nowevid=2. A missingEVIDvalue on a dose is now 1. - A
use=ignoredata column named like an rxode2 event column (SS,RATE,EVID,DOSE, …) was still used by rxode2, which matches those names ignoring case; it is now dropped. - Lines flagged by a
use=ignoredlinecolumn were kept (and anMDV-named flag could make the import fail); the flagged lines, doses included, and the flag column are now dropped. The parsed[CONTENT]gainedignoreLine, theuse=ignoredlinecolumns (also still listed inignore), andas.character()now writesuse=ignorecolumns asuse = ignoreinstead ofuse = ignoredline. - A data
EVID=3line with a missing amount (AMT = .), which Monolix 2024R1 ignores, was imported as a reset; it is nowevid=2. AnEVID=4line without an amount, which stopped the import, is now ignored the same way.
- Without an administration column no dose was routed, because
Fixed
depot(target=Ac, ka)into acompartment()macro: the depot ODE and itskatransfer were dropped (onlyEQUATION:states received them), also when the compartment had no other flows.Fixed
transfer(from=1, to=2, kt): the inflow into the receiving compartment was dropped when that compartment was named later (for example byelimination(cmt=2, ...)).Fixed PK state leaking between parses: an
EQUATION:block could pick updur()/f()/alag()lines of the previously parsed model, and a[COVARIATE] EQUATION:its PK end lines.Fixed the scale of the imported
thetaMat: it was Monolix’s natural-scale covariance while theini()estimates of log-, logit- and probit-normal parameters are on the transformed scale, sorxSolve()withnStud > 1drew their uncertainty on the wrong scale.thetaMatis now on theini()(transformed) scale for both the older natural-scale and the newer transformed Monolix outputs, converted at Monolix’s final estimates.Fixed
predRtol(and the pred line of the validation), which was relative to Monolix’sipredinstead of itspred; the iwres line of the validation reported the pred median.Fixed the imported random effects of a parameter whose
sd=(orvar=) is not namedomega_<parameter>(likevar=omega2_Clor a fixedsd=0.3): Monolix’seta_Clcolumn becameomega_Cl, which is not an eta of the model, so the validation solve failed.Accepted
errorModel=combined1(a, b, c)andcombined2(a, b, c), the spelling Monolix 2024R1 saves for thecombined1c/combined2cerror models (it refusescombined1c(a, b, c)); the import failed on them.as.character()(andprint()) now write this spelling.Fixed numeric-looking subject identifiers that are equal as numbers (
1and01), which Monolix keeps apart and the import merged into one subject; the identifiers are read as text and become numbers only when no two merge (also in Excel/SAS data sets), and Monolix’s random effects and predictions take the data’s identifier type. A quoted header (write.csv()), or one with spaces after the delimiters, now matches the project’s header without a warning.Fixed a
delimiter = spacedata set whose columns are aligned with runs of spaces, which was not read; the header and the rows are now split on any run of white space.Fixed a
use=limitcolumn filled on every row (as intheo/parent_metabolite_data.csv): Monolix reads the limit only on censored rows, but the imported data kept it on uncensored ones, where nlmixr2 reads it as a truncation; it is now missing there (#62).Fixed
factorial()andfactln()of a non-integer, which Monolix 2024R1 computes for the rounded argument; rxode2 gavegamma(x + 1).Fixed PK macro and
pkmodel()arguments given as expressions (Cl=a+b,V=V1*WT,k12=c-d), which were pasted into the ODEs without parentheses.Fixed
depot(target=central, ka), whose doses went to adepotcompartment the model does not have instead of itscentraldstate.Fixed the import of a run with occasions (an occasion column or an
EVID=4washout), whosesummary.txt“Number of subjects-occasion” line stopped the import; random effects Monolix repeats on each occasion of a model without IOV are read once per subject.Fixed the validation of a data set with a subject without observations, which Monolix leaves out of its estimates.
Fixed a run without
exportpathwhose results are next to the project (lixoftConnectors), which imported without the final estimates.Fixed an infusion given by a
RATEinto a compartment with a bioavailability: Monolix keeps the durationAMT/RATEand scales the rate, while rxode2 kept the rate and shortened the infusion; such doses are now imported with adur.Fixed the validation of censored data: the censored observations were left out of the rxode2 solve but not of Monolix’s predictions, so they were reported in
$monolixNotMatched; and aCENSof.on the dose lines stopped the validation with “‘id’ cannot have NA values”.Fixed a parameter fixed with a lowercase
method=fixed, which was imported as estimated.Fixed
[LONGITUDINAL]variables and states named like rxode2 keywords (rate,dur,time,TIME,ii,df, …), which rxode2 refused; they are now written asmlx_<name>. Such a name as a model input or output is an error.Fixed
X_0initial conditions: a state with an underscore (A_gut_0) had none, and a variable likeE_0with no stateEbecameE(0), which rxode2 refused.Fixed a data line with both a dose and an observation: the observation was dropped. The line is now split into an observation and a dose.
Fixed a
[COVARIATE] EQUATION:covariate defined from an earlier one (lBMI = log(BMI/25)afterBMI = WT/(HT/100)^2): the model used the undefinedBMI; a covariate assigned twice used its first value.Fixed
if/elsein a[COVARIATE] EQUATION:, which left the covariate undefined; theif/else(and what uses it) now starts themodel()block, and the other covariate equations are still inlined.Fixed the validation of a project without random effects: the imported
$etaDatabecame a vector of ids (or was missing), so nothing was validated.Fixed an
[INDIVIDUAL] DEFINITION:line whosedistribution=is not the first option, which was a syntax error.Fixed the validation of a data set with character subject ids (
S-001): the individual parameters kept the characterid, whichrxSolve()refused, so nothing was validated. They are now also put in the data’s subject order, which is howrxSolve()assigns them.Fixed the
PK:macrosempty(adm, target)andreset(adm), whose administrations were given as doses: anempty()line now empties its target (rxode2evid=5with amount 0) and areset()line resets the system (evid=3). With them, a macro’sTlag,porTk0no longer stopped the translation and applies to its own administration only. InEQUATION:they are still not translated (a warning says so).Fixed an error parameter shared by several endpoints (
combined1(a, b1)andcombined1(a, b2)), which stopped the import with a duplicated parameter;ais now one estimate and the later endpoints use an alias (rx_a_y2 <- a), since rxode2 refuses one error parameter in two endpoints.Fixed the start of a model without
t_0: Monolix starts each subject at its first administration or observation, while rxode2 starts at time 0, so a system that changes without doses (a response with production) was already moving at the first record. The imported data now resets each subject whose first administration or observation is not at 0 there (anevid=2and anevid=3row, with that record’s covariates); witht_0 = 0(or a time-to-event endpoint) the model starts at 0, as before, and a numeric non-zerot_0(ignored before) starts every subject there. The validation compares Monolix’s predictions with rxode2’s observation rows only.Fixed
rem()in a[COVARIATE] EQUATION:inmlxtranGetMutate(): R’s%%gave a negative covariate the sign of the divisor; it now has the sign of the covariate, like Monolix and the model.Fixed covariates missing on some of a subject’s lines (a dose line): the imported data now fills them with the subject’s value (per occasion), as Monolix does; rxode2 warned that the column was missing for the subject.
Fixed
amtDoseandtDosebefore the first dose: rxode2’sdose()andtlastare missing there, while Monolix gives 0; they are nowdose0()andtlast0(), which also lets aTlag,Tk0orpmacro argument using them solve at the first dose. With a lag time rxode2 updates them at the lagged dose, Monolix at the dose itself; the import now warns.Fixed
pkmodel()or a PK macro (compartment(),oral(), …) followed by anifinEQUATION:: the macro arguments’ parentheses and commas were written before theif, so the model did not parse.Added
aaaCranMonolix2rxThreads(), run first in the examples, which limits CRAN checks to 2 threads to cut the example time.
monolix2rx 0.0.6
CRAN release: 2025-08-29
Updated to add types for rstudio completion
Defensive
drop = FALSEon the importedthetaMatcovariance subset so a single surviving parameter is not collapsed to a scalar.Parameters whose off-diagonal covariances are
NaN/NA/Infare now also dropped from the importedthetaMat(previously only the diagonal was checked forNaN/NA, so non-finite covariances could silently propagate into simulations).When every parameter is dropped from the imported
thetaMat, the covariance information is now ignored with a warning instead of storing a0x0matrix that would breakrxSolve()simulations;rxSolve()also warns whennStud > 1is requested but nothetaMatis available, so uncertainty is never silently omitted.Fixed
rxSolve()fallbacks that readdfObs/thetaMatfrom the wrong location when the values were stored on the model instead of itsmetaenvironment.rxSolve()now actually uses the Monolix-stylemaxSSit reports (number of steady-state doses plus one); previously the computed value was ignored and the literal default10000Lwas passed to the solver. The guard also checkedmissing(maxSS)twice where it meantminSS, so a user-specifiedminSSno longer gets silently overwritten. Note this can change steady-state simulation results: like Monolix itself, a fixed number of doses is now simulated, so slowly accumulating drugs reproduce Monolix’s (possibly pre-steady-state) concentrations instead of being dosed to full steady state; passmaxSS/minSSexplicitly to override.
monolix2rx 0.0.5
CRAN release: 2025-07-15
Updated for new solving option in rxode2 4.0 (and depend on the packages)
Bug fixes for importing models from
lixoftConnectors.
monolix2rx 0.0.3
CRAN release: 2024-10-24
- For initial conditions starting with
rxCov_don’t add to ini
