Software · Founding article · Published 2026-11-24 · Open access, CC-BY 4.0

Fitting segmented mixed models with random changepoints in R

Vito M.R. Muggeo1

1 Dip. Scienze Economiche, Aziendali & Statistiche - Universita' di Palermo, Italy · orcid 0000-0002-3386-4054

segmented regressionmixed modelsrandom changepointsR packagepiecewise-linear modelslongitudinal data
doi: https://doi.org/10.68365/jrepstat.2026.12 Vol. 1 (2026) · Art. 12 Version 1 how to cite ↓ html pdf (typeset)
✓ Reproduced

Reproducibility record

verified 2026-11-18
Result
Reported results reproduced. Table 1 reproduces exactly from 300 replicates (B set to 300). Examples 1 and 2 agree, four printed values differ in their last digit.
✓ measured
Entry point
source("Rcode.R"), no command. The author's code is code/Rcode.R in the package.
declared
Environment
macOS arm64 native, R 4.5.2, segmented 2.3-0 from the author's tarball, 27 minutes
✓ measured
Determinism
Seeded.
declared
Archive
fitting-segmented-mixed-models-with-random-changepoints-in-r-v1-repro.zip · reviewed bundle SHA-256 ab8da100777d1cbc5d6cff97a99a5f5d95367079bb4de738889c154c7ff5314e · https://doi.org/10.5281/zenodo.24496310
✓ computed
AI use
None.
declared

Reproducibility package (.zip, 288 KB) · Zenodo doi:10.5281/zenodo.24496310 · SHA-256 3f6ef883776ecb17157afb1f09c61751863dca28a64e96c9224a9c81a74e3e68

Open review

Peer review record

4 rounds · 3 reviewers · signed Full reviewsHide reviews
2026-10-04Minor revision2026-10-305 answers2026-10-31Minor revision2026-11-0314 answers2026-11-03Minor revision2026-11-064 answers2026-11-18Accepted

The decision letters, the reports the authors read, their answers and the editor's signed decisions, as written. The reports come from the journal's review engine. The authors could have kept this record private until they confirmed the proof.

Round 1Minor revision3 reviewers · response
Minor revisionConfirmed and signed by Matthias Templ2026-10-04 · orcid 0000-0002-8638-5276
Decision letter2026-10-04This paper shows, with one real and one simulated dataset, how to fit and visualise segmented mixed models with random changepoints using segmented.lme in the R package segmented. It matters to applied analysts of longitudinal and clustered data who need subject-specific breakpoints estimated in a likelihood framework. We would be glad to see the revised version.

Thank you for your submission to JRepStat. We are inviting a minor revision. The reviewers’ points follow, grouped by weight.

This paper shows, with one real and one simulated dataset, how to fit and visualise segmented mixed models with random changepoints using segmented.lme in the R package segmented. It matters to applied analysts of longitudinal and clustered data who need subject-specific breakpoints estimated in a likelihood framework. We would be glad to see the revised version.

How to read this letter. The decision rests on the items marked required. If a required item seems wrong to you, or cannot be done within this paper, say so in your response letter and give the reason. A reasoned decline is a legitimate answer, and the editor weighs it. Reviewers can be mistaken. Items marked recommended or optional are advice from the reviewers. Adopt them, decline them with a sentence, or leave them for later work. None of that counts against the paper. The reviewer reports below carry the same marks. The editor who signs this decision may weigh an item differently in the accompanying message, and that message prevails.

required (the decision rests on these):

  • [Reviewer 1] Example 2 states its aim is to validate the functions against the true simulation parameters, then reports “results not shown here”. Show the summary(oseg1) comparison to the true values, or drop the validation framing and present the example as illustration only.
  • [Reviewer 3] Example 1 is not reproducible as written because bootstrap restarting is stochastic and no seed is set, while Example 2 does set seeds. Set a seed (or the relevant seg.control option) so the printed estimates reproduce, or state in the text that bootstrap-restarting results can vary across runs.

recommended:

  • [methods-soundness] The text states the breakpoints make the model non-regular, yet the summary and slope outputs report Wald t-values and p-values for the changepoint (G0) and slope-difference (U) parameters, and the narrative reads significance directly from them (“significantly different”, “a larger changepoint”). Near-boundary and changepoint parameters are exactly where Wald inference is least reliable under non-regularity. Please add one or two sentences stating which quantities have trustworthy standard errors and advising caution for the changepoint-related terms, so readers do not transfer the displayed p-values uncritically.
  • [software-quality] I am assessing from the manuscript and the described public interface. The package source, its help pages, and any tests/ directory were not supplied, so I cannot confirm that the documented behaviour of segmented.lme, plot.segmented.lme, sim.seg, and slope is covered by automated tests. State in the paper whether the demonstrated functions are exercised by the package test suite, and point readers to where those tests live.
  • [software-quality] The examples set seeds (set.seed(123), seed=15, seed argument of sim.seg) and use shipped data with no hard-coded paths, so the runs are portable. The paper does not record the R version or a captured session state. Add one line giving the R version and sessionInfo() (or the exact segmented/nlme versions) used for the printed output, so the numeric results can be reproduced.
  • [software-quality] The code appears across the text as interleaved snippets rather than one runnable file. Provide the two examples as a single script or a package vignette that runs end to end, so a new user can reproduce Figures 1 to 3 and the printed estimates without reassembling fragments.
  • [statistical-rigor] The analysis of glucoseData describes the Obese curve as “significantly different” from Control on the basis of several contrasts read off one summary table (intercept, left slope, slope difference, changepoint) with no correction across them. Please restate these conclusions in terms of the estimated differences and their intervals, which the example already produces, and drop the threshold wording so the example does not model uncorrected multiple testing for readers who copy it.
  • [statistical-rigor] The multinormal random-effects distribution in equation (4) and the zero-mean residual assumption are stated but never examined in either example. One sentence pointing to a residual or random-effects diagnostic, alongside the standardized-residual summary already printed, would show readers how to check the fit rather than assert it.
  • [statistical-rigor] The simulated example validates recovery on a single draw (seed 15) at one noise level. Since the Conclusions state the method “work[s] reasonably well when the signal-to-noise ratio is modest to high”, a short note on the range of conditions behind that statement, using runs you have already done, would let readers judge where the recovery claim holds.
  • [visualisation] Figure 1 packs 33 subjects into a 3 by 11 grid. At that size the per-panel axis annotation and the “time”/“phos” labels are hard to read, and only a handful of panels carry tick values. Consider a 5 by 7 or 6 by 6 layout, or a single faceted plot with shared axes and one axis label per edge, so the reader can compare profiles without squinting.
  • [visualisation] The red/blue coding in Figures 1 and 2 reads for the common red-green colourblindness because the two hues differ in blue content, so the palette is broadly safe. Figure 2 reinforces colour with line type (lty=3 for Obese), which is good practice. Carrying that same line-type distinction into Figure 1, and stating the red/blue meaning once in the main text as well as the caption, would make the group contrast legible in greyscale print too.
  • [visualisation] Axis labels give variable names (“time”, “phos”) without units. One phrase in each caption, naming the time unit and that phos is plasma inorganic phosphate, would let the figures stand on their own.
  • [writing-quality] Section 1 ends the sentence “the R package segmented (version 2.3-0 or higher)” without a full stop, and the paragraph in Section 2 ending “in the segmented, in particular” and “demanding … more demanding” trails off without a closing period in two places. A pass to close these sentences would help the reader.
  • [writing-quality] The summary(os1) output shows no t-value or p-value for the U and G0 rows while neighbouring rows report both. One sentence saying why these entries are blank (for example that the changepoint and reference slope-difference are reported without the associated test) would prevent readers from reading it as a defect in the output.
  • [ethics-and-integrity] The empirical example uses glucoseData, a de-identified dataset of 33 patients (Control and Obese) shipped inside the segmented package, analysed as a secondary illustration. No individuals are identifiable and no new data were collected, so the absence of an ethics-approval or consent statement does not meet the threshold for a violation. Add one sentence naming the original source of glucoseData and its public availability, so the provenance of the human measurements is on record.
  • [ethics-and-integrity] The paper is a tutorial for the author’s own segmented package, a relationship visible from the author line and the citations. A short competing-interests line stating that the author maintains the software would make the interest explicit. Add a competing-interests statement.
  • [Reviewer 1] Provide a single self-contained script that runs both examples end to end, with the output of sessionInfo() and the segmented/nlme versions used.
  • [Reviewer 1] Comment on the near-zero random-effect standard deviations in Example 1 (time and U, around 0.002) and link them to the overparameterization guidance already given in the Conclusions.
  • [Reviewer 1] In summary(os1) the U and G0 rows carry no p-value (and G0 no t-value). State what these entries mean, or confirm they are intentionally omitted.
  • [Reviewer 2] The summary of os1 omits t and p columns for G0 and the p column for U. Add one sentence explaining the omission and the non-regular nature of inference on the changepoint.
  • [Reviewer 2] Add a small repeated-simulation check (bias and interval coverage over replicates) to support the validation claim, since one dataset recovers one draw.
  • [Reviewer 2] Give a short account of the approximate restricted log-likelihood (the “approx” in the print output) and what the approximation affects.
  • [Reviewer 2] Expand the guidance for choosing among the four covariance specifications into a short worked rule, since convergence difficulty is the practical obstacle you identify.
  • [Reviewer 3] Report R version, operating system, and the exact versions of segmented and nlme used, and pin an exact segmented version instead of “2.3-0 or higher” for the numeric outputs.

optional:

  • [methods-soundness] The statement “the more complex the model, the better the fit and corresponding predictions” is loose, since richer random-effect structures risk overfitting and the convergence problems the same paragraph describes. A brief note tying model choice to an information criterion, which the AIC/BIC output already provides, would make the guidance concrete. This is beyond the illustrative scope of the current examples.
  • [Reviewer 1] (conditional) One or two sentences on the clinical reading of the Control-versus-Obese changepoint difference would help an applied reader connect the fit to the glucose tolerance test.

We will correct these in production, and you confirm them in the proof:

  • [consistency-check] In Example 2 the text names the additional segmented profiles as “the 3rd, the 4th and the 10th”, but the code call plot(oseg1, id=c(4,28,3,5,10), ...) and Figure 3 show subjects 3, 5 and 10 (subject 4 is one of the two linear profiles). The “4th” should read “5th” to match the code and figure.
  • [writing-quality] In Section 2, “In particular, the the ‘plot’ method can be used” repeats “the”. This is a duplicated word, not an extraction artefact.
  • [writing-quality] In Section 3.1 the summary discussion reads “the Obese group has an higher intercept”; this should read “a higher”.

Reviews

Report Reviewer 1recommends minorThis is a clear, practically useful software illustration from the package author, showing how segmented.lme fits piecewise-linear mixed models with subject-specific breakpoints. The underlying method is already published (Muggeo et al., 2014), so the contribution here is the code, the argument reference, and two worked examples. For an applied reader who has longitudinal data with a plausible turning point per subject, the paper gives a usable path from an lme fit to a segmented fit, to group comparisons, to plots. The structure of the functions section is a good quick reference, and the glucose example reads well.

Written by the journal's review engine in the role of the application reviewer, and read by the editor before the decision. How the engine works is on the peer review page.

This is a clear, practically useful software illustration from the package author, showing how segmented.lme fits piecewise-linear mixed models with subject-specific breakpoints. The underlying method is already published (Muggeo et al., 2014), so the contribution here is the code, the argument reference, and two worked examples. For an applied reader who has longitudinal data with a plausible turning point per subject, the paper gives a usable path from an lme fit to a segmented fit, to group comparisons, to plots. The structure of the functions section is a good quick reference, and the glucose example reads well.

My main concern is in Example 2, which the text sets up explicitly as a validation exercise, comparing estimates to the true simulation parameters, and then reports the key comparison as “results not shown here”. For a software paper the recovery of known parameters is close to the point of the example, and an applied reader cannot judge whether the functions behave as claimed without seeing it. The boundary-detection part (identifying subjects 4 and 28 as linear, matching dd$perc.psi) is shown and is convincing. The parameter-recovery part is asserted. Please either print the summary(oseg1) comparison against the true values, or present the example as an illustration of the workflow and remove the validation language.

Two things in Example 1 would help a practitioner more than they currently do. The diagonal fit reports random-effect standard deviations for time and U of roughly 0.002, which are effectively zero and suggest those random components are not supported by these data. Your Conclusions already warn about exactly this situation, so one sentence connecting the warning to the visible output would teach the reader how to read it. Separately, the summary(os1) table shows no p-value for U and no t-value or p-value for G0. If that omission is deliberate, because testing a zero slope-difference or a zero-valued changepoint is not a standard test here, say so in a line, because an applied reader will otherwise read the blank as missing output.

On reproducibility, the code is embedded in the text and uses set.seed and seed arguments, which is good practice. The submission record lists reproducibility artifacts that I was not given, so I cannot confirm whether a single runnable script exists. If one does not, a self-contained script plus the output of sessionInfo() and the segmented and nlme version numbers would let a reader reproduce both examples without reassembling snippets from the prose. The package version floor (2.3-0 or higher) is already stated, which is helpful.

The interpretive language around the group comparison (“significantly different”, “it turns out the curve for the Obese patients is significantly different”) leans on significance rather than on the estimated differences and their uncertainty, which you already report. Stating the intercept, slope and changepoint differences with their intervals, as you do for the slopes, would make the applied reading cleaner. This is a presentation point and not a barrier.

Numbered suggestions to the authors:

  1. required In Example 2, show the summary(oseg1) estimates against the true simulation parameters that the example says it validates, or remove the “validate” framing and present the example as a workflow illustration.
  2. recommended Supply one self-contained script that runs both examples, together with sessionInfo() output and the segmented and nlme versions used.
  3. recommended Add a sentence in Example 1 noting the near-zero random-effect standard deviations for time and U, and connect it to the overparameterization guidance in the Conclusions.
  4. recommended Explain the blank entries for U and G0 in the summary(os1) table, or confirm they are omitted by design.
  5. optional (conditional) Add one or two sentences on what the Control-versus-Obese changepoint difference means for the glucose tolerance test, to anchor the fit for applied readers.
Report Reviewer 2recommends minorThis is a clear software illustration of a method that is already established in Muggeo et al. (2014). As a methodology read, my job is to check that the illustration represents the estimator and its caveats correctly, and that the claims the examples make are supported by what the examples show. On the first count the paper is in good shape. The model in equation (1), the decomposition into fixed and random parts in (2), the two changepoint parametrisations in (3) with the logistic form keeping psi inside (a1, a2), and the covariance structure in (4) are all stated correctly, and the four random-effect specifications are ordered sensibly by complexity. I checked the internal arithmetic of the os1 example and it holds together: the Obese left slope (-1.2797 + 0.5461 = -0.7336) and right slope (-0.7336 + 1.6482 - 0.5351 = 0.3795) match the slope() output to the digits shown, and the intercept and changepoint sums match the text. The numbers are coherent.

Written by the journal's review engine in the role of the methodology reviewer, and read by the editor before the decision. How the engine works is on the peer review page.

This is a clear software illustration of a method that is already established in Muggeo et al. (2014). As a methodology read, my job is to check that the illustration represents the estimator and its caveats correctly, and that the claims the examples make are supported by what the examples show. On the first count the paper is in good shape. The model in equation (1), the decomposition into fixed and random parts in (2), the two changepoint parametrisations in (3) with the logistic form keeping psi inside (a1, a2), and the covariance structure in (4) are all stated correctly, and the four random-effect specifications are ordered sensibly by complexity. I checked the internal arithmetic of the os1 example and it holds together: the Obese left slope (-1.2797 + 0.5461 = -0.7336) and right slope (-0.7336 + 1.6482 - 0.5351 = 0.3795) match the slope() output to the digits shown, and the intercept and changepoint sums match the text. The numbers are coherent.

My main concern is the validation claim in Example 2. The paper states the aim is “to ‘validate’ the functions by comparing the results with the true parameter values,” and then reports “Estimates of the fixed effects and of the variance components can be compared to the true values … (results not shown here).” The one comparison that is the stated purpose of the example is the one withheld. For a software paper this is the evidence a methodology reader looks for first. The fix is cheap because you already have the object: print the fixed effects and variance components against the fixEff and S arguments used in sim.seg. If instead you prefer to keep the example compact, qualify the word “validate” to a single recovery illustration, because one simulated dataset recovers one draw of the random effects and does not on its own establish that the estimator is unbiased or that its intervals cover. A short repeated-simulation summary over replicates, reporting bias and the coverage of the Wald intervals, would carry the stronger word and is worth adding.

A second, lighter methodological point concerns inference on the changepoint. The summary of os1 shows no t or p value for G0 and no p value for U, while G.groupObese and the slope terms carry full columns. A reader will notice the gap. This is the right place to say in one sentence why Wald inference on the breakpoint location is treated differently, given the non-regularity you already flag at the start of Section 3, and what the confint.segmented.lme method reports instead. The print output also labels the log-restricted-likelihood as “approx”, which a methodology reader will want explained: a sentence on what is approximated in the likelihood used for REML, and what that affects in the reported standard errors, would close the loop.

The practical guidance in the Conclusions is sound and matches my experience with these models, that convergence is the binding constraint and a diagonal start is wise. It would help to turn that advice into a short rule tied to the four specifications in Section 2, so a reader who hits non-convergence knows which covariance to drop first. None of these points unsettles the method or the examples. They are about showing the evidence the paper says it has and stating the inferential caveats that a changepoint model carries.

Numbered suggestions to the authors:

  1. required Display the Example 2 comparison of the estimated fixed effects and variance components against the sim.seg truth (fixEff and S), or change “validate” to a single illustrative recovery so the claim matches what is shown.
  2. [editor_fix] Remove the duplicated word in “the the ‘plot’ method” (Section 2).
  3. recommended Add one sentence in Section 3.1 explaining why the summary omits t and p for G0 and p for U, linking it to the non-regular inference on the changepoint and to what confint.segmented.lme reports.
  4. recommended Add a small repeated-simulation summary over replicates reporting bias and Wald-interval coverage for the fixed effects and changepoint, to support the validation claim.
  5. recommended Add a sentence describing the approximate restricted log-likelihood (the “approx” in the print output) and what the approximation affects in the reported standard errors.
  6. recommended Turn the Conclusions advice into a short rule tied to the four covariance specifications, naming which variance or covariance to drop first on non-convergence.
Report Reviewer 3recommends minorThis is a clear, compact software illustration of segmented.lme and its companion methods. Read as code, the manuscript hangs together well. The internal arithmetic across the printed outputs is consistent: in Example 1 the changepoint estimate (1.724) matches the G0 coefficient, and the right slope (0.3507) equals the left slope plus the U coefficient. In Example 1 with the group interaction, the Obese left slope (-0.7337) and both right slopes recovered from slope(os1) reconstruct exactly from the summary table. In Example 2 the boundary-detection check is a genuine small validation, because which(!attr(oseg1\(psi.i, "is.break")) and which(dd\)perc.psi %in% c(0,1)) both return subjects 4 and 28. That agreement is the strongest part of the paper from a software standpoint.

Written by the journal's review engine in the role of the software reviewer, and read by the editor before the decision. How the engine works is on the peer review page.

This is a clear, compact software illustration of segmented.lme and its companion methods. Read as code, the manuscript hangs together well. The internal arithmetic across the printed outputs is consistent: in Example 1 the changepoint estimate (1.724) matches the G0 coefficient, and the right slope (0.3507) equals the left slope plus the U coefficient. In Example 1 with the group interaction, the Obese left slope (-0.7337) and both right slopes recovered from slope(os1) reconstruct exactly from the summary table. In Example 2 the boundary-detection check is a genuine small validation, because which(!attr(oseg1\(psi.i, "is.break")) and which(dd\)perc.psi %in% c(0,1)) both return subjects 4 and 28. That agreement is the strongest part of the paper from a software standpoint.

The reproducibility gap sits in Example 1. The print output reports “Bootstrap restarting on 6 samples; 1 different solution(s)”, which tells the reader the fit involves a random component, yet no seed is set before the segmented() call. Example 2, by contrast, sets set.seed(123) and passes seed=15 to sim.seg, and the text even says “We set the seeds just to reproduce the results”. The two examples should be held to the same standard. A reader who runs the Example 1 block today may see different fixed effects and variance components from those in the paper. Setting a seed (or the appropriate seg.control option that governs the restart draws), or a one-line statement that the restarting results can vary, closes this.

The second gap is the one claim I cannot see supported. The paper states the simulated example serves “to validate the functions by comparing the results with the true parameter values”, then reports summary(oseg1) as “results not shown here”. The only quantities shown against truth are the left slope (-0.1995 against -0.2) and the boundary detection. For a paper that names validation as an explicit aim, the summary output and a short estimate-versus-truth comparison belong in the text. If that is more than intended, the simpler route is to describe the simulated example as an illustration plus the boundary check, and drop “validate”.

On environment: the manuscript pins “version 2.3-0 or higher” and names nlme, but gives no R version, operating system, or exact package versions. For a software article whose value is the exact printed numbers, a session-info block removes ambiguity about what produced them. I note that the artifacts declared at submission were not provided to me, so I have assessed the inline code and its internal consistency and have not run anything. A reader reproducing Example 2 also depends on sim.seg naming its output columns Xdif, Zpsi1, and Zpsi2, which the fit formula assumes. A single head(d) or a note on the column names would make that explicit.

Numbered suggestions to the authors:

  1. required Make Example 1 reproducible: set a seed (or the seg.control option controlling the bootstrap restarts) before the segmented() call so the printed estimates reproduce, or add one sentence that bootstrap-restarting results can vary across runs.
  2. required Support the validation aim by including the summary(oseg1) output with an explicit comparison of the estimated fixed effects and variance components to the true simulation values, or narrow “validate” to the boundary-detection check you already show.
  3. recommended Add a session-info block giving the R version, operating system, and exact versions of segmented and nlme, and pin an exact segmented version for the numeric outputs.
  4. recommended In Example 2, note or show that sim.seg returns the columns Xdif, Zpsi1, and Zpsi2 that the fit formula references, for instance with head(d), so the block runs without the reader guessing the column names.
  5. [editor_fix] Remove the duplicated word in Section 2, “the the ‘plot’ method”.

Revision

Authors' response2026-10-30 · 5 answersAuthors confirm each required point as done or give their reason for declining it. Further answers are voluntary, because the review compares every revision with the previous version and the next round's reports say what remains open.

Authors confirm each required point as done or give their reason for declining it. Further answers are voluntary, because the review compares every revision with the previous version and the next round's reports say what remains open.

With respect to the first version, I have modified the text to follow the referees’ suggestions, I have modified (slightly)the title, and I have added treatment of a couple of new functions (mainly breakpoint()). Also, the results in the 1st example are slightly improved (in terms of Likelihood) as I have modified the fitter functions to avoid early stopping of the algorithm.

required Example 2 states its aim is to validate the functions against the true simulation parameters, then reports "results not shown here". Show the summary(oseg1) comparison to the true values, or drop the validation framing and present the example as illustration only.
Done
required Example 1 is not reproducible as written because bootstrap restarting is stochastic and no seed is set, while Example 2 does set seeds. Set a seed (or the relevant seg.control option) so the printed estimates reproduce, or state in the text that bootstrap-restarting results can vary across runs.
Done
recommended The multinormal random-effects distribution in equation (4) and the zero-mean residual assumption are stated but never examined in either example. One sentence pointing to a residual or random-effects diagnostic, alongside the standardized-residual summary already printed, would show readers how to check the fit rather than assert it.
Declined it would require a not-so short treatment and I think it is out of aims of the paper
recommended The paper is a tutorial for the author's own `segmented` package, a relationship visible from the author line and the citations. A short competing-interests line stating that the author maintains the software would make the interest explicit. Add a competing-interests statement.
Declined I do not understand what you mean. Sorry.
optional (conditional) One or two sentences on the clinical reading of the Control-versus-Obese changepoint difference would help an applied reader connect the fit to the glucose tolerance test.
Declined I don’t have added any “medical comment’ on the results in the first example: I don't have the skills to do it

The authors' full response letter (PDF)

Round 2Minor revision3 reviewers · response
Minor revisionConfirmed and signed by Matthias Templ2026-10-31 · orcid 0000-0002-8638-5276

The editor's note

The reviewers of the first round read the revision. Both required points of that round are met, one reviewer now recommends acceptance and two ask for a further minor revision. The remaining work is in the code that reproduces the paper. The uploaded script fits the group model from the wrong starting object, two printed functions give different intervals for the same slope, and the package build that produced the printed output is not on file.

Decision letter2026-10-31This paper shows, with one real and one simulated dataset, how to fit and visualise segmented mixed models with random changepoints using segmented.lme in the R package segmented. It matters to applied analysts of longitudinal and clustered data who need subject-specific breakpoints estimated in a likelihood framework. We would be glad to see the revised version.

Thank you for the revised version of your manuscript. This is round 2, and we are inviting a further minor revision. This round was read against the list you answered, and the editor has read your response against it in full. What follows is only what remains. An item carried over from the previous round says so.

This paper shows, with one real and one simulated dataset, how to fit and visualise segmented mixed models with random changepoints using segmented.lme in the R package segmented. It matters to applied analysts of longitudinal and clustered data who need subject-specific breakpoints estimated in a likelihood framework. We would be glad to see the revised version.

How to read this letter. The decision rests on the items marked required. If a required item seems wrong to you, or cannot be done within this paper, decline it on the revision page and give the reason. A reasoned decline is a legitimate answer, and the editor weighs it. Reviewers can be mistaken. Items marked recommended or optional are advice from the reviewers. Adopt them, decline them with a sentence, or leave them for later work. None of that counts against the paper. The reviewer reports below carry the same marks. The editor who signs this decision may weigh an item differently in the accompanying message, and that message prevails.

Reproducibility items marked required are the journal’s minimum for a paper that ships code with its results: code and a command that runs it, and by acceptance a captured computational environment (dependencies/lockfile/container) and a signed determinism attestation for the entry-point command. They document what you already have. They do not ask for new analysis.

required (the decision rests on these):

  • [consistency-check] The confint(os1) interval for the baseline left slope (“time” row, [-1.6293, -1.0747]) is not centred on the point estimate -1.2796 shown in summary(os1), and it disagrees with slope(os1), which reports [-1.5569, -1.0023] for the same baseline left slope. The breakpoint rows (G0, G.groupObese) in confint do match their point estimates, so the mismatch is specific to the non-breakpoint parameters. Please reconcile the confint output with summary and slope, or add one sentence stating why confint and slope produce different intervals for the same quantity.
  • [methods-soundness] The new simulation block that produces Table 1 cannot run as printed. The storage matrices are sized to B with B=3 (V=matrix(,B,4), SE<-E<-matrix(,B,7)), while the loop is hard-coded for(i in 1:300), so assignment to V[i,] fails once i exceeds 3 with a subscript-out-of-bounds error. The text states the table rests on 300 runs. Set B=300 and index the loop as for(i in 1:B) so the printed snippet reproduces the table, or state that the manuscript snippet is a reduced illustration and the full run sits in the uploaded script. I did not open Rcode.R, so the script may already carry the corrected form.
  • [software-quality] The self-contained script Rcode.R fits the group model with the wrong starting object. The line os1<-segmented(o, time, z.psi= group, x.diff= group, random=subj 1+time+U+G0) passes o (from lme(phos time, ...)), but the manuscript builds os1 from o1 <- lme(phos time*group, ...). Starting from o drops the groupObese and time:groupObese fixed effects, so the script cannot produce the summary(os1), confint(os1), Figure 1 or Figure 2 shown in Section 3.1. Change o to o1 on that line.
  • [software-quality] Two divergent copies of Rcode.R are shipped (one inside package+Rscript.zip, one standalone) and neither reproduces the paper end to end. The zip copy calls sim.seg(N, nj=12, ...), but the argument is ni (per args(sim.seg) in the paper), so that call errors; it also uses the old n.plot=c(3,11) layout. The standalone copy carries the os1 bug above. Please ship one authoritative script that matches the printed output, or state which file is the reproduction artifact.

recommended:

  • [software-quality] The package source extracted for this review contained only Rcode.R, not the segmented help pages or any tests/ directory, so I cannot confirm that segmented.lme, plot.segmented.lme, sim.seg, fixef, getVarCov, slope, and breakpoint are exercised by automated tests. The earlier request (75ae2e1b) asked the paper to state whether these functions are covered by the package test suite and where those tests live; the revised text still does not say. One sentence pointing readers to the tests would close this.
  • [software-quality] The reproducibility of the printed estimates rests on segmented.lme() deriving a seed from the response values, as the text now states. The script does not set seg.control(seed=...) explicitly anywhere, so reproduction depends entirely on that implicit behaviour and on the exact segmented version. The sessionInfo() now pins segmented_2.3-0, which helps; consider setting the seed explicitly in the script so the path is fixed independently of the internal default.
  • [statistical-rigor] The new Table 1 supports the recovery claim with bias and a comparison of the mean model-based standard error to the empirical sampling sd over 300 replicates. It does not report the empirical coverage of the Wald intervals, which is the quantity that would directly back the sentence “we can trust the Wald statistic to build confidence intervals.” Add the coverage from the replicates already run.
  • [statistical-rigor] For κ2 the mean standard error (0.020) is below the empirical sampling sd (0.025), and the mean estimate (-0.186) sits off the true -0.2. The summary “model-based standard errors quantifying rather appropriately the distribution standard deviations” overstates agreement for that term. Name the terms where the model-based SE understates spread.
  • [ethics-and-integrity] The competing-interests point from the prior round [b6d11824] was declined because the request was unclear, so no statement was added. To be plain about what is meant: you wrote and maintain the segmented package that this paper is a tutorial for, and that is a competing interest a reader should see stated in the paper, separate from the maintainer field on CRAN. Add one line, for example “The author develops and maintains the segmented R package”, to the Acknowledgements or a Competing Interests section.
  • [revision-response-verifier] Carry the unit phrasing into the Figure 2 caption and either pin an exact segmented version in Section 1 or note that “2.3-0 or higher” is intentional for the printed outputs.
  • [visualisation] Axis labels give variable names (“time”, “phos”) without units. One phrase in each caption, naming the time unit and that phos is plasma inorganic phosphate, would let the figures stand on their own. This was asked in the previous round and is still open.

optional:

  • [visualisation] One small residual, newly visible now that the grid is denser: each of the 33 panels in Figure 1 still repeats the base-plot “time”/“phos” labels inside the panel, while the units sit only on the outer edges. The panels would read more cleanly with the per-panel “time”/“phos” text suppressed so only the edge labels with units remain. The figure stands as drawn.

We will correct these in production, and you confirm them in the proof:

  • [consistency-check] In Section 3.1 the text reads “a less steep left slope (−1.2796 + 0.5461)”, but the summary(os1) table gives time:groupObese = 0.5460. The text value should read 0.5460.
  • [consistency-check] The Section 1 roadmap states “section 3 reports some analyses on the simulated dataset”, but Section 3 contains both Example 1 (real data, glucoseData) and Example 2 (simulated data). The sentence should name both.
  • [consistency-check] In Section 3.2 the additional profiles are named “the 6rd, the 5th and the 10th”. The subject numbers match the code plot(oseg1, id=c(4,28,6,5,10), ...) and Figure 3, so only the ordinal is wrong: “6rd” should read “6th”.
  • [writing-quality] In Section 3 the sentence “even under the the standard Gaussian assumptions for the ϵ’s” repeats “the”. This is a duplicated word that survives into the revision, distinct from the Section 2 instance that was fixed.
  • [writing-quality] In the Acknowledgements, “Teh author also thanks dr. V. Genoa” should read “The author”. A transposition, not an extraction artefact.
  • [writing-quality] In Example 2, “Starting the analysis with a simple structure, e.e a diagonal matrix” should read “e.g.”.
  • [revision-response-verifier] (production) The consistency fix for Example 2 introduced “the 6rd”, which should read “6th”.

Reviews

Report Reviewer 1recommends minorOf the one required point and the recommended and optional points I raised, all are met or declined with a reason I accept. Example 2 no longer carries the validation framing and now shows the parameter recovery directly, through fixef() and getVarCov() tables that place the true values beside the estimates. That is a cleaner answer than the one I asked for and it settles the point. The near-zero random-effect standard deviations are now discussed and tied to the parsimony and model-selection reasoning, the blank U and G0 entries in the summary are explained in the text after the first summary() call, and sessionInfo() is printed. The decline on a clinical reading of the changepoint difference is reasonable: the author is a statistician and the paper does not need a medical interpretation to stand.

Written by the journal's review engine in the role of the application reviewer, and read by the editor before the decision. How the engine works is on the peer review page.

Of the one required point and the recommended and optional points I raised, all are met or declined with a reason I accept. Example 2 no longer carries the validation framing and now shows the parameter recovery directly, through fixef() and getVarCov() tables that place the true values beside the estimates. That is a cleaner answer than the one I asked for and it settles the point. The near-zero random-effect standard deviations are now discussed and tied to the parsimony and model-selection reasoning, the blank U and G0 entries in the summary are explained in the text after the first summary() call, and sessionInfo() is printed. The decline on a clinical reading of the changepoint difference is reasonable: the author is a statistician and the paper does not need a medical interpretation to stand.

One issue is new in this version and I flag it as new. The small simulation study added at the end of Section 3.2 is a genuine improvement and the coverage-style summary in Table 1 is exactly the kind of evidence the recovery claim needed. The printed code for it will not run, though. The matrices V, E and SE are created with B rows where B is set to 3, and the loop then runs for(i in 1:300). In R a matrix does not grow on assignment, so V[i,] fails once i exceeds 3. A reader who copies the block to reproduce Table 1 gets a subscript error. The fix is small: set B=300 and index the loop and the matrices by B. The uploaded source file may already be correct, but the manuscript code is what a reader of a tutorial copies, so the printed snippet should be the one that runs.

Three small textual errors are new and can be settled in proof: “6rd” for “6th” in the Section 3.2 profile list, “Teh author” in the Acknowledgements, and “e.e” for “e.g.” in Section 3.2.

Numbered suggestions to the authors:

  1. required Repair the Section 3.2 simulation snippet so it runs: set B=300 and size V, E and SE and the loop by B (for(i in 1:B)), so the code reproduces Table 1 rather than erroring at the fourth iteration.
  2. [editor_fix] Correct “the 6rd” to “the 6th” in Section 3.2 to match the plot call and Figure 3.
  3. [editor_fix] Correct “Teh author” to “The author” in the Acknowledgements and “e.e a diagonal matrix” to “e.g. a diagonal matrix” in Section 3.2.
Report Reviewer 2recommends acceptOf the one required point and five lighter ones I raised, all are met. The validation framing in Example 2 is now “assess”, and the example displays the fixed effects against the sim.seg truth via fixef() and the random-effect standard deviations via getVarCov(), which is exactly the evidence the stated purpose needed. The summary output now carries a clear paragraph on why U drops its p-value and why both the t- and p-value are dropped for the changepoint, tied to the non-regular inference. The “approx” log-likelihood is explained with a pointer to Muggeo et al. (2014). The Conclusions give a usable rule for the four covariance specifications, start simple and build up. The new repeated-simulation study (Table 1, 300 replicates) reports means, medians and sampling standard deviations against the model-based standard errors, which answers the bias-and-coverage request in substance even though coverage is not tabulated as a percentage. The decline on residual and random-effects diagnostics is reasoned and reasonable for a tutorial of this length, and I am content to leave it out of scope.

Written by the journal's review engine in the role of the methodology reviewer, and read by the editor before the decision. How the engine works is on the peer review page.

Of the one required point and five lighter ones I raised, all are met. The validation framing in Example 2 is now “assess”, and the example displays the fixed effects against the sim.seg truth via fixef() and the random-effect standard deviations via getVarCov(), which is exactly the evidence the stated purpose needed. The summary output now carries a clear paragraph on why U drops its p-value and why both the t- and p-value are dropped for the changepoint, tied to the non-regular inference. The “approx” log-likelihood is explained with a pointer to Muggeo et al. (2014). The Conclusions give a usable rule for the four covariance specifications, start simple and build up. The new repeated-simulation study (Table 1, 300 replicates) reports means, medians and sampling standard deviations against the model-based standard errors, which answers the bias-and-coverage request in substance even though coverage is not tabulated as a percentage. The decline on residual and random-effects diagnostics is reasoned and reasonable for a tutorial of this length, and I am content to leave it out of scope.

What remains is a single code inconsistency in the new material, which I could not have raised before because the simulation did not exist in the prior version. The loop dimensions V, SE and E with B rows after setting B=3, then iterates over 1:300. As printed it will fail at the fourth iteration with a subscript error, so the code does not reproduce Table 1. The fix is to set B to 300 before the matrices are created, and to confirm the uploaded script carries the same value.

The remaining items are small demonstrable mismatches between the text and the outputs it quotes, which production handles and you confirm in the proof.

Numbered suggestions to the authors:

  1. [editor_fix] In the simulation code, set B to 300 before dimensioning V, SE and E, so the loop over 1:300 runs and produces Table 1, and align the uploaded script.
  2. [editor_fix] Remove the duplicated word in “even under the the standard Gaussian assumptions” (Section 3).
  3. [editor_fix] Change “the 6rd” to “the 6th” (Section 3.2) to match id=c(4,28,6,5,10) and Figure 3.
  4. [editor_fix] Reconcile “-1.2796 + 0.5461” in Section 3.1 with the summary coefficient 0.5460.
  5. [editor_fix] Change “Teh author” to “The author” in the acknowledgements.
Report Reviewer 3recommends minorAll five points from my prior report are met. The Example 1 reproducibility gap is resolved cleanly: the text now explains that segmented.lme() derives its seed from the response values, so the bootstrap-restart path is deterministic, and it points to seg.control(seed=) for an explicit alternative. The validation framing is softened to “assess” and backed by a direct true-versus-estimate table for both fixed effects (via fixef) and the random-effect standard deviations (via getVarCov), which is exactly the comparison I asked for. The sessionInfo() block pins R 4.6.1, the OS, and segmented_2.3-0 and nlme_3.1-169. Example 2 now shows head(d,3) with the Xdif, Zpsi1, and Zpsi2 columns named in the text. The duplicated “the the ‘plot’ method” is gone.

Written by the journal's review engine in the role of the software reviewer, and read by the editor before the decision. How the engine works is on the peer review page.

All five points from my prior report are met. The Example 1 reproducibility gap is resolved cleanly: the text now explains that segmented.lme() derives its seed from the response values, so the bootstrap-restart path is deterministic, and it points to seg.control(seed=) for an explicit alternative. The validation framing is softened to “assess” and backed by a direct true-versus-estimate table for both fixed effects (via fixef) and the random-effect standard deviations (via getVarCov), which is exactly the comparison I asked for. The sessionInfo() block pins R 4.6.1, the OS, and segmented_2.3-0 and nlme_3.1-169. Example 2 now shows head(d,3) with the Xdif, Zpsi1, and Zpsi2 columns named in the text. The duplicated “the the ‘plot’ method” is gone.

One new item is material and newly visible in this version. The simulation study added at the end of Section 3.2 is a genuine improvement and the Table 1 recovery looks sound, but the displayed code will not run. V, E, and SE are allocated with matrix(,B,4) and matrix(,B,7) while B is set to 3, yet the loop iterates for(i in 1:300). Assigning V[i,] for i greater than 3 raises “subscript out of bounds” in R, so the block errors at the fourth iteration and never fills the matrices Table 1 reports. The caption and surrounding text both say the results are based on 300 runs, so the intent is clear. Set B=300 and index both the allocations and the loop by B (or 1:B), so the code that produces Table 1 is the code the paper prints. For a software article whose value rests on the printed numbers being the code’s output, this one should be correct.

The three small text errors I list as editor_fix all sit in newly added or newly edited sentences and the paper itself fixes their values.

Numbered suggestions to the authors:

  1. required Make the simulation block run as printed: set B=300 (or allocate V, E, SE with nrow=300) and iterate the loop by 1:B, so the code matches Table 1’s stated 300 replicates.
  2. [editor_fix] Correct three text errors in the new material: “under the the standard Gaussian assumptions” (duplicated “the”), “Teh author” in the Acknowledgements, and “the 6rd” in Section 3.2 (should read “6th”).

Revision

Authors' response2026-11-03 · 14 answersAuthors confirm each required point as done or give their reason for declining it. Further answers are voluntary, because the review compares every revision with the previous version and the next round's reports say what remains open.

Authors confirm each required point as done or give their reason for declining it. Further answers are voluntary, because the review compares every revision with the previous version and the next round's reports say what remains open.

required The confint(os1) interval for the baseline left slope ("time" row, [-1.6293, -1.0747]) is not centred on the point estimate -1.2796 shown in summary(os1), and it disagrees with slope(os1), which reports [-1.5569, -1.0023] for the same baseline left slope. The breakpoint rows (G0, G.groupObese) in confint do match their point estimates, so the mismatch is specific to the non-breakpoint parameters. Please reconcile the confint output with summary and slope, or add one sentence stating why confint and slope produce different intervals for the same quantity.
Done Thanks for noting that. I have corrected the function
required The new simulation block that produces Table 1 cannot run as printed. The storage matrices are sized to B with `B=3` (`V=matrix(,B,4)`, `SE<-E<-matrix(,B,7)`), while the loop is hard-coded `for(i in 1:300)`, so assignment to `V[i,]` fails once `i` exceeds 3 with a subscript-out-of-bounds error. The text states the table rests on 300 runs. Set `B=300` and index the loop as `for(i in 1:B)` so the printed snippet reproduces the table, or state that the manuscript snippet is a reduced illustration and the full run sits in the uploaded script. I did not open Rcode.R, so the script may already carry the corrected form.
Done corrected, thanks.
required The self-contained script `Rcode.R` fits the group model with the wrong starting object. The line `os1<-segmented(o, time, z.psi= group, x.diff= group, random=subj 1+time+U+G0)` passes `o` (from `lme(phos time, ...)`), but the manuscript builds `os1` from `o1 <- lme(phos time*group, ...)`. Starting from `o` drops the `groupObese` and `time:groupObese` fixed effects, so the script cannot produce the `summary(os1)`, `confint(os1)`, Figure 1 or Figure 2 shown in Section 3.1. Change `o` to `o1` on that line.
Done Yes, of course. Thanks for noting that. I have corrected that
required Two divergent copies of `Rcode.R` are shipped (one inside `package+Rscript.zip`, one standalone) and neither reproduces the paper end to end. The zip copy calls `sim.seg(N, nj=12, ...)`, but the argument is `ni` (per `args(sim.seg)` in the paper), so that call errors; it also uses the old `n.plot=c(3,11)` layout. The standalone copy carries the `os1` bug above. Please ship one authoritative script that matches the printed output, or state which file is the reproduction artifact.
Done I'm sorry for the inconvenience. I got confused. I am uploading the file Rcode+package.zip including i)the new version of the package segmented_2.3-0.tar.gz, and ii)the Rcode.R to replicate the analyses in the paper
recommended The package source extracted for this review contained only `Rcode.R`, not the `segmented` help pages or any `tests/` directory, so I cannot confirm that `segmented.lme`, `plot.segmented.lme`, `sim.seg`, `fixef`, `getVarCov`, `slope`, and `breakpoint` are exercised by automated tests. The earlier request (75ae2e1b) asked the paper to state whether these functions are covered by the package test suite and where those tests live; the revised text still does not say. One sentence pointing readers to the tests would close this.
Done I apologize for the inconvenience. I got confused. I am uploading the file Rcode+package.zip including i)the new version of the package segmented_2.3-0.tar.gz, and ii)the Rcode.R to replicate the analyses in the paper
recommended The reproducibility of the printed estimates rests on `segmented.lme()` deriving a seed from the response values, as the text now states. The script does not set `seg.control(seed=...)` explicitly anywhere, so reproduction depends entirely on that implicit behaviour and on the exact `segmented` version. The `sessionInfo()` now pins `segmented_2.3-0`, which helps; consider setting the seed explicitly in the script so the path is fixed independently of the internal default.
Declined I have commented in the text the behaviour of segmented and the possibility of using the 'seg.control(seed=..)'. I think it is enough. I hope you are fine with my choice
recommended The new Table 1 supports the recovery claim with bias and a comparison of the mean model-based standard error to the empirical sampling sd over 300 replicates. It does not report the empirical coverage of the Wald intervals, which is the quantity that would directly back the sentence "we can trust the Wald statistic to build confidence intervals." Add the coverage from the replicates already run.
Done Table 1 now includes the coverage levels (last column)
recommended For κ2 the mean standard error (0.020) is below the empirical sampling sd (0.025), and the mean estimate (-0.186) sits off the true -0.2. The summary "model-based standard errors quantifying rather appropriately the distribution standard deviations" overstates agreement for that term. Name the terms where the model-based SE understates spread.
Done I have modified the comments, by underlining the behaviour for kappa1 (and kappa2 too).
recommended The competing-interests point from the prior round [b6d11824] was declined because the request was unclear, so no statement was added. To be plain about what is meant: you wrote and maintain the segmented package that this paper is a tutorial for, and that is a competing interest a reader should see stated in the paper, separate from the maintainer field on CRAN. Add one line, for example "The author develops and maintains the segmented R package", to the Acknowledgements or a Competing Interests section.
Done Added in the Acknowledgements
recommended Axis labels give variable names ("time", "phos") without units. One phrase in each caption, naming the time unit and that phos is plasma inorganic phosphate, would let the figures stand on their own. This was asked in the previous round and is still open.
Declined Yes, it was asked, and in fact I followed such suggestion by specifying the labels in the x- and y-axis (by also adding the units as you suggested) of Figure 1. In Figure 2 , in order to keep simple the relevant code, the labels are the variable names.
optional One small residual, newly visible now that the grid is denser: each of the 33 panels in Figure 1 still repeats the base-plot "time"/"phos" labels inside the panel, while the units sit only on the outer edges. The panels would read more cleanly with the per-panel "time"/"phos" text suppressed so only the edge labels with units remain. The figure stands as drawn.
Declined I am sorry, but I see no "time"/"phos" labels inside the 33 panels in Figure 1.
recommended I am assessing from the manuscript and the described public interface. The package source, its help pages, and any `tests/` directory were not supplied, so I cannot confirm that the documented behaviour of `segmented.lme`, `plot.segmented.lme`, `sim.seg`, and `slope` is covered by automated tests. State in the paper whether the demonstrated functions are exercised by the package test suite, and point readers to where those tests live.
Done I am uploading the file Rcode+package.zip including i)the new version of the package segmented_2.3-0.tar.gz, and ii)the Rcode.R to replicate the analyses in the paper
recommended Axis labels give variable names ("time", "phos") without units. One phrase in each caption, naming the time unit and that phos is plasma inorganic phosphate, would let the figures stand on their own.
Done In the caption of Figure 2
recommended Report R version, operating system, and the exact versions of segmented and nlme used, and pin an exact segmented version instead of "2.3-0 or higher" for the numeric outputs.
Done At the end of section 3, I report the output of sessionInfo()
Round 3Minor revision3 reviewers · response
Minor revisionConfirmed and signed by Matthias Templ2026-11-03 · orcid 0000-0002-8638-5276

The editor re-weighted 2 points.

Decision letter2026-11-03This paper shows, with one real and one simulated dataset, how to fit and visualise segmented mixed models with random changepoints using segmented.lme in the R package segmented. It matters to applied analysts of longitudinal and clustered data who need subject-specific breakpoints estimated in a likelihood framework. We would be glad to see the revised version.

Thank you for the revised version of your manuscript. This is round 3, and we are inviting a further minor revision. This round was read against the list you answered, and the editor has read your response against it in full. What follows is only what remains. An item carried over from the previous round says so.

This paper shows, with one real and one simulated dataset, how to fit and visualise segmented mixed models with random changepoints using segmented.lme in the R package segmented. It matters to applied analysts of longitudinal and clustered data who need subject-specific breakpoints estimated in a likelihood framework. We would be glad to see the revised version.

How to read this letter. The decision rests on the items marked required. If a required item seems wrong to you, or cannot be done within this paper, decline it on the revision page and give the reason. A reasoned decline is a legitimate answer, and the editor weighs it. Reviewers can be mistaken. Items marked recommended or optional are advice from the reviewers. Adopt them, decline them with a sentence, or leave them for later work. None of that counts against the paper. The reviewer reports below carry the same marks. The editor who signs this decision may weigh an item differently in the accompanying message, and that message prevails.

recommended:

  • [software-quality] The submission still carries two stale copies of Rcode.R that do not match the paper: upload: Rcode.R (standalone) still fits os1<-segmented(o, ...) with the wrong starting object the prior round flagged, and package+Rscript.zip: Rcode.R still calls sim.seg(N, nj=12, ...) with the wrong argument nj and the old n.plot=c(3,11) layout. The author has named Rcode+package.zip as the reproduction artifact, which resolves the ambiguity, but removing or clearly marking the two superseded copies would stop a reader from running the wrong file.
  • [software-quality] I am assessing from the manuscript and the described public interface. The package source, its help pages, and any tests/ directory were not supplied, so I cannot confirm that the documented behaviour of segmented.lme, plot.segmented.lme, sim.seg, and slope is covered by automated tests. State in the paper whether the demonstrated functions are exercised by the package test suite, and point readers to where those tests live. This was asked in the previous round and is still open.

optional:

  • [software-quality] The declared reproduction artifact Rcode+package.zip: Rcode.R sets the simulation covariance as S=diag(c(.12,.05,.3,.02)^2) in the small simulation loop, so the breakpoint random-effect sd is 0.02. The paper’s printed snippet uses S=diag(c(.12,.05,.3,.1)^2) and Table 1 reports σk true 0.10 with mean 0.090 and sd 0.011. A run with σk=0.02 cannot produce a mean of 0.090, so the uploaded authoritative script would not reproduce the σk row of Table 1. Set the fourth variance in S to .1 in the uploaded script, or correct the Table 1 σk entries, so the script and the table agree.

We will correct these in production, and you confirm them in the proof:

  • [consistency-check] The Section 3.1 text still reads “a less steep left slope (−1.2796 + 0.5461)”, while summary(os1) gives time:groupObese = 0.5460. The text should read 0.5460. This was raised last round (faa3a12a) and the manuscript still carries 0.5461.
  • [consistency-check] The Section 1 roadmap still states “section 3 reports some analyses on the simulated dataset”, but Section 3 contains Example 1 (real glucoseData) and Example 2 (simulated data). The sentence should name both. Raised last round (5436d34f) and still open.
  • [consistency-check] In Section 3.2 the profiles are still named “the 6rd, the 5th and the 10th”. The code plot(oseg1, id=c(4,28,6,5,10)) and Figure 3 confirm subject 6, so the ordinal should read “6th”. Raised last round (e3ab272b/f99c9341) and still present.
  • [methods-soundness] In Section 3.2 the phrase “values quite close to 0.95%” carries a stray percent sign; the nominal level is 0.95 or 95%. The paper itself determines the correct value.
  • [revision-response-verifier] Several production corrections from the prior round remain unmade in the text, the “0.5461” value (should be 0.5460), the Section 1 roadmap naming both examples, “6rd” (should be 6th), the duplicated “the”, and “e.e” (should be “e.g.”), and should be carried to the proof list.
  • [Reviewer 1] Section 3.2 still reads “e.e a diagonal matrix”; this should read “e.g. a diagonal matrix”.
  • [Reviewer 2] Section 3 still reads “even under the the standard Gaussian assumptions”; the duplicated “the” remains.
  • [revision-response-verifier] (production) The consistency fix for Example 2 introduced “the 6rd”, which should read “6th”. This was asked in the previous round and is still open.

Reviews

Report Reviewer 1recommends acceptThe one required point is met. The simulation snippet at the end of Section 3.2 now runs: the loop is for(i in 1:B) and V, E and SE are sized by B, so the subscript error at i=4 is gone. The author kept B=3 in the printed block for speed and states in the text that Table 1 rests on 300 runs rather than 3. That is a sound choice for a tutorial, the printed code executes without error, and a reader who wants the table is told to raise B. The uploaded Rcode.R and segmented_2.3-0 archive settle the reproducibility artifact as well. I am content with the resolution.

Written by the journal's review engine in the role of the application reviewer, and read by the editor before the decision. How the engine works is on the peer review page.

The one required point is met. The simulation snippet at the end of Section 3.2 now runs: the loop is for(i in 1:B) and V, E and SE are sized by B, so the subscript error at i=4 is gone. The author kept B=3 in the printed block for speed and states in the text that Table 1 rests on 300 runs rather than 3. That is a sound choice for a tutorial, the printed code executes without error, and a reader who wants the table is told to raise B. The uploaded Rcode.R and segmented_2.3-0 archive settle the reproducibility artifact as well. I am content with the resolution.

Two of the three textual corrections I flagged remain. The Acknowledgements now read “The author”. The profile-list typo “6rd” and the “e.e” abbreviation in Section 3.2 are still present in this version. Both are editor_fix items whose correct values the text itself fixes, so they belong on the proof production list rather than holding the paper.

Numbered suggestions to the authors:

  1. [editor_fix] Correct “the 6rd” to “the 6th” in Section 3.2 to match the plot call and Figure 3.
  2. [editor_fix] Correct “e.e a diagonal matrix” to “e.g. a diagonal matrix” in Section 3.2.
Report Reviewer 2recommends acceptOf the five production points I raised last round, two are settled and three remain. The acknowledgements now read “The author”, so that one is done. The simulation code no longer crashes: the loop runs over 1:B rather than 1:300, so the subscript error is gone, and the text now records that Table 1 rests on 300 runs while the printed snippet keeps B=3 for speed. That is a reasonable way to leave it, and with the uploaded Rcode.R carrying the full run I am content. A reader who copies the printed snippet verbatim will get a 3-run table rather than the one shown, but the text says so.

Written by the journal's review engine in the role of the methodology reviewer, and read by the editor before the decision. How the engine works is on the peer review page.

Of the five production points I raised last round, two are settled and three remain. The acknowledgements now read “The author”, so that one is done. The simulation code no longer crashes: the loop runs over 1:B rather than 1:300, so the subscript error is gone, and the text now records that Table 1 rests on 300 runs while the printed snippet keeps B=3 for speed. That is a reasonable way to leave it, and with the uploaded Rcode.R carrying the full run I am content. A reader who copies the printed snippet verbatim will get a 3-run table rather than the one shown, but the text says so.

Three small demonstrable mismatches between the text and its own outputs are still in the manuscript: the duplicated “the the” in Section 3, “6rd” where “6th” is meant in Section 3.2, and “0.5461” in Section 3.1 against the table value 0.5460. None of these touch a claim or a result. They are production fixes you confirm in the proof, and they do not hold the paper. The methodology, the worked examples, the summary output explanation for the dropped p-values, and the simulation with coverage levels in Table 1 all stand as accepted last round.

Numbered suggestions to the authors:

  1. [editor_fix] Remove the duplicated word in “even under the the standard Gaussian assumptions” (Section 3).
  2. [editor_fix] Change “the 6rd” to “the 6th” (Section 3.2) to match id=c(4,28,6,5,10) and Figure 3.
  3. [editor_fix] Reconcile “-1.2796 + 0.5461” in Section 3.1 with the summary coefficient 0.5460.
Report Reviewer 3recommends acceptThe required point is met. The simulation block is now internally consistent and runs as printed: B is set to 3, V, E and SE are sized to B, and the loop iterates 1:B, so there is no subscript error. The author resolved the 3-versus-300 mismatch by keeping the quick B=3 demo in the printed listing and stating in the surrounding text that Table 1 is based on 300 runs. A reader reproducing Table 1 sets B=300, and the provided Rcode.R carries the full run. For a software illustration this is a reasonable resolution, and the defect that made the block error out is gone.

Written by the journal's review engine in the role of the software reviewer, and read by the editor before the decision. How the engine works is on the peer review page.

The required point is met. The simulation block is now internally consistent and runs as printed: B is set to 3, V, E and SE are sized to B, and the loop iterates 1:B, so there is no subscript error. The author resolved the 3-versus-300 mismatch by keeping the quick B=3 demo in the printed listing and stating in the surrounding text that Table 1 is based on 300 runs. A reader reproducing Table 1 sets B=300, and the provided Rcode.R carries the full run. For a software illustration this is a reasonable resolution, and the defect that made the block error out is gone.

Two of the three editor_fix text errors remain in the current version. Section 3 still reads “even under the the standard Gaussian assumptions”, and Section 3.2 still reads “the 6rd” where “6th” is meant. Both carry values the paper itself fixes, so they belong on the production list for the proof. “Teh author” is corrected.

The seed decline is fine. Commenting the segmented.lme() seed behaviour and pointing to seg.control(seed=) in the text covers the replicability question without a code change, and the Example 1 narrative already explains the response-derived seed.

Numbered suggestions to the authors:

  1. [editor_fix] Correct the two remaining text errors for the proof: “under the the standard Gaussian assumptions” (duplicated “the”) in Section 3, and “the 6rd” (should read “6th”) in Section 3.2.

Revision

Authors' response2026-11-06 · 4 answersAuthors confirm each required point as done or give their reason for declining it. Further answers are voluntary, because the review compares every revision with the previous version and the next round's reports say what remains open.

Authors confirm each required point as done or give their reason for declining it. Further answers are voluntary, because the review compares every revision with the previous version and the next round's reports say what remains open.

recommended The submission still carries two stale copies of `Rcode.R` that do not match the paper: `upload: Rcode.R` (standalone) still fits `os1<-segmented(o, ...)` with the wrong starting object the prior round flagged, and `package+Rscript.zip: Rcode.R` still calls `sim.seg(N, nj=12, ...)` with the wrong argument `nj` and the old `n.plot=c(3,11)` layout. The author has named `Rcode+package.zip` as the reproduction artifact, which resolves the ambiguity, but removing or clearly marking the two superseded copies would stop a reader from running the wrong file.
Declined You clearly refer to the Rcode.R of the 1st submission. I really do not understand. I really can't see multiple copies of Rcode.R. When I go to submit a revision, I upload the zip file (paperJReprStatOK.zip) including the paper source files and a zip file (Rcode+package.zip) including the new Rcode.R along with the (updated) segmented package. I can't see (and can't cancel) the previous The other Rcode.R
recommended I am assessing from the manuscript and the described public interface. The package source, its help pages, and any `tests/` directory were not supplied, so I cannot confirm that the documented behaviour of `segmented.lme`, `plot.segmented.lme`, `sim.seg`, and `slope` is covered by automated tests. State in the paper whether the demonstrated functions are exercised by the package test suite, and point readers to where those tests live.
Declined I do not understand. When I go for a new the revision, I upload the zip file (paperJReprStatOK.zip) including the paper source files and a zip file (Rcode+package.zip) including the new Rcode.R along with the (updated) segmented package. Note that referee 1 writes "The uploaded Rcode.R and segmented_2.3-0 archive settle the reproducibility artifact as well. I am content with the resolution". Do it seems (s)he is able to run the example.
optional The declared reproduction artifact `Rcode+package.zip: Rcode.R` sets the simulation covariance as `S=diag(c(.12,.05,.3,.02)^2)` in the small simulation loop, so the breakpoint random-effect sd is 0.02. The paper's printed snippet uses `S=diag(c(.12,.05,.3,.1)^2)` and Table 1 reports σk true 0.10 with mean 0.090 and sd 0.011. A run with σk=0.02 cannot produce a mean of 0.090, so the uploaded authoritative script would not reproduce the σk row of Table 1. Set the fourth variance in `S` to `.1` in the uploaded script, or correct the Table 1 σk entries, so the script and the table agree.
Done done, thanks for reporting that.
recommended The package source extracted for this review contained only `Rcode.R`, not the `segmented` help pages or any `tests/` directory, so I cannot confirm that `segmented.lme`, `plot.segmented.lme`, `sim.seg`, `fixef`, `getVarCov`, `slope`, and `breakpoint` are exercised by automated tests. The earlier request (75ae2e1b) asked the paper to state whether these functions are covered by the package test suite and where those tests live; the revised text still does not say. One sentence pointing readers to the tests would close this.
Declined I do not understand. When I go for a new the revision, I upload the zip file (paperJReprStatOK.zip) including the paper source files and a zip file (Rcode+package.zip) including the new Rcode.R along with the (updated) segmented package. Note that referee 1 writes "The uploaded Rcode.R and segmented_2.3-0 archive settle the reproducibility artifact as well. I am content with the resolution". Do it seems (s)he is able to run the example.
Round 4Accepted3 reviewers
AcceptedSigned by Matthias Templ2026-11-18 · orcid 0000-0002-8638-5276

The editor's note

Accepted. All three reviewers recommend acceptance. The author corrected the simulation so that each replicate draws its own data set, and the journal ran his code with his package: Table 1 reproduces exactly from 300 replicates, and the two examples agree.

Decision letter2026-11-18Congratulations, your manuscript has been accepted for publication in JRepStat. Production begins now.

Congratulations, your manuscript has been accepted for publication in JRepStat. Production begins now.

Where it is not on file yet, we still need the following for production.

  • a valid ORCID iD for every author
  • a captured computational environment (dependencies/lockfile/container)
  • a signed determinism attestation for the entry-point command

Reviews

Report Reviewer 1recommends acceptBoth points I raised are met. Section 3.2 now reads “(the 6th, the 5th and the 10th, say)”, matching plot(oseg1, id=c(4,28,6,5,10)) and Figure 3, and the diagonal-matrix sentence now reads “e.g. a diagonal matrix”. Nothing from my report is still open.

Written by the journal's review engine in the role of the application reviewer, and read by the editor before the decision. How the engine works is on the peer review page.

Both points I raised are met. Section 3.2 now reads “(the 6th, the 5th and the 10th, say)”, matching plot(oseg1, id=c(4,28,6,5,10)) and Figure 3, and the diagonal-matrix sentence now reads “e.g. a diagonal matrix”. Nothing from my report is still open.

The three reproducibility points the author declined belong to other referees, not to me, and the author’s lines there report confusion about which Rcode.R copy is attached rather than a refusal to supply the artifact. On the version in front of me the uploaded Rcode.R and segmented_2.3-0 archive run as I reported last round, so from the application and reproducibility angle I am satisfied. If the submission system is carrying a stale Rcode.R from the first round alongside the current one, that is a matter for the editorial office to resolve at acceptance so the recorded artifact is the one that matches this manuscript.

Numbered suggestions to the authors: (none)

Report Reviewer 2recommends acceptAll three points I left open are settled in this version. Section 3 now reads “even under the standard Gaussian assumptions”. Section 3.2 reads “the 6th, the 5th and the 10th”, matching id=c(4,28,6,5,10) and Figure 3. Section 3.1 now reads “(−1.2796 + 0.5460)”, in agreement with the summary coefficient 0.5460.

Written by the journal's review engine in the role of the methodology reviewer, and read by the editor before the decision. How the engine works is on the peer review page.

All three points I left open are settled in this version. Section 3 now reads “even under the standard Gaussian assumptions”. Section 3.2 reads “the 6th, the 5th and the 10th”, matching id=c(4,28,6,5,10) and Figure 3. Section 3.1 now reads “(−1.2796 + 0.5460)”, in agreement with the summary coefficient 0.5460.

The three reproducibility points the author declined were raised by another reviewer, not by me, and concern the upload mechanics for Rcode.R and the segmented archive rather than any methodology question. They do not bear on my assessment. The methodology, the worked examples, the summary-output explanation for the dropped p-values, and the simulation with coverage levels in Table 1 all stand as accepted.

Nothing is open on my lens. I recommend acceptance.

Numbered suggestions to the authors:

Report Reviewer 3recommends acceptThe one item I left open is met. Section 3 now reads “even under the standard Gaussian assumptions for the ϵ’s” with the duplicated “the” removed, and Section 3.2 now reads “(the 6th, the 5th and the 10th, say)”, which matches the plot call id=c(4,28,6,5,10). Both production corrections are in the current version.

Written by the journal's review engine in the role of the software reviewer, and read by the editor before the decision. How the engine works is on the peer review page.

The one item I left open is met. Section 3 now reads “even under the standard Gaussian assumptions for the ϵ’s” with the duplicated “the” removed, and Section 3.2 now reads “(the 6th, the 5th and the 10th, say)”, which matches the plot call id=c(4,28,6,5,10). Both production corrections are in the current version.

On the reproducibility declines the author recorded: the response explains that each revision upload replaces the prior Rcode.R inside Rcode+package.zip, and that an earlier reference to multiple copies reflected a stale artifact the author cannot see or remove on their end. That reading is consistent with how the submission system versions attachments, and referee 1 confirms the uploaded Rcode.R and segmented_2.3-0 archive run. Those points were recommended, and the explanation convinces me, so I take them as settled.

Numbered suggestions to the authors: (none)

Peer review record (PDF) · How open review works

Abstract

We illustrate and discuss R code to fit segmented mixed models with random changepoints in a likelihood based framework. Some examples are presented to show capability of the methodology and of the relevant functions in the R package segmented.

Introduction

In segmented regression, the effect of a numeric covariate is expressed via a piecewise linear relationship, namely two straight lines with different slopes connected at some unknown value within the covariate range, the so-called breakpoint (Hardy, 2001; Muggeo, 2003). Segmented mixed models extend simple segmented regression to the mixed model framework by putting random effects in each model parameter, including the breakpoint (Cudeck & Klebe, 2002; Morrell et al., 1995; Muggeo et al., 2014). Random effects are popular to model longitudinal or clustered data when repeated measurements for each unit have been collected, see Fitzmaurice et al. (2004) for instance.

Assuming numeric data yijy_{ij}, with observational times tijt_{ij} (j=1,…,nij=1,\ldots,n_i and i=1,…,Ni=1,\ldots,N), the model reads as yij=β0i+β1itij+δi(tij−ψi)++ϵij,(1)\begin{equation} \label{eq:segmented} y_{ij}=\beta_{0i}+\beta_{1i}t_{ij}+\delta_{i}(t_{ij}-\psi_i)_++\epsilon_{ij}, \end{equation} \qquad(1) where the ϵij\epsilon_{ij} are the usual zero-mean stochastic component. Note that, according to parametrization above, the left and right slopes are β1i\beta_{1i} and β1i+δi\beta_{1i}+\delta_i respectively. Each parameter of model ((1)) is given by the sum of fixed effects, possibly depending on covariates, and the random component. Thus for the intercept and the left slope it is possible to write β0i=β00+x0iTβ0+b0iβ1i=β10+x1iTβ1+b1i,(2)\begin{equation} \label{eq:diffSlope} \beta_{0i}=\beta_{00}+x_{0i}^T\beta_0+b_{0i} \qquad\qquad \beta_{1i}=\beta_{10}+x_{1i}^T\beta_1+b_{1i}, \end{equation} \qquad(2) while for the slope-difference and the changepoint parameters we have δi=δ0+xdiTδ+diψi=κ0+ziTκ+ki.(3)\begin{equation} \label{eq:changepoint} \delta_i=\delta_0+x_{di}^T\delta+d_i \qquad\qquad \psi_i=\kappa_0+z^T_i\kappa+k_i. \end{equation} \qquad(3) The x0,x1,xdx_0,x_1, x_d and zz are, possibly overlapped, covariate vectors describing the subject features or experimental conditions, i.e. with values fixed within the same subject. Note that for the changepoint parameter, an alternative parameterization is ψi=a1+a2exp⁡{κ0+ziTκ+ki}1+exp⁡{κ0+ziTκ+ki}\psi_i=\frac{a_1+a_2\exp\{\kappa_0+z^T_i\kappa+k_i\}}{1+\exp\{\kappa_0+z^T_i\kappa+k_i\} }, where a1=min{tij}a_1=min\{t_{ij}\} and a2=max{tij}a_2=max\{t_{ij}\}. This logistic parameterization guarantees values of ψi\psi_i always in the admissible range (a1,a2)(a_1,a_2).

As usual, a multinormal distribution with zero mean and specified covariance matrix, is assumed for the random effects, i.e.

[b0ib1idiki]∼𝒩4([0000],[σb02...σb0b1σb12..σb0dσb1dσd2.σb0kσb1kσdkσk2]).(4)\begin{equation} \label{eq:normal.re} \left[ \begin{array}{l} b_{0i}\\ b_{1i}\\ d_i\\ k_i\\ \end{array}% \right] %(b_{0i},b_{1i},d_i,k_i)^T \sim \mathcal{N}_4 \left(\left[% \begin{array}{l} \:0\\ \:0\\ \:0\\ \:0\\ \end{array}% \right],\left[ \begin{array}{llll} \:\sigma^2_{b_0}&.&.&.\\ \:\sigma_{b_0b_1}&\sigma^2_{b_1}&.&.\\ \:\sigma_{b_0d}&\sigma_{b_1d}&\sigma^2_{d}&.\\ \:\sigma_{b_0k}&\sigma_{b_1k}&\sigma_{dk}&\sigma^2_{k}\\ \end{array}% \right]\right). \end{equation} \qquad(4)

The model has been discussed by several authors, and estimation has been illustrated mostly in a Bayesian paradigm, see Lange et al. (1992); Kiuchi et al. (1995); Jacqmin-Gadda et al. (2006). Muggeo et al. (2014) proposed estimation in a likelihood framework, i.e. without need to specify any prior for parameters.

We illustrate how to fit the model and to display the relevant results via specific functions of the R package segmented (Muggeo, 2008), version 2.3-0. Full information on the operating system, the R version, and on additional packages used, is reported at the end of section 3.

The rest of the paper is organized as follows: section 2 introduces the functions by describing their main arguments, and section 3 reports some analyses on real-data as well as on a simulated dataset. Finally, section 4 is devoted to conclusions and discussion.

Structure of the functions

The main function is segmented.lme shipped within package segmented for R (R Core Team, 2026), with main arguments

segmented.lme(obj, seg.Z, z.psi =~1, x.diff =~1, random,
              psi.link = c("identity", "logit"))

obj is a classical ‘lme’ object returned by lme() from the nlme package (Pinheiro & Bates, 2000) that is automatically loaded along with segmented; seg.Z is one-sided formula to specify the ‘segmented’ covariate having the piecewise linear relationship with the response, namely the tijt_{ij} values in equation ((1)). x.diff and z.psi are one-sided formulas to indicate the possible covariates for the slope difference δi\delta_i and for the breakpoint ψi\psi_i, i.e. respectively the xdx_d’s and the zz’s in equations ((3)). Both of them default to ~1, meaning no covariate, namely δ=0\delta=0 and κ=0\kappa=0. Dependence on covariates of the linear parameters β0i\beta_{0i} and β1i\beta_{1i} can be modelled via appropriate main effects or interaction terms to be included in the starting obj. psi.link specifies which sub-regression model should be employed for the breakpoint, linear or logistic, as discussed in the previous section.

random allows to set the random structure of the model, namely the covariance matrix in equation ((4)). It should be a list with a formula for the clustering variable, typically the subject identifier. The formula can include any linear variable in the model and, more importantly, the specific terms U and G0 to set random effects, respectively for the difference-in-slope (the did_i’s), and for breakpoint (the kik_i’s). Some possible specifications of the random effects covariance in ((4)) using the constructors of positive-definite matrix classes in the package nlme, are reported below. We refer to model ((1)), with the tijt_{ij} values represented by the variable time, and clustering variable id.

i

random=list(id=pdDiag(~1+time+U+G0)): independent random effects in each model parameter, namely the covariance matrix is diagonal;

ii

random=list(id=pdBlocked(list(pdDiag(~1+time), pdSymm(~U+G0-1)))): a block diagonal covariance matrix, where the second block assumes correlated random effects, namely all covariances set to zero but σdk\sigma_{dk};

iii

random=list(id=pdBlocked(list(pdSymm(~1+time), pdSymm(~U+G0-1)))): a block diagonal covariance matrix, where both the blocks assume correlated random effects, namely all covariances set to zero but σdk\sigma_{dk} and σb0b1\sigma_{b_0b_1};

iv

random=list(id=pdSymm(~1+time+U+G0)): non-independent random effects, i.e. the full covariance matrix is estimated.

The four specifications above are listed according their complexity: the first one is the simplest and, probably, it could represent the first option when one is interested in assessing if heterogeneity is supported by data. For this very reason, segmented.lme() simplifies that by also accepting in random a simple formula; in other words, random=id~time+U+G0 will set independent random effects without specifying pdDiag. In item iv, we want to estimate an unstructured covariance matrix with 4 variances and 6 covariances. Of course, the more complex the model, the better the fit and corresponding predictions, but also the heavier the corresponding computational burden which could make model estimation more demanding: namely overfitting with unsuccessful fits. Roughly speaking, if the model being fitted is not supported by data (for instance unnecessary covariances or even variances), troubles can arise in reaching convergence. This is true also in linear mixed models, but it is enhanced in nonlinear mixed models and in the segmented, in particular, see Example 2 in sec 3.2.

The object resulting from segmented.lme() is a list of class ‘segmented.lme’, with some related methods, such as print.segmented.lme, summary.segmented.lme, vcov.segmented.lme, and the plot method plot.segmented.lme. In particular, the ‘plot’ method can be used to produce graphics of the resulting model, namely the fitted segmented lines along with observations. The function with its main arguments is

plot.segmented.lme(x, level=1, id = NULL, res = TRUE, pop = FALSE,
           yscale = 1, xscale=1,  n.plot, by=NULL, ...)

x is the fit object returned by segmented.lme(), and level refers to the level of grouping, with level zero corresponding to the population fitted values; id specifies which profiles should be drawn (default to NULL meaning all profiles); res=TRUE indicates if the plot should also include the observations; finally pop=TRUE adds the population (i.e. based on fixed effects only) estimates. The remaining arguments affect the appearance. yscale and xscale regulate the yy and the xx-scale of the figures: if negative values are supplied, ‘individual’, i.e. subject-specific limits are used, otherwise the common limits are obtained by considering the ranges of all subjects. Finally n.plot is a vector to be passed to mfrow when multiple plots have to be produced.

If the fixed-effect (i.e. level=0) relationship depends on some covariates (included via interactions in the starting lme fit or via the arguments x.diff and/or z.psi of segmented.lme), the argument by allows to specify for which covariate pattern the relationships has to be drawn, see examples in the next section.

Fitting the model in practice

Broadly speaking, maximization of log marginal likelihood is quite a difficult task in nonlinear mixed models, even under the standard Gaussian assumptions for the ϵ\epsilon’s in ((1)) and for the random effects in ((4)). The load is enhanced in segmented mixed models as the breakpoints make the model non regular. The approach implemented in segmented.lme, based on the aforementioned Gaussian assumptions, is discussed in detail in Muggeo et al. (2014) and relies on iterative fitting of simple linear mixed models via the lme() function of the nlme package. The algorithm is quite efficient but, due to possible local optima, bootstrap restarting (Wood, 2001) is also implemented to escape the local solutions where the algorithm can get stuck.

Example 1: real data

The dataframe glucoseData shipped with the package includes data on n=33n=33 patients (in two groups, Control and Obese) who took a standard glucose tolerance test. The goal was to assess the pattern of phosphate elimination (phos) with respect to time after introduction: therefore the response measurements are plasma inorganic phosphate (inversely related to glucose level) taken at the beginning and 0.5, 1, 1.5, 2, 3, 4, and 5 hours after introduction. Data come from Zerbe (1979) and have been analysed also in Cudeck & Klebe (2002).

A first look to data can be provided by scatterplots for each subject,

> plot(groupedData(phos~time|subj,data=glucoseData)) #plot not shown

The Phosphate level decreases immediately after administration and recovers subsequently, which suggests that a segmented mixed models could be a reasonable tool for the analysis. To fit the model, we first fit the starting linear mixed model via lme(), and then add the piecewise-linear relationship via segmented.lme(), which does not need to be called explicitly as it is a method function in the R philosophy. Hence

> o <-lme(phos~time, random=~1|subj, data=glucoseData)
> os <-segmented(o, ~time, random=subj~1+time+U+G0)

With respect to the starting lme object, segmented.lme() updates the fixed part formula by adding the slope-difference term along with the breakpoint, and replaces the random statement by the new one; as discussed in the previous section, here we use a simple formula to set independent random effects. When implementing the bootstrap restarting, the bootstrap samples are randomly drawn, leading to select different starting values at each run; however, the global optimum is evaluated on the original dataset, and therefore the final solution is expected to be independent of the bootstrap runs, at least when data are not excessively noisy. However, to make fully replicable the analysis on the same data, including the ‘path’ driving to the final solution, segmented.lme() uses a seed coming from the response values; as an alternative, it is also possible to set it explicitly in the call via seg.control(), namely segmented(.., control=seg.control(seed=..)).

The print method returns some basic information, just like the print method for lme objects, namely point estimates for the fixed effects and the variance components

> os
Segmented linear mixed-effects model fit by REML
  Data: glucoseData 
  Log-restricted-likelihood (approx): -155.9955
  Bootstrap restarting on 6 samples; 1 different solution(s)

Fixed: phos ~ time + U + G0 
(Intercept)        time           U          G0 
  4.3050486  -0.8483528   1.2048822   1.6624618 
  psi.link = identity

Random effects:
 Formula: ~time + U + G0 | subj
 Structure: Diagonal
        (Intercept)       time           U        G0 Residual
StdDev:    0.675425 0.00189322 0.003314052 0.4340041 0.365604

Number of Observations: 264
Number of Groups: 33 

The fixed effects correspond to estimates of the intercept, left slope and slope-difference (coefficient of U), while the coefficient of G0 is the changepoint estimate (i.e. ψ̂=1.662\hat\psi=1.662). The high standard deviations for the intercepts and G0 underline the high heterogeneity of the subjects with respect to their intercepts and changepoints.

The first output of the print method (and also of summary, see later) is the log (marginal) likelihood value which comes from an approximation, as illustrated in Muggeo et al. (2014). Model fitting via maximization of the actual likelihood requires heavy computations and numerical integration that could lead to a considerable computational burden. Simulation studies presented in Muggeo et al. (2014) and in the end of section 3, show that such approximation works reasonable well in practice, while maintaining an acceptable execution times.

According to results of model os, all subjects share the same V-shaped pattern (quite low σ̂b1\hat\sigma_{b_1} and σ̂d\hat\sigma_d), although their changepoints are different. However, data refer to Control and Obese patients, therefore it could be interesting to assess whether the two V-shaped relationships are the same or not in the two groups. Therefore, we include the term group as main effect and interaction term in the starting lme fit, and also in the arguments x.diff and z.psi,

> o1<-lme(phos~time*group, random=~1|subj, data=glucoseData)
> os1<-segmented(o1, ~time, z.psi=~group, x.diff=~group, 
+                random=subj~1+time+U+G0)

When there are interaction terms, the summary.lme() returns results by assembling the estimates of each parameter of the regression equation ((1)),

> summary(os1)
Segmented mixed-effects model fit by REML
       AIC      BIC    logLik
  327.5191 373.7076 -150.7596
 Bootstrap restarting on 6 samples;  1 different solution(s)

Random effects:
 Formula: ~time + U + G0 | subj
 Structure: Diagonal
        (Intercept)       time           U        G0  Residual
StdDev:   0.5619773 0.05488536 0.003517548 0.2958991 0.3511334

Fixed effects:
                  Value Std.Error  DF t-value p-value
(Intercept)      4.0349    0.1788 225  22.567 0.00000
groupObese       0.5113    0.2271  31   2.252 0.03155
-- leftS:                                            
time            -1.2796    0.1415 225  -9.045 0.00000
time:groupObese  0.5460    0.1521 225   3.589 0.00041
-- diffS:                                            
U                1.6481    0.1446 225  11.397        
U.groupObese    -0.5350    0.1611 225  -3.322 0.00104
-- break:                                            
G0               1.1086    0.1170 225                
G.groupObese     1.0465    0.1714 225   6.104 0.00000
 psi.link = identity 

Standardized Within-Group Residuals:
        Min          Q1         Med          Q3         Max 
-2.73565679 -0.55307557  0.01409987  0.63157506  3.20513447 

Number of Observations: 264
Number of Groups: 33 

As in the summary of usual lme fits, the last columns return tt-values relevant to the null hypothesis of zero coefficient, and pp-values relying on a Gaussian distribution of the estimator under the null hypothesis. It is well known that such approximation is not reliable for δ̂0\hat\delta_0 (Muggeo, 2016, 2025), and therefore the term U misses the pp-value; the corresponding tt-value is displayed, as it can be used to quantify the strength of the slope change estimate regardless of the reference null distribution. For the changepoint, testing for a zero value is meaningless, and therefore both the tt- and the pp-value have been dropped. However, for the remaining regression coefficients including those in equations ((3)), the Normal approximation for the sampling distributions is generally understood to be valid, making the pp-values acceptable from a statistical viewpoint, at least in large samples.

The confint method returns the interval estimates for the model parameters, using again the Wald statistic relying on a limiting Gaussian distribution and asymptotic model-based standard errors (that are returned internally by the vcov method)

> t(confint(os1))
                       2.5%      97.5%
(Intercept)      3.68444601  4.3853227
time            -1.55692116 -1.0023407
groupObese       0.06626251  0.9563422
U                1.36470061  1.9315360
G0               0.87932679  1.3378761
G.groupObese     0.71045946  1.3825110
U.groupObese    -0.85069494 -0.2193703
time:groupObese  0.24784367  0.8440827

By looking at the results, the curve for the Obese patients can be considered different from the Control group. More specifically, the Obese group has a higher intercept (4.0349+0.51134.0349+0.5113), a less steep left slope (−1.2796+0.5460-1.2796+0.5460), and a larger changepoint (1.1086+1.04651.1086+1.0465). To have estimates of the slopes and breakpoints in both groups, we use the functions slope() and breakpoint(),

> slope(os1) #in the baseline group
                 Est.     St.Err t value   0.95.low    0.95.up
leftSlope  -1.2796309 0.14147721  -9.045 -1.5569212 -1.0023407
rightSlope  0.3684874 0.03629992  10.151  0.2973409  0.4396339
>
> slope(os1, by=list(group="Obese"))
                 Est.     St.Err t value   0.95.low    0.95.up
leftSlope  -0.7336678 0.05585699 -13.135 -0.8431455 -0.6241901
rightSlope  0.3794180 0.04677694   8.111  0.2877368  0.4710991

The former call returns the slopes corresponding to the baseline values of the interaction term, i.e. group='Control', while in the latter, we specify the covariate and its corresponding label of interest via argument by to obtain the slopes in the Obese group. Likewise, for the estimated breakpoint we type

> breakpoint(os1) #in the baseline group
        Est.    St.Err  0.95.low  0.95.up
psi 1.108601 0.1296831 0.8793268 1.337876
>
> breakpoint(os1, by=list(group="Obese"))
        Est.    St.Err  0.95.low  0.95.up
psi 2.155087 0.2701112  1.909431 2.400742

As in confint, the confidence intervals returned by slope() and breakpoint() are computed using the approximate Gaussian distribution of the Wald statistic. We remark such approximation is generally reliable if the sample is large, the breakpoint is understood to exist, and the segmented relationship is rather clear-cut. We present results from a small simulation study in the next section to bear this out.

Some graphical outputs could complete the analysis. For instance, to visualize the fitted segmented profiles, the method plot described in the previous section can be used. Thus typing

> plot(os1, n.plot=c(5,7), res=TRUE, 
+      l.col=rep(c(4,2), c(13,20)), l.lty=rep(c(1,2), c(13,20)),
+      ylab="Phosphate level (mg/dl)", xlab="Hours after challenge")

produces the output of Figure 1. Dots are the observed data (via res=TRUE), and the lines portray the individual profiles (given by the sum of fixed effects and random predictions), while symbols on the bottom locate the individual changepoints. In this example there n=33n=33 subjects, so we decide to put the individual panels into 5 rows and 7 columns (n.plot=c(5,7)), and to use the blue and continuous line to display the first 13 subjects (of the Control group), and the red and dashed line for the 20 individuals of the Obese group. We specify such color and line type vectors in the argument l.col and l.lty.

Fig 1: Output of plot.segmented.lme(..) to display the individual profiles. The continuous blue and the dashed red lines refer to the Control and Obese groups respectively.

Finally, for illustrative purposes, we also report additional plots in Figure 2 by running the following code

> par(mfrow=c(1,2))
> #left panel (population estimates)
> plot(os1, level=0, vline=TRUE, ylim=c(1,6), p.lwd=4, p.col=4,
+      pos.leg="topleft", text.leg = "Control" )
> plot(os1, level=0, by=list(group="Obese"), add=TRUE, p.col=2, p.lty=2,
+      pos.leg="top", text.leg = "Obese" ,vline=TRUE, p.lwd=5)
> #right panel
> plot(os1, n.plot=1, l.col=2:6, ylim=c(1,6), dens.col=grey(.5), res=FALSE)

In the left panel we first plot the baseline population segmented relationship in the baseline (Control) group, then we add the Obese group estimate via arguments add and by; p.col and p.lwd are used to set width and color of the segmented lines. On the right panel, we display the subject-specific profiles along with a kernel density of the individual breakpoints on the bottom. Unlike the previous plot in Figure 1, we do not specify the axes labels, but we let the function to take the variable names, as happen in the other plot functions in R.

Fig 2: Additional output of plot.segmented.lme(..). Marginal profiles in the left panel, and subject-specific predictions in the right. On the bottom, the nonparametric density estimate of the individual breakpoints is optionally reported (via the dens.col): the bimodality comes from having different fixed-effect breakpoint estimates in two groups. time in the xx-axis refers hours after challenge and phos on the yy-axis to phosphate level (mg/dl).

By looking at the variance estimates of model os1, we note that the heterogeneity in the slope difference is quite low, σ̂d=0.0035\hat\sigma_d=0.0035. While the estimation process did not return any error or warning message, we could assess whether the fit could be simplified by removing it in the interest of the parsimony principle. However, in the same perspective as model selection, we should also assess if data support a more complex model, for instance by also estimating σb0b1\sigma_{b_0b_1} and σdk\sigma_{dk}, for instance. To this end, we exploit the usual update() function in R, to change just a single argument value with respect to os1,

> os2<-update(os1, random=subj~time+G0)
> os3<-update(os1, random=list(subj=
+             pdBlocked(list(pdSymm(~1+time), pdSymm(~U+G0-1)))))
> AIC(os1,os2,os3)
    df      AIC
os1 13 327.5191
os2 12 325.5192
os3 15 327.1868

While the AIC values (and the BIC as well) suggest that os2 could be preferred, it should be remarked that model selection is a hot and open research topic in mixed models. We do not pursue the topic further, as it is beyond the scope of this paper.

Example 2: simulated data

As a further example we use simulated data. The aim is twofold: to illustrate the code for somewhat more complicated modelling, and to ‘assess’ the results reliability by comparing them with the true values. We discuss results for a single dataset and then across several datasets in a small simulation study at the end of section.

We simulate data by means of the function sim.seg() that, with its main arguments, reads as

> args(sim.seg)
  function (N, ni, fixEff = c(2, -0.2, 0.3, 0.4), 
  S = diag(c(0.05, 0.05, 0.05, 0.07)^2), seg.Z = NULL, z.psi, x.diff, 
  sd.eps = 0.01, seed) 

N and ni are the number of subjects and the number of measurements per subject, fixEff indicates the 4 fixed parameters (β0,β1,δ0,κ0)(\beta_0,\beta_1,\delta_0,\kappa_0), S the covariance matrix in ((4)), seg.Z the segmented covariate, and x.diff and z.psi the covariates and corresponding coefficients for the sub-regression models for δi\delta_i and ψi\psi_i using a linear link. Both arguments are specified via a list with coefficient(s) and covariate values, see the example below. It is assumed that such variables are subject-specific, so NN values have to be provided for each variable: a NN-dimensional vector for a single covariate (which needs a single coefficient), and a N×pN\times p matrix for pp covariates (and pp coefficients have to be specified). We set the seeds just to reproduce the results

> N=30
> set.seed(123)
> Xd=runif(N, 0,2) #1 covariate for delta (N-vector)
> Z=cbind(1:N/N, rnorm(N)) #2 covariates for psi (N x 2 matrix)
> dd=sim.seg(N, ni=12, S=diag(c(.12,.05,.3,.1)^2),
+          x.diff=list(.5,Xd), z.psi=list(c(.3,-.2),Z), sd.eps=.003, seed=15)
> 
> d=dd$data
>
> head(d,3)
  id        y          x     Xdif      Zpsi1    Zpsi2
1  1 1.931448 0.06693461 0.575155 0.03333333 1.786913
2  1 1.932327 0.09619888 0.575155 0.03333333 1.786913
3  1 1.934428 0.10839553 0.575155 0.03333333 1.786913

In the simulated dataset, Xdif is the covariate for the slope change parameter, and Zpsi1 and Zpsi2 affect the changepoint.

To fit the segmented model, we can avoid to fit a lme object beforehand and specify the fixed effect formula directly in segmented.lme() which has to be called explicitly; we also need to indicate the dataframe where the variables are stored

> oseg1 <- segmented.lme(y~x, ~x, x.diff=~Xdif, z.psi=~Zpsi1+Zpsi2, 
+                        random=id~1+x+U+G0, data=d)

Out of curiosity, we can compare the true fixed effect versus the corresponding estimates extracted by fixef(),

> cbind(true=c(2,-0.2,0.3,0.4,0.3,-0.2,0.5), est=fixef(oseg1))
            true        est
(Intercept)  2.0  2.0457565
x           -0.2 -0.1990579
U            0.3  0.2526996
G0           0.4  0.3547105
G.Zpsi1      0.3  0.3545174
G.Zpsi2     -0.2 -0.1827813
U.Xdif       0.5  0.5980579

while for the random effects, we take the main diagonal of the covariance matrix extracted by getVarCov()

> cbind(true=c(0.12,0.05,0.30,0.10), est=sqrt(diag(getVarCov(oseg1))))
            true        est
(Intercept) 0.12 0.11410761
x           0.05 0.05667073
U           0.30 0.25146646
G0          0.10 0.10089096

As in the previous example, to compute correctly the slopes and breakpoints accounting for the interaction variables, we need to specify the covariate pattern in the argument by. For instance, for the breakpoint depending on Zpsi1 and Zpsi2, and assuming 0.50.5 and −1.2-1.2 are two values of interest, we type

> breakpoint(oseg1, by=list(Zpsi1=.5,Zpsi2=-1.2))
         Est.     St.Err  0.95.low   0.95.up
psi 0.7513068 0.02449226 0.6874128 0.8152007

oseg1$psi.i includes the predicted NN changepoints with two attributes: "ni" the number of measurements per subject, and "is.break" a logical vector indicating whether the individual changepoint is within the covariate range or not. Possible FALSE values identify subjects wherein the changepoint has been predicted on the boundary, and whose corresponding profiles are estimated to be linear. Thus

> which(!attr(oseg1$psi.i, "is.break"))
 4 28 
 4 28 

Hence, the model identifies two subjects with a fitted linear profile, and it is worth checking if such ‘predictions’ are correct. In order to do that, note the object returned by sim.seg() also includes the actual breakpoints (dd$psi.i), and its percentile (dd$perc.psi) with respect to corresponding covariate ranges. Clearly, if the percentile is 0 or 1, the breakpoint is on boundary, leading to data simulated according to underlying linear profiles. We have

> which(dd$perc.psi%in%c(0,1))
[1]  4 28

Thus, we can claim predictions are correct to detect subjects with no change. We display their predicted linear profiles along with some additional segmented profiles (the 6th, the 5th and the 10th, say) using their specific xx- and yy-scales,

> plot(oseg1, id=c(4,28,6,5,10),n.plot=c(1,5), yscale=-1,xscale=-1)
Fig 3: Output for 5 subjects on their individual xx and yy scales (via xscale=-1 and yscale=-1).

In addition to the aforementioned linear profiles for subjects 4 and 28, it is worth stressing the fitted line for subj# 6: interestingly, even if data follow an almost linear pattern, the model succeeds in predicting correctly the corresponding breakpoint.

We now try to fit the same model, but with a non-null covariance between the breakpoint and the slope difference random effects, i.e. σdk≠0\sigma_{dk}\neq0 in ((4)).

> oseg2<-update(oseg1, 
+              random=list(id=pdBlocked(list(pdDiag(~1+x), pdSymm(~U+G0-1)))))
 There were 14 warnings (use warnings() to see them)

While the procedure succeeds in fitting the model, several warning messages are returned.

> warnings()
Warning messages:
1: In logLik.reStruct(object, conLin) :
  Singular precision matrix in level -1, block 28
..............
14: In logLik.reStruct(object, conLin) :
  Singular precision matrix in level -1, block 28

The reason is that we are trying to fit a over-parametrized model having an additional covariance parameter which is actually zero. In general, when we try to estimate more parameters than the data support, it is not rare to run into such warnings or even error messages with no final fit. Starting the analysis with a simple structure, e.g. a diagonal matrix, for the random effects covariance matrix is, generally, recommended.

We conclude this section by running a small simulation experiment using the following code. Results are displayed in Table 1 based on B=300 runs rather than B=3.

> #a small simulation study
> N=50
> set.seed(123)
> Xd=runif(N, 0, 2) #1 covariate for delta (N-vector)
> Z=cbind(1:N/N, rnorm(N))
> 
> B=3
> V=matrix(,B,4)
> SE<-E<-matrix(,B,7)
> 
> for(i in 1:B){
+   dd=sim.seg(N,ni=10,S=diag(c(.12,.05,.3,.1)^2), seed=i,
+            x.diff=list(0.5,Xd), z.psi=list(c(.3,-.1),Z), sd.eps=.01)
+   d=dd$data
+   suppressWarnings(oseg1 <-segmented.lme(y~x, ~x, 
+             x.diff=~Xdif, z.psi=~Zpsi1+Zpsi2, 
+             random=id~1+x+U+G0, data=d))
+   
+   V[i,]<-sqrt(diag(getVarCov(oseg1)))#sd
+   E[i,]<-fixef(oseg1)
+   SE[i,]<-sqrt(diag(vcov(oseg1)))
+ }
Table 1: Results of the simulation experiment: mean, median and standard deviations of the sampling distributions, and mean of the standard errors. The last column refers to the coverage levels of the 95% confidence intervals based on the Normal distribution of the Wald statistic. Results based on 300 replicates.
      sampling distribution summary
4-7parameter true mean med sd se‾\bar{\mathrm{se}} CL
β0\beta_0   2.0 2.001 2.002 0.016 0.017 0.970
β1\beta_1   −0.2-0.2 −0.199-0.199 −0.199-0.199 0.011 0.009 0.923
δ0\delta_0   0.3 0.279 0.271 0.092 0.095 0.937
δ1\delta_1   0.5 0.504 0.501 0.078 0.079 0.950
κ0\kappa_0   0.4 0.402 0.403 0.030 0.028 0.910
κ1\kappa_1   0.3 0.280 0.280 0.055 0.049 0.877
κ2\kappa_2   −0.1-0.1 −0.094-0.094 −0.094-0.094 0.017 0.015 0.897
*[.2cm] σb0\sigma_{b0}   0.12 0.119 0.119 0.012 - -
σb1\sigma_{b1}   0.05 0.052 0.051 0.014 - -
σd\sigma_{d}   0.30 0.308 0.307 0.037 - -
σk\sigma_{k}   0.10 0.090 0.090 0.011 - -

The means and medians are rather overlapped, suggesting that the underlying distributions are fairly symmetric; the estimators appear substantially unbiased, with κ̂0\hat\kappa_0, κ̂1\hat\kappa_1, and κ̂2\hat\kappa_2 sharing slight differences between the means and the corresponding true parameter values. The model-based standard errors appears to quantify appropriately the corresponding standard deviations for all estimators but κ̂0\hat\kappa_0, κ̂1\hat\kappa_1, and κ̂2\hat\kappa_2. Their corresponding coverage levels in the last column exhibit values lower than the nominal 95%, unlike the other interval estimators having values quite close to 0.95. Overall, the breakpoint parameters appear, unsurprisingly, to be those having an unsatisfactory performance of the Wald statistic. Better performances, however, are expected with larger samples or in scenarios with higher signal-to-noise ratio. Broader simulation settings, and further investigation are beyond the goal of this paper; some additional results are discussed in Muggeo et al. (2014). Regardless the sample size or the signal-to-noise ratio, we remark that the Wald statistic δ̂0/SE(δ̂0)\hat\delta_0/\mathrm{SE}(\hat\delta_0) is useless, and the existence of the breakpoint, with or without heterogeneity, cannot currently be tested via the functions in the package.

At the end we report technical information on the machine used to run the code


> sessionInfo()
R version 4.6.2 (2026-10-29 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 26200)

Matrix products: default
  LAPACK version 3.12.1

locale:
[1] LC_COLLATE=Italian_Italy.utf8  LC_CTYPE=Italian_Italy.utf8    LC_MONETARY=Italian_Italy.utf8
[4] LC_NUMERIC=C                   LC_TIME=Italian_Italy.utf8    

time zone: Europe/Rome
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] segmented_2.3-0 nlme_3.1-171    MASS_7.3-66    

loaded via a namespace (and not attached):
[1] compiler_4.6.2 tools_4.6.2    splines_4.6.2  grid_4.6.2     stats4_4.6.2   lattice_0.23-1

Conclusions

We have discussed how to fit segmented mixed models within the R environmentvia the segmented package. At time of writing, to the best of author’s knowledge, there is no package on CRAN to fit such class of models in a likelihood (non-Bayesian) framework. While the Bayesian approach can lead to in-depth results via the parameter posterior distributions, a simple effective framework could foster a somewhat more widespread adoption and usage of the model in practical applications (Krefman et al., 2021).

The method (and functions) are not limited to analysis of data equal number of measurements per subject, by working reasonably well and relatively fast. In our experience, some troubles can arise when the structure of the random effects covariance matrix is uselessly complicated, namely too many variances and covariances. Especially with noisy data, we suggest to start from a simple model, such as a diagonal covariance matrix, and then to try progressively more complex structures as illustrated in sec 3.2. However the AIC based on the log marginal likelihood, as that returned by AIC() function, is known not to be appropriate when the focus is on the clusters, and a conditional AIC should be used (Vaida & Blanchard, 2005). Implementing that, along with an hypothesis testing procedures for the existence of breakpoint and corresponding heterogeneity (Muggeo, 2025; Segalas et al., 2019; Spuck et al., 2026), and model fitting with more than 1 breakpoint, represent notable extensions for the segmented package.

Data and Code Availability

The analyses and relevant results reported in this paper, have been obtained via the R package segmented, version 0.2-3. The glucoseData dataset of section 3.1 (example 1) is shipped with the package, and the simulated dataset of section 3.2 is obtained via the code reported in the text. The file Rcode.R contains the R code to replicate the analyses, including the simulation experiment and corresponding results of Table 1. The file Rcode.R along with segmented 2.3-0 are available as Supplentary Material of this paper at https://jrepstat.fairpressjournals.com/articles/; The R package segmented is also downloadable from CRAN at
https://cran.r-project.org/web/packages/segmented/index.html.

The author is the creator, developer and the maintainer of segmented package.

Acknowledgements

The author thanks the Editor and the three referees for the insightful comments that led to a substantial improvement of the paper. The author also thanks dr. V. Genova for reading the draft version of the manuscript.

References

  • Cudeck, R., & Klebe, K. J. (2002). Multiphase mixed-effects models for repeated measures data. Psychological Methods, 7(1), 41–63. https://doi.org/10.1037/1082-989x.7.1.41 ↩ 1 2
  • Fitzmaurice, G. M., Laird, N. M., & Ware, J. H. (2004). Applied longitudinal analysis. Wiley. ↩
  • Hardy, R. (2001). Commentary: Are piecewise mixed effects models useful in epidemiology? International Journal of Epidemiology, 30(6), 1341–1342. https://doi.org/10.1093/ije/30.6.1341 ↩
  • Jacqmin-Gadda, H., Commenges, D., & Dartigues, J.-F. (2006). Random changepoint model for joint modeling of cognitive decline and dementia. Biometrics, 62, 254–260. ↩
  • Kiuchi, A. S., Hartigan, J. A., Holford, T. R., Rubinstein, P., & Stevens, C. E. (1995). Change Points in the Series of T4 Counts Prior to AIDS. Biometrics, 51(1), 236. https://doi.org/10.2307/2533329 ↩
  • Krefman, A. E., Labarthe, D., Greenland, P., Pool, L., Aguayo, L., Juonala, M., Kähönen, M., Lehtimäki, T., Day, R. S., Bazzano, L., Muggeo, V. M. R., Van Horn, L., Liu, L., Webber, L. S., Pahkala, K., Laitinen, T. T., Raitakari, O., Lloyd-Jones, D. M., & Allen, N. B. (2021). Influential Periods in Longitudinal Clinical Cardiovascular Health Scores. American Journal of Epidemiology, 190(11), 2384–2394. https://doi.org/10.1093/aje/kwab149 ↩
  • Lange, N., Carlin, B. P., & Gelfand, A. E. (1992). Hierarchical Bayes Models for the Progression of HIV Infection Using Longitudinal CD4 T-Cell Numbers. Journal of the American Statistical Association, 87(419), 615–626. https://doi.org/10.1080/01621459.1992.10475258 ↩
  • Morrell, C. H., Pearson, J. D., Carter, H. B., & Brant, L. J. (1995). Estimating Unknown Transition Times Using a Piecewise Nonlinear Mixed-Effects Model in Men with Prostate Cancer. Journal of the American Statistical Association, 90(429), 45–53. https://doi.org/10.1080/01621459.1995.10476487 ↩
  • Muggeo, V. M., Atkins, D. C., Gallop, R. J., & Dimidjian, S. (2014). Segmented mixed models with random changepoints: a maximum likelihood approach with application to treatment for depression study. Statistical Modelling, 14(4), 293–313. https://doi.org/10.1177/1471082x13504721 ↩ 1 2 3 4 5 6
  • Muggeo, V. M. R. (2003). Estimating regression models with unknown break‐points. Statistics in Medicine, 22(19), 3055–3071. https://doi.org/10.1002/sim.1545 ↩
  • Muggeo, V. M. R. (2008). Segmented: An R package to fit regression models with broken-line relationships. R News, 8(1), 20–25. ↩
  • Muggeo, V. M. R. (2016). Testing with a nuisance parameter present only under the alternative: a score-based approach with application to segmented modelling. Journal of Statistical Computation and Simulation, 86(15), 3059–3067. https://doi.org/10.1080/00949655.2016.1149855
  • Muggeo, V. M. R. (2025). Letter to the Editors: Comments on “Statistical inference on change points in generalized semiparametric segmented models” by Yang et al. (2025). Biometrics, 81(4). https://doi.org/10.1093/biomtc/ujaf147 ↩ 1 2
  • Pinheiro, J. C., & Bates, D. M. (2000). Mixed-effects models in s and s-PLUS,. Springer. ↩
  • R Core Team. (2026). R: A Language and Environment for Statistical Computing. R Foundation for Statistical Computing. https://doi.org/10.32614/r.manuals ↩
  • Segalas, C., Amieva, H., & Jacqmin‐Gadda, H. (2019). A hypothesis testing procedure for random changepoint mixed models. Statistics in Medicine, 38(20), 3791–3803. https://doi.org/10.1002/sim.8195 ↩
  • Spuck, N., Schmid, M., & Berger, M. (2026). Detection of nonlinearity, discontinuity and interactions in generalized regression models. Statistical Modelling, 26, 248–276. ↩
  • Vaida, F., & Blanchard, S. (2005). Conditional Akaike information for mixed-effects models. Biometrika, 92(2), 351–370. https://doi.org/10.1093/biomet/92.2.351 ↩
  • Wood, S. N. (2001). Minimizing Model Fitting Objectives That Contain Spurious Local Minima by Bootstrap Restarting. Biometrics, 57(1), 240–244. https://doi.org/10.1111/j.0006-341x.2001.00240.x ↩
  • Zerbe, G. O. (1979). Randomization Analysis of the Completely Randomized Design Extended to Growth and Response Curves. Journal of the American Statistical Association, 74(365), 215–221. https://doi.org/10.1080/01621459.1979.10481640 ↩

Cite this article

Muggeo, V. M. R. (2026). Fitting segmented mixed models with random changepoints in R. Journal of Reproducible Statistics, 1, 12. https://doi.org/10.68365/jrepstat.2026.12

doi: https://doi.org/10.68365/jrepstat.2026.12

Downloads

PDF ePub JATS XML .bib .ris .csl.json Reproducibility package (.zip) 3f6ef883776ecb17157afb1f09c61751863dca28a64e96c9224a9c81a74e3e68

https://doi.org/10.68365/jrepstat.2026.12 also supports content negotiation, so reference managers can fetch the citation from the DOI directly. The exports above work without it.