nlive: an R Package to facilitate the application of the sigmoidal and random changepoint mixed models

Background: The use of mixed effect models with a specific functional form such as the Sigmoidal Mixed Model and the Piecewise Mixed Model (or Changepoint Mixed Model) with abrupt or smooth random change allow the interpretation of the defined parameters to understand longitudinal trajectories. Currently, there are no interface R packages that can easily fit the Sigmoidal Mixed Model allowing the inclusion of covariates or incorporate recent developments to fit the Piecewise Mixed Model with random change. Results: To facilitate the modeling of the Sigmoidal Mixed Model, and Piecewise Mixed Model with abrupt or smooth random change, we have created an R package called nlive. All needed pieces such as functions, covariance matrices, and initials generation were programmed. The package was implemented with recent developments such as the polynomial smooth transition of piecewise mixed model with improved properties over Bacon-Watts, and the stochastic approximation expectation-maximization (SAEM) for efficient estimation. It was designed to help interpretation of the output by providing features such as annotated output, warnings, and graphs. Functionality, including time and convergence, was tested using simulations. We provided a data example to illustrate the package use and output features and interpretation. The package implemented in the R software is available from the Comprehensive R Archive Network (CRAN) at https://CRAN.R-project.org/package=nlive. Conclusions: The nlive package for R fits the Sigmoidal Mixed Model and the Piecewise Mixed: abrupt and smooth. The nlive allows fitting these models with only five mandatory arguments that are intuitive enough to the less sophisticated users.

line of code, with only five mandatory arguments. The package was implemented 34 with the most recent and efficient algorithms for non-linear models. Implementation 35 was also performed with the most interpretable parameterization and was based on 36 the most recent developments in each type of model. For example, for the smooth 37 PMM, instead of using the  which can create an artificial increase 38 in the trajectory right after the changepoint [15], we considered the most recently 39 developed polynomial smooth transition [16]. In the following, we reintroduce these 40 models, describe the implementation of the package, and provide a simulation study 41 to demonstrate the performance of the package. We also demonstrate the use of the 42 model and interpretation of the output using a made-up illsutrative sample dataset 43 with trajectories similar to those observed in cohorts such as the Religious Order 44 Study and the Rush Memory and Aging Project [17]. 45 Model specifications 46 As a prelude to the introduction and demonstration of the new nlive package, we first describe the general formulation of the nonlinear mixed models implemented in the package. The simplified general form of nonlinear mixed models can be written in terms of a known nonlinear function f given by: where y ij denotes the longitudinal outcome value of subject i (i = 1, ..., N ) collected 47 The Sigmoidal Mixed Model 58 The SMM introduced by Capuano and colleagues [4] is based on the four-parameter 59 logistic that allows the inclusion of covariates related to four parametric quantities.

60
The non-linear trajectory of the outcome Y can be formulated as follows: (2) where the first parameter, ψ 1i , represents the person-specific initial level of the outcome before the onset of decline. The second parameter, ψ 2i , represents the person-specific level of the outcome at time equal to zero (e.g., death), or the intercept. We will call it the last level although the meaning of time may differ depending on the application. ψ 3 represents the marginal time when half of the total decline occurred. We will call it the midpoint. ψ 4 represents the marginal Hill slope and will define the nonlinear pattern of the trajectory (e.g. determining the steepness, earlier versus later acceleration of change). These two latter parameters are kept as marginal for convergence purposes [4]. The four parameters are assumed to obey the following equations: initial level : ψ 1i = α 1 + β 1 X 1i + η 1i last level (intercept) : ψ 2i = α 2 + β 2 X 2i + η 2i (4) midpoint or time of half decline : ψ 3 = α 3 + β 3 X 3i trajectory of the outcome Y can be formulated as follows: where the first parameter, ψ 1i , represents the person-specific level of the outcome at time zero, or the intercept; ψ 2i represents the person-specific slope before the changepoint; ψ 3i represents the person-specific slope after the changepoint; and ψ 4i represents the person-specific changepoint time parameter.
Assuming an alignment at death for example (for interpretation purposes), the parameters ψ 1i to ψ 4i are supposed to obey the following equations: slope before the changepoint : slope after the changepoint : changepoint time : ψ 4i = α 4 + β 4 X 4i + η 4i (11) 80 where α 1 , α 2 , α 3 , and α 4 are the mean values for the last level, the slope before the change point, the slope after the changepoint, and the changepoint time, respec-82 tively; X 1i , X 2i , X 3i , and X 4i are vectors of covariates associated with the vector 83 of fixed effects β 1 , β 2 , β 3 , and β 4 , respectively; and η 1i to η 4i are random effects we re-formulated the PMM-smooth model as: where ψ 1i , ψ 2i , and ψ 3i have been previously defined for Equation (7). ψ 4i is the person-specific time when the smooth transition phase of length v begins. v is a value representing the time interval where the polynomial curve occurs between t ij = ψ 4i and t ij = ψ 4i + v. In order to be closer to the PMM-abrupt, the two linear parts should intersect at the middle of the transition phase and the constraint is imposed. Note that v set to 0 reduces to a PMM-abrupt model.
The smoothness of the transition function involves four linear equations with four parameters: where g transition is obtained by solving the system of four linear equations with 103 four unknown parameters. The derivatives of g transition at the times t ij = ψ 4i and 104 t ij = ψ 4i + v are respectively ψ 3i and ψ 2i . predictor.all, and predictor.par1 to predictor.par4.

201
• ID: name of the variable representing the grouping structure specified with " 202 (e.g., "ID" representing the unique identifier of participants).

205
• time: name of the variable representing the timescale specified with " (e.g.,  The fitted SMM model indicates that higher age at death was associated with 376 lower cognitive level at baseline (see term beta ageDeath90(first.level)) and 377 close to death (see term beta ageDeath90(last.level)). In addition, higher age 378 at death was associated with an earlier half of cognitive decline (see term 379 beta ageDeath90(midpoint)). However, age at death was not associated with the Hill slope(see term beta ageDeath90(hill.slope)). It is important to note here that    however, convergence adequacy was tested given the particular complexity of these 570 models. Overall the convergence rate was high, the time was reasonable, and the 571 bias was low.

572
The motivation of this package was aging research including biomarkers of the