22 Novembre 2026

Psicologia Punto One | Psicologia e Psicologi nel Web

Menu

Menu

SCHEDA SCIENTIFICA2026Altra ricerca

Piecewise modeling for longitudinal psychological research: a tutorial using R.

He S, Lee W

Frontiers in psychology · 2026

Abstract originale

Longitudinal psychological research often centers on key developmental transitions, where patterns of change may differ across stages. Piecewise modeling is well suited to capturing these stage-specific changes. This tutorial introduces three piecewise methods in longitudinal psychological research: piecewise multilevel modeling (MLM), piecewise latent class growth modeling (LCGM), and latent transition analysis (LTA). Drawing on a six-wave longitudinal study of national identity development, we show how each method can be implemented in R and highlight the types of research questions each is designed to address, from estimating average developmental trajectories to identifying heterogeneous trajectory patterns and examining transitions between latent developmental states.

Parole chiave

MAPSlatent class growth modellatent transition analysislongitudinal methodsmultilevel modelpiecewise modelingMapsLatent Transition AnalysisMultilevel ModelLongitudinal MethodsLatent Class Growth ModelPiecewise Modeling
Leggi il testo integrale originale

Testo estratto dalla pubblicazione: sono esclusi immagini, media, supplementi e parti soggette a diritti distinti.

Piecewise modeling for longitudinal psychological research: a tutorial using R

Abstract

Longitudinal psychological research often centers on key developmental transitions, where patterns of change may differ across stages. Piecewise modeling is well suited to capturing these stage-specific changes. This tutorial introduces three piecewise methods in longitudinal psychological research: piecewise multilevel modeling (MLM), piecewise latent class growth modeling (LCGM), and latent transition analysis (LTA). Drawing on a six-wave longitudinal study of national identity development, we show how each method can be implemented in R and highlight the types of research questions each is designed to address, from estimating average developmental trajectories to identifying heterogeneous trajectory patterns and examining transitions between latent developmental states.

Keywords: latent class growth model, latent transition analysis, longitudinal methods, MAPS, multilevel model, piecewise modeling

1.Introduction

Psychological development frequently exhibits non-linear shifts surrounding major transition points, such as educational transitions, treatment phases, or life events (Baltes, 1987; Benner, 2011; Forman-Hoffman et al., 2024). Such stage-dependent shifts are evident across domains, including self-esteem, academic adjustment, identity formation, and clinical outcomes (Eccles et al., 1993; Howard et al., 1993; Huang et al., 2022; Stulz et al., 2007). Piecewise modeling captures this complexity by specifying separate growth parameters for distinct stages defined by theoretical or empirical turning points (Cudeck and Klebe, 2002; Kohli et al., 2018). This tutorial introduces three piecewise modeling approaches, each addressing a distinct research question.

A key consideration in piecewise modeling is whether to specify the changepoint a priori or estimate it from the data. A changepoint may be treated as known when theory or study design can specify its location in advance, such as the timing of an educational transition or the onset of an intervention. In this setting, the primary research question concerns whether and how the rate of change differs across predefined phases. In contrast, when a transition is hypothesized, but its location cannot be specified a priori, the changepoint can be treated as an unknown parameter and estimated from the data (Kohli and Harring, 2013; Ning and Luo, 2017). This distinction is important because misspecifying a fixed changepoint can bias estimates of growth parameters, while conventional model-fit indices may not reliably detect such misspecification (Ning and Luo, 2017). When the substantive research question concerns detecting whether and where a change occurs, data-driven changepoint detection provides an appropriate alternative (D'Angelo, 2025).

Growth modeling provides a key framework for describing longitudinal change in psychology (Jebb and Tay, 2017). Multilevel modeling (MLM; Singer and Willett, 2003) and latent growth curve modeling (LGCM; Preacher et al., 2008, pp. 185–198) are two primary approaches for estimating population-average trajectories while accounting for individual variation. Specifically, individual differences follow continuous distributions around population means, operationalized as random effects in MLM and latent growth factors in LGCM, respectively. Although MLM and LGCM can yield equivalent results for many conventional growth models, they differ in model parameterization and estimation (Curran, 2003). These differences matter more for intrinsically nonlinear models, such as piecewise models with unknown changepoints, which may require additional reparameterization within the LGCM framework. When theoretical or empirical transitions are anticipated, these frameworks extend to piecewise growth models to capture stage-specific rates of change. Piecewise MLM, for instance, parameterizes distinct average growth rates across predefined developmental phases.

However, not all longitudinal research focuses on population-average trajectories. When a population is expected to comprise multiple latent subgroups rather than a single homogeneous population, person-centered approaches offer a useful alternative. Two widely used methods are piecewise latent class growth modeling (piecewise LCGM; Nagin, 2005) and latent transition analysis (LTA; Collins and Lanza, 2009). Piecewise LCGM identifies latent subgroups that follow qualitatively distinct developmental trajectories. In contrast to piecewise MLM, which models continuous individual differences around a single average trajectory, piecewise LCGM assumes that individuals belong to a finite number of discrete trajectory classes, each with its own stage-specific pattern of change.

Latent transition analysis similarly adopts a person-centered perspective, but it defines a discrete latent status based on cross-sectional response patterns at each measurement occasion, and subsequently estimates transition probabilities between these latent statuses to describe how individuals transition across developmental stages.

While piecewise MLM, piecewise LCGM, and LTA are each well-established, methodological literature often treats them in isolation, focusing primarily on statistical assumptions, model specification, and estimation procedures. Consequently, few studies explicitly compare their conceptual distinctions or the research questions each addresses, offering applied researchers limited guidance when aligning model selection with substantive hypotheses.

Although piecewise LCGM and LTA are widely implemented in proprietary software like Mplus, tutorials demonstrating equivalent workflows in open-source environments remain scarce. The present tutorial focuses specifically on piecewise models with changepoints prespecified based on theory or study design, rather than on the estimation of unknown changepoints from the data. To address this gap, this tutorial demonstrates how to implement piecewise MLM, piecewise LCGM, and LTA in R using longitudinal data centered on a meaningful developmental transition. Beyond technical implementation, we clarify the research questions each method addresses, delineate contexts where each approach is most appropriate, and show how researchers can transition across these frameworks as their research questions evolve. Complete R code and an empirical example are provided to facilitate transparent and reproducible research.

2.Example datasets

This study used data from the Multicultural Adolescents Panel Study (MAPS), a nationally representative longitudinal survey conducted annually by the Korean National Youth Policy Institute from 2019 to 2025. The original sample included 2,271 adolescents. To illustrate the proposed modeling approaches, we analyzed six waves of national identity data spanning participants’ middle school (2019–2021) and high school (2022–2024) years. National identity was assessed using four items rated on a 4-point Likert scale: “When someone praises Korea, I feel as if I am being praised,” “I am interested in what people from other countries think about Korea,” “Korea’s success is my success,” and “When someone speaks negatively about Korea, I feel offended as if they were criticizing me.” The transition from middle school to high school was specified as a known changepoint because the six measurement occasions naturally comprised two predefined educational stages: three waves during middle school and three waves during high school. Thus, the study design and the substantive educational transition defined the changepoint rather than estimating it from the national identity data. The descriptive trajectory shown in Figure 1 further supported the relevance of this specification, with national identity generally increasing during middle school and declining following the transition to high school.

3.Piecewise multilevel growth model

Although MLM and LGCM differ in their statistical formulations, they generally produce highly comparable results when applied to longitudinal data (Jackson, 2010). Therefore, this study uses a piecewise extended model of the MLM as an example to estimate the rate of change at different development stages.

When two developmental stages are specified, within-person level can be represented as

(1)Yit=β0i+β1iTime1,it+β2iTime2,it+eit,where Yit is the observed outcome for individual i at time t, β0i is the individual’s initial status (intercept), β1i is the slope of change in the first stage [i.e., before the changepoint (middle-school stage)], β2i is the slope of change in the two stage[i.e., after the changepoint (high-school stage)], and eit is the error term, assumed to eit~N(0,σ2).

At the between-person level, individual growth parameters are modeled as

(2)β0i=γ00+u0i,β1i=γ10+u1i,β2i=γ20+u2i,where γ00, γ10, γ20 denote the average intercept, the average growth rate during the first developmental stage (wave 0–2), and the average growth rate during the second developmental stage (wave 3–5), respectively. The random effects u0i, u1i, and u2i represent individual deviations from the average intercept and two growth rates and are assumed to follow a multivariate normal distribution with a mean vector of zero and the following variance–covariance matrix:

(3)(u0iu1iu2i)∼MVN((000),(τ00τ01τ02τ10τ11τ12τ20τ21τ22)).The piecewise MLM described above includes both random intercepts and random slopes. If individual variation is assumed to exist only in initial status rather than in rates of change, the model simplifies to a random-intercept model by omitting the random slope terms (u1i, u2i). In this constrained specification, u0i~N(0,τ00), and the stage-specific slopes are estimated as fixed effects (i.e., β1i=γ10, β2i=γ20). Alternatively, if development is conceptualized as a single continuous trajectory without distinct developmental transitions, researchers can replace the piecewise specification with a standard linear growth model that fits a single slope across all measurement wave (wave 0–5).

3.1.R demonstration

Piecewise MLM were estimated using the lme4 (Bates et al., 2015) and lmerTest (Kuznetsova et al., 2017) packages, while the corresponding piecewise LGCM was estimated using the lavaan package (Rosseel, 2012). The R code and data used for these analyses are publicly available on OSF (https://osf.io/r597h/).

Step 1. Piecewise time coding

> library(dplyr)
> data_piecewise <− data % > % # long format data
mutate(phase = ifelse(time <= 2, “Phase 1,” “Phase 2”),
time1 = pmin(time, 2), time2 = pmax(0, time - 2))
> head(data_piecewise)
# A tibble: 6 × 7 #time 1 = middle-school stage
PID wave national time phase time1 time2 #time 2 = high-
school stage
1 1832 1 16 0 Phase 1 (0–2) 0 0
2 1832 2  9 1 Phase 1 (0–2) 1 0
3 1832 3 10 2 Phase 1 (0–2) 2 0
4 1832 4 12 3 Phase 2 (2–5) 2 1
5 1832 5 12 4 Phase 2 (2–5) 2 2
6 1832 6 11 5 Phase 2 (2–5) 2 3The dataset (data) must be arranged in long format to fit MLM in R. To capture developmental changes across educational stages, time was modeled using two piecewise variables. The middle school period (Time 1) was coded as 0, 1, 2, 2, 2, and 2 across the six waves, whereas the high school period (Time 2) was coded as 0, 0, 0, 1, 2, and 3. The corresponding coefficients represented growth rates during each stage.

Step 2. Model fitting

To evaluate the importance of the piecewise specification, four models were compared. Model 1 included only a random intercept, whereas Model 2 additionally estimated random intercept and random slopes for the middle school and high school phases. Models 3 and 4 ignored the developmental transition by treating the entire study period as a single growth process. Model 3 included only a random intercept, whereas Model 4 also estimated a random slope.

> library(lme4)
> library(lmerTest)
> Model 1 < − lmer(national ~ time1 + time2 + (1| PID),
data = data_piecewise)
> Model 2 < − lmer(national~ time1 + time2 + (1 + time1 +
 time2| PID), data = data_piecewise)
> Model 3 < − lmer(national~ time+ (1|PID),
data = data_piecewise)
> Model 4 < − lmer(national ~ time +(1 + time|PID),
data = data_piecewise)Step 3. Model comparison

All comparisons were conducted using the anova() function in R (Bates et al., 2015).

> anova(Model1, Model2, Model3, Model4)
Data: data_long
Models:
Model3: national ~ time + (1 | PID)
Model1: national ~ time1 + time2 + (1 | PID)
Model4: national ~ time + (1 + time | PID)
Model2: national ~ time1 + time2 + (1 + time1 + time2 | PID)
npar AIC BIC logLik −2*log(L) Chisq Df Pr(>Chisq)
Model3 4 55607 55637–27800 55599
Model1 5 55536 55573–27763 55526 73.653 1 < 2.2e-16 ***
Model4 6 55264 55308–27626 55252 274.110 1 < 2.2e-16 ***
Model2 10 55078 55152–27529 55058 193.625 4 < 2.2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘’ 1

3.2.Results and interpretation

Model 2 (piecewise random intercept and random slopes model) yielded the best fit based on Akaike information criterion (AIC; Akaike, 1974) and Bayesian information criterion (BIC; Schwarz, 1978)1 indices, supporting distinct developmental trajectories and individual variation across both educational stages.

Results from Model 2 (Table 1) indicated that the average initial level of national identity was 10.47 (SE = 0.06, p < 0.001). National identity increased significantly during middle school (γ10 = 0.31, SE = 0.04, p < 0.001), but declined during high school (γ20 = − 0.10, SE = 0.02, p < 0.001). Overall, these findings suggest that national identity follows a non-linear developmental trajectory, characterized by growth during middle school and a gradual decline during high school.

Table 1MLM estimation results (Model 2).

Parameter Estimate SE t p

Fixed effect

Intercept 10.465 0.058 181.333 <0.001

Time 1 0.307 0.035 8.783 <0.001

Time 2 −0.103 0.023 −4.589 <0.001

Random effect

Intercept (τ00) 4.286

Time 1 (τ11) 0.925

Time 2 (τ22) 0.221

Corr (u0j,u1j) −0.54

Corr (u0j,u2j) −0.34

Corr (u1j,u2j) 0.09

Residual (σ) 3.898

Corr = correlation between two random effects; SE = standard error.

The variance of random effects was found for the intercept (τ00 = 4.29), the middle school slope (τ11 = 0.93), and the high school slope (τ22= 0.22), indicating substantial individual heterogeneity in initial status and stage-specific rates of change. Higher initial national identity was associated with slower increases in middle school (Corr (u0j,u1j)= −0.54) and attenuated declines in high school (Corr (u0j,u2j) = − 0.34). The correlation between the two slope factors was weak (Corr (u1j,u2j) = 0.09), suggesting that change during middle school was largely independent of change during high school.

4.Piecewise latent class growth model

An important assumption of MLM is that there is a population trend, and that there are individual differences regarding this trend. This assumption may be inappropriate when a population contains qualitatively distinct developmental patterns. For example, if one subgroup shows increasing development while another shows decreasing development, the average trajectory may suggest little or no overall change even though both subgroups exhibit substantial change in opposite directions. Developmental theory likewise suggests that individual differences may reflect qualitatively distinct pathways rather than merely continuous variation in growth rates (Bergman and Magnusson, 1997).

This distinction is often described in terms of variable-centered and person-centered approaches (Muthén and Muthén, 2000). Variable-centered approaches, including regression, multilevel models, and structural equation models, focus on relations among variables and assume that a single population model adequately characterizes all individuals. Person-centered approaches, such as latent profile analysis (LPA) and LCGM, instead seek to identify relatively homogeneous subgroups whose members exhibit similar response patterns, resulting in greater within-class than between-class similarity.

Within this person-centered framework, LCGM extends conventional growth modeling by representing population heterogeneity as a set of discrete latent trajectory classes rather than continuously distributed random effects (Andruff et al., 2009; Jung and Wickrama, 2008). Rather than requiring researchers to specify the number or shape of developmental trajectories in advance, LCGM estimates and compares models with different numbers of latent classes using multiple fit indices to identify the solution that best captures the observed data (Andruff et al., 2009; Nagin, 1999). This feature makes LCGM particularly well suited for exploratory research seeking to identify unobserved developmental heterogeneity within a population (van der Nest et al., 2020).

To understand LCGM, it is first necessary to review the basic framework of LPA. In LPA, observed variables are assumed to follow a normal distribution within each latent class. Specifically, the observed score of individuals (i) on variable (j) in latent class (k) can be expressed as

yij=μj(k)+ϵit,where μj(k) is the class-specific mean of variable (j) for latent class (k), and ϵit is an individual-specific deviation from that class mean. In LPA, the class-specific mean μj(k) is freely estimated for each observed variable, allowing latent classes to differ in their response profiles across variables. The residual term is assumed to be normally distributed with mean zero and class-specific variance:

ϵij~N(0,σj2(k)).In piecewise LCGM, the expected value of the outcome variable is modeled as a time-dependent function of time (t). Assuming a linear growth trajectory, the class-specific mean for latent class (k) is expressed as

μt(k)=η0(k)+η1(k)time1,it+η2(k)time2,it,where η0(k) is the class-specific intercept, and η1(k) is the class-specific growth rate during the first developmental stage (wave 0–2), and η2(k) is the class-specific growth rate during the second developmental stage (wave 3–5). Incorporating these piecewise growth parameters into the latent profile framework yields the piecewise LCGM formulation:

yit=η0(k)+η1(k)timeit+η2(k)time2,it+ϵit,where yit is the observed outcome for individual (i) at time (t), and ϵit is a residual term assumed to follow a normal distribution, ϵit~N(0,σt2(k)).

Thus, individuals within the same class share a common developmental trajectory defined by class-specific intercepts and stage-specific slopes. Different classes can therefore exhibit distinct growth patterns across stages, while individual observations vary around these class trajectories due to residual error.

4.1.R demonstration

MLM and LCGM can be applied to the same longitudinal dataset because they are designed to model individual developmental trajectories over time. However, they differ fundamentally in their assumptions about between-person heterogeneity.

Step 1. Fit the baseline one-class model

To evaluate whether trajectories differed qualitatively across individuals, we first specified a baseline one-class model using the same longitudinal dataset as in the piecewise MLM. This baseline model assumes a single homogeneous population, serving as a benchmark for multi-class comparisons.

The model was estimated using the hlme() function from the lcmm package (Proust-Lima et al., 2017). Fixed effects were specified for the two piecewise slopes (time1 and time2), and a random intercept was included to account for individual differences in initial status.

> lcgm1 < − hlme(fixed = national ~ time1 + time2,
> random = ~ 1, # random intercept
> subject = ‘PID’,
> ng = 1,
> data = data_ piecewise)The fixed-effects component was specified as national ~ time1 + time2, where time1 and time2 estimate the average developmental rates before and after the theoretical transition point, respectively. To establish a baseline developmental trajectory, the one-class model included only a random intercept (random = ~1), allowing individual differences in initial levels while assuming a common developmental pattern. Repeated observations were nested within participants (subject = “PID”), and the number of latent classes was fixed at one (ng = 1). This model served as the baseline for comparing models with additional latent classes and provided starting values for subsequent analyses.

Step 2. Fit models with increasing numbers of latent classes.

Following the single-class baseline, models with two through four latent classes were fitted to determine whether multiple distinct trajectories provided a superior fit to the population data. Increasing the number of classes allowed each latent subgroup to estimate its own stage-specific growth parameters.

> lcgm2 < − gridsearch(
> hlme(fixed = national_iden ~ time1 + time2,
> mixture = ~ time1 + time2,
> random = ~ 1,
> subject = ‘PID’,
> ng = 2, ## class3, class 4.> data = data_piecewise),
> rep = 30, maxiter = 10, minit = lcgm1)The ng argument specifies the number of latent classes to be estimated. To identify the optimal number of classes, models with increasing numbers of latent classes (e.g., 2, 3, and 4) were estimated and compared. Each model represents a competing hypothesis regarding the underlying heterogeneity of developmental trajectories. The mixture = ~ time1 + time2 specification allows the fixed effects of time1 and time2 to vary across latent classes, enabling each class to have distinct developmental slopes during the middle school and high school periods rather than assuming a common developmental trajectory for all individuals. To minimize convergence to local maxima, all models were estimated using the gridsearch() procedure with 30 random sets of starting values and 10 preliminary iterations, and the best-performing solution was retained for final estimation.

Step 3. Model comparison

To determine the optimal model, piecewise latent class growth models with one to four classes were evaluated against multiple complementary criteria, including information criteria (e.g., BIC), classification quality, class proportions, and theoretical alignment. Although the four-class solution yielded the lowest BIC, it produced a small class representing only 3.2% of the sample. In contrast, the three-class solution achieved a superior trade-off between statistical fit and substantive interpretability and was thus selected as the final model.

> summarytable(lcgm1, lcgm2, lcgm3, lcgm4)
G loglik npm BIC %class1%class2%class3%class4
lcgm1 1 –27762.90 555564.45100.0000
lcgm2 2 –27591.77 955253.09 16.424483 83.575517
lcgm3 3 –27487.63 1355075.73 84.456187 7.089388 8.454425
lcgm4 4 –27438.84 1755009.06 9.467195 3.170410 7.881990
79.48041

4.2.Results and interpretation

As shown in Figure 2 and Table 2, three distinct trajectories of national identity were identified. Class 1 accounted for 8.45% of the sample and displayed a marked increase in national identity. Beginning with the lowest initial level (η03= 6.84, p < 0.001), adolescents in this class showed substantial gains during middle school (η13 = 2.43, p < 0.001). Growth then plateaued after the transition to high school, with no further significant change detected.

Table 2LCGM estimation results (class 3).

Parameter Class 1, Coef(p) Class 2, Coef(p) Class 3, Coef(p)

Intercept (η0) 6.835 (<0.001) 10.844 (<0.001) 11.806 (<0.001)

Time 1 (η1) 2.433 (<0.001) 0.147(0.004) −0.918 (<0.001)

Time 2 (η2) 0.079 (0.353) −0.000 (0.980) −1.062 (<0.001)

Mixed proportion (%) 8.454 84.456 7.089

Class 2 was the largest group, representing 84.46% of the sample. National identity remained relatively stable over time. Although scores increased modestly during middle school (η12= 0.15, p = 0.004), no significant change was observed after students entered high school, resulting in an overall stable pattern across the study period.

Class 3, comprising 7.09% of the sample, was characterized by a continuous decline. Adolescents in this class began with the highest level of national identity (η01 = 11.81, p < 0.001), followed by significant decreases during both middle school (η11= − 0.92, p < 0.001) and high school (η21= − 1.06, p < 0.001). The rate of decline increased slightly after the transition to high school.

5.Latent transition analysis

Latent transition analysis adopts a person-centered perspective by identifying cross-sectional latent states at each measurement wave and estimating the probabilities of transitioning between these states over time. Unlike piecewise trajectory models, LTA does not directly model a continuous developmental trajectory or estimate stage-specific rates of change. Rather, the two approaches address distinct but complementary aspects of longitudinal development: piecewise trajectory models characterize patterns of continuous change across developmental stages, whereas LTA characterizes changes in individuals’ latent-state membership across discrete measurement occasions. Therefore, establishing evidence for a piecewise developmental trajectory is not a prerequisite for conducting LTA. Researchers may conduct LTA independently when their research questions focus specifically on identifying latent states and examining transitions in state membership over time.

Latent transition analysis consists of a measurement model and a structural model. The measurement model is equivalent to an LPA at each measurement wave and identifies latent states based on individuals’ response patterns. At the baseline measurement wave, the observed indicator vector y1i is assumed to arise from a finite mixture of K latent classes:

P(y1i)=∑k=1Kp(c1i=k)p(y1i∣c1i=k),Where P(y1i) is the marginal distribution of the observed indicator vector for individual i at the baseline measurement wave; p(c1i=k) is the probability of membership in latent class k, and p(y1i∣c1i=k) represents the class-specific conditional distribution of the observed indicators. This formulation assumes that population heterogeneity can be captured by a finite number of unobserved latent classes, each characterized by a distinct response profile. Under the local independence assumption, associations among the observed indicators are assumed to be fully explained by latent-state membership.

To examine whether transition processes differed across developmental periods, two piecewise time variables were included as predictors in the multinomial logistic transition model. The first variable (time 1) captured linear change during waves 0–2 and remained constant thereafter, whereas the second variable (time2) captured linear change during waves 3–5. For a latent transition model consisted of three latent states (K = 3), the transition probabilities were modeled using multinomial logistic regression. With the third latent state specified as the reference category, the transition model was formulated as follows:

P(Cit=s∣Ci,t−1=r)=exp(αr,s+β1,r,stime1t+β2,r,stime2t)∑m=13exp(αr,m+β1,r,mtime1t+β2,r,mtime2t),where P(Ci,t=s∣Ci,t−1=r) is the probability of transitioning from latent state (r) at time (t-1)to latent state (s) at time (t); St−1 and St are the latent states at the previous and current time points, respectively; αr,s is the intercept for the transition from state (r) to state (s); β1,r,s and β2,r,s represent the effects of the two piecewise time variables (Time 1 and Time 2) on the transition probability; ∑m=13exp(αr,m+β1,r,mtime1t+β2,r,mtime2t) is the normalization term, which sums the exponentiated linear predictors across all three possible destination states to ensure that the transition probabilities from a given origin state sum to one. The coefficients associated with the reference state were fixed to zero for model identification.

This specification extends the standard time-homogeneous transition model by incorporating two piecewise time predictors, allowing transition probabilities to vary across developmental stages. As a result, the model can evaluate whether the likelihood of moving between latent states differs systematically across the middle and high school developmental periods.

5.1.R demonstration

Unlike MLM and LCGM, which model repeated outcome scores, LTA estimates latent states using observed indicators (i.e., item-level responses). Therefore, the data should be organized in long format, with each row representing one individual at one measurement wave, as shown below.

head(lta_piecewise)
PID wave national_01 national _02 national _03 national
_04 wave1 wave2
1 1832 1 4 4 4 4 0 0
2 1832 2 2 3 2 2 1 0
3 1832 3 2 3 3 2 2 0
4 1832 4 3 3 3 3 2 1
5 1832 5 3 3 3 3 2 2
6 1832 6 3 3 2 3 2 3Step 1. Determine the number of latent states using LPA

Following Ryoo et al. (2018), fit separate latent class/profile models at each measurement occasion to identify a plausible range of candidate status solutions rather than determine a single number of statuses for the subsequent LTA. These preliminary solutions can be evaluated using statistical fit indices (e.g., AIC and BIC), classification quality, and substantive interpretability. The resulting candidate solutions can then be compared within the longitudinal LTA framework, with the final number of latent statuses selected based on both model-fit information and conceptual interpretability (Lanza et al., 2010).

Before conducting the LTA, LPAs were performed separately at each of the six-measurement wave to identify an appropriate latent profile structure. The LPAs were conducted using the tidyLPA package (Rosenberg et al., 2018).

> library(tidyLPA)
> lpa_wave1 < − lta_piecewise_wave 1% > % estimate
profiles(n_profiles = 1:4, models = 1)
> lpa_wave2 < − lta_piecewise_wave2% > % estimate
profiles(n_profiles = 1:4, models = 1)
……
>lpa_wave6 < − lta_piecewise_wave6% > % estimate
profiles(n_profiles = 1:4, models = 1)After conducting LPAs separately at each of the six-measurement wave, the optimal number of latent profiles was identified. These profiles are conceptually different from the latent classes identified by piecewise LCGM. Piecewise LCGM groups individuals according to differences in their developmental trajectories over time, whereas LPA groups individuals according to similarities in their responses to the observed indicators at a given measurement wave.

Step 2. Fit models

After identifying candidate profile solutions based on the preliminary LPA results, LTA models with different numbers of latent states were fitted and compared using AIC and BIC. The final state solution was selected based on model fit and substantive interpretability.

> library(depmixS4)
> ntimes <− table(df_lta$PID) # Define participant-specific
sequence lengths
> forms <− lapply(items, function(x) as.formula(paste(x, “~
1”)))# form define
> lta_model_3states < − depmix(
response = forms,
data = lta_piecewise,
ntimes = as.numeric(ntimes),
nstates = 3, ## state 2–4
transition = ~ wave1 + wave2,
family = rep(list(multinomial(“identity”)), 4)The LTA was estimated using the depmixS4 package (Visser and Speekenbrink, 2010). The response argument specifies forms, a list of intercept-only response formulas (~ 1) for the four observed indicators used to define the latent states in the LTA model. Setting nstates = 3 fitted a three-state model, in which individuals were assigned to one of three latent developmental states at each measurement wave. Transition probabilities were modeled as a function of the two piecewise time variables (wave1 + wave2), allowing transition patterns to differ between the two developmental stages rather than remain constant across the study period. The family argument, rep(list(multinomial(“identity”)), 4), specified multinomial distributions for all four observed indicators, treating them as categorical variables.

5.2.Results and interpretation

As shown in Figure 3, the LPA results supported the three-profile solution across all six waves. Although the four-state LTA showed slightly better fit than the three-state solution (Table 3), the additional state primarily reflected a further differentiation of the lower level of national identity rather than a qualitatively distinct pattern. In contrast, the three-state solution provided a clearer and more parsimonious representation of low, moderate, and high levels of national identity. Considering statistical fit, substantive interpretability, and parsimony together, the three-state model was retained. As presented in Table 4, the three states were characterized by distinct levels of national identity across the four indicators. State 1 (36.9%) exhibited the highest indicator scores and was labeled low identity, State 2 (47.1%) exhibited intermediate scores and was labeled moderate identity, and State 3 (16.1%) exhibited the lowest scores and was labeled high identity.

Table 3Model fit indices across LTA.

Model LogLik AIC BIC

Two-state model −56575.80 113213.59 113446.70

Three-state model −51638.78 103389.56 103810.67

Four-state model −49148.48 98470.97 99125.18

Table 4Three latent states in the LTA.

State Item 1 Item 2 Item 3 Item 4 Group

State 1(36.9%) 1.913 1.880 1.943 1.883 Low

State 2(47.1%) 2.959 2.841 2.879 2.825 Moderate

State 3(16.1%) 3.788 3.554 3.747 3.638 High

Figure 4 illustrates the estimated transition probabilities for the middle school and high school periods. The moderate identity state exhibited the greatest stability in both periods, with the probability of remaining in this state increasing from 0.72 in middle school to 0.78 in high school. Stability also increased for the high identity state (0.51 to 0.53) and the low identity state (0.58 to 0.67), indicating greater persistence of all three identity states during high school.

Transitions aligned predominantly toward the moderate state rather than between extreme states. High-identity adolescents increasingly transitioned to the moderate state across periods (0.39 to 0.42), while low-to-moderate transitions remained consistently frequent (0.38 and 0.31). Direct transitions between high and low identity states were negligible. Overall, the results indicate that adolescents’ national identity became increasingly centered on the moderate identity state. Compared with the high and low identity states, the moderate identity state exhibited the greatest Stability and accounted for the largest share of transitions across both educational stages.

6.Discussion

This tutorial demonstrates piecewise MLM, piecewise LCGM, and LTA as complementary frameworks for modeling stage-dependent developmental processes. Using national identity as an empirical illustration, we show how these methods address distinct but complementary aspects of longitudinal change: average stage-specific growth, trajectory heterogeneity, and transition dynamics across latent states. These methods move beyond overall mean trajectories to capture discrete sub-groups and their evolving state transitions over time.

6.1.Application issues

The models described in this tutorial are most suitable for longitudinal studies that examine theoretically meaningful transition points, include repeated assessments spanning at least two developmental stages, and address questions about average developmental change, developmental heterogeneity, or transitions between developmental states. In these settings, a single growth model is often insufficient to represent stage-specific developmental processes, and choosing an analytical method is an important consideration.

In practice, researchers should also consider sample size requirements, which increase with model complexity. Simulation studies suggest that LCGM generally requires larger samples as the number of latent classes increases, class separation decreases, and missing data become more prevalent, with recommended sample sizes ranging from approximately 200 for two-class solutions to 1,000 for five-class solutions (Kim, 2012; Tein et al., 2013). For LTA, sample size requirements also depend on the number of measurement wave, transition probabilities, class separation, and class sizes, with previous studies generally recommending sample sizes of 300–1,000 and at least 500 participants for most applications (Finch and Bronk, 2011; Nylund-Gibson and Choi, 2018).

Although MLM, LCGM, and LTA are based on different latent variable assumptions, they provide complementary perspectives on the same developmental process. MLM characterizes developmental change as continuous variation across individuals. LCGM captures developmental heterogeneity by identifying distinct trajectory classes. LTA focuses on changes in latent developmental states over time. Considered together, these models represent continuous latent variables, categorical latent classes, and dynamic latent states, respectively. This allows researchers to study development issues from different perspectives.

6.2.Method extension

Compared with dedicated software, the open-source R environment offers considerable flexibility and integration for longitudinal analyses. Researchers can address missing data using multiple imputation (e.g., Multiple Imputation by Chained Equations) and incorporate time-varying or analysis-specific covariates. Beyond the packages demonstrated in this tutorial, several R packages offer alternative implementations of longitudinal modeling frameworks, each with different strengths and limitations. Table 5 summarizes representative R packages for MLM, LGCM, LCGM, and LTA and highlights their main advantages and limitations.

Table 5R Packages for different longitudinal modeling frameworks: advantages and limitations.

Research focus Method R package Advantages Limitations

Continuous trajectory Piecewise MLM lme4 (Bates et al., 2015) Flexible specification of fixed and random effects; straightforward implementation of piecewise trajectories Limited specification of within-person residual covariance structures; does not provide fit indices

nlme (Pinheiro et al., 2025) Allows flexible residual covariance structures and nonlinear mixed-effects models Model specification can be more complex than in lme4

Piecewise LGCM lavaan package (Rosseel, 2012) Provides SEM-based global fit indices; allows growth parameters to be represented as latent factors Complex piecewise models may require additional parameterization, particularly when the changepoint is unknown

Trajectory heterogeneity Piecewise LCGM lcmm package (Proust-Lima et al., 2017) Designed for latent-class mixed models; accommodates class-specific longitudinal trajectories Requires careful selection of the number of classes and initial values

flexmix for LCGM (Grün and Leisch, 2008) Provides a flexible framework for finite-mixture regression models Not specifically designed for longitudinal growth modeling; complex growth structures require additional specification

Status transition LTA mixtools for LTA (Benaglia et al., 2010) Provides flexible tools for finite-mixture modeling and latent-class estimation Does not directly implement conventional LTA; transition structures require additional programming

depmixS4 package (Visser and Speekenbrink, 2010) Supports longitudinal latent-state models and estimation of transition probabilities Primarily based on the hidden Markov modeling framework

For ordinal or categorical longitudinal outcomes, researchers may consider alternative modeling approaches depending on their research questions. Researchers can implement generalized linear mixed-effects models using R packages such as lme4 and glmmTMB. In contrast, researchers can estimate latent class growth or mixed models with lcmm when the focus is on heterogeneous developmental trajectories. Alternatively, LTA, a longitudinal extension that links latent class analyses (LCAs) across multiple time points, can examine transitions between latent states (Nylund-Gibson et al., 2023). Although R packages such as OpenMx and mixtools can implement LTA, they have limitations for more complex specifications. Mplus provides a more flexible framework for specifying and estimating such models (Nylund-Gibson et al., 2023).

Piecewise modeling is not limited to two linear segments separated by a single changepoint and can represent more complex developmental processes. For example, different developmental phases may follow different functional forms, including nonlinear trajectories, and models may incorporate multiple changepoints when more than two phases of change are expected (Harring et al., 2021). Piecewise models can also accommodate more complex longitudinal data structures. For example, piecewise crossed random-effects models can account for dynamic group membership over time while modeling nonlinear growth (Rohloff et al., 2024). Extensions to multivariate settings include bivariate piecewise models, which jointly model two segmented longitudinal processes and their associations over time (Peralta et al., 2022). Other extensions include piecewise growth models that separate state and trait components of change (Heo et al., 2026) and models for examining mediation processes across developmental stages (Liu and Perera, 2023). Mixture mediation models provide another extension by accounting for population heterogeneity in longitudinal mediation processes (Zhang et al., 2026). Together, these extensions illustrate the flexibility of piecewise modeling for addressing nonlinear change, complex data structures, and relationships among multiple developmental processes.

Funding Statement

The author(s) declared that financial support was not received for this work and/or its publication.

Edited by: Fernando Marmolejo-Ramos, Flinders University, Australia

Reviewed by: Ziwei Zhang, Yale University, United States

José Roberto Silva Dos Santos, Federal University of Ceara, Brazil

1Lower values of AIC and BIC indicate a better trade-off between model fit and parsimony.

Data availability statement

Data collected from the Multicultural Adolescents Panel Study (MAPS) by the National Youth Policy Institute were used in this study. Data are available at the following: https://www.nypi.re.kr/archive/mps. Further inquiries can be directed to the corresponding author/s.

Author contributions

SH: Writing – original draft. WL: Writing – review & editing.

Conflict of interest

The author(s) declared that this work was conducted in the absence of any commercial or financial relationships that could be construed as a potential conflict of interest.

Generative AI statement

The author(s) declared that Generative AI was used in the creation of this manuscript. During the preparation of this work, the authors used GPT-5.5 for language editing and translation. After using this tool, the authors carefully reviewed and revised the manuscript as needed and take full responsibility for the content of this publication.

Any alternative text (alt text) provided alongside figures in this article has been generated by Frontiers with the support of artificial intelligence and reasonable efforts have been made to ensure accuracy, including review by the authors wherever possible. If you identify any issues, please contact us.

Publisher’s note

All claims expressed in this article are solely those of the authors and do not necessarily represent those of their affiliated organizations, or those of the publisher, the editors and the reviewers. Any product that may be evaluated in this article, or claim that may be made by its manufacturer, is not guaranteed or endorsed by the publisher.

References

Akaike H. (1974). A new look at the statistical model identification. IEEE Trans. Autom. Control
19, 716–723. doi: 10.1109/tac.1974.1100705

Andruff H., Carraro N., Thompson A., Gaudreau P., Louvet B. (2009). Latent class growth modelling: a tutorial. Tutor. Quant. Methods Psychol.
5, 11–24. doi: 10.20982/tqmp.05.1.p011

Baltes P. B. (1987). Theoretical propositions of life-span developmental psychology: on the dynamics between growth and decline. Dev. Psychol.
23, 611–626. doi: 10.1037/0012-1649.23.5.611

Bates D., Mächler M., Bolker B., Walker S. (2015). Fitting linear mixed-effects models using lme4. J. Stat. Softw.
32, 1–48. doi: 10.18637/jss.v067.i01

Benaglia T., Chauveau D., Hunter D. R., Young D. S. (2010). Mixtools: an R package for analyzing mixture models. J. Stat. Softw.
32, 1–29. doi: 10.18637/jss.v032.i06

Benner A. D. (2011). The transition to high school: current knowledge, future directions. Educ. Psychol. Rev.
23, 299–328. doi: 10.1007/s10648-011-9152-0,

Bergman L. R., Magnusson D. (1997). A person-oriented approach in research on developmental psychopathology. Dev. Psychopathol.
9, 291–319. doi: 10.1017/s095457949700206x,

Collins L. M., Lanza S. T. (2009). Latent Class and Latent Transition Analysis: With Applications in the Social, Behavioral, and Health Sciences. Hoboken, NJ: John Wiley & Sons.

Cudeck R., Klebe K. J. (2002). Multiphase mixed-effects models for repeated measures data. Psychol. Methods
7, 41–63. doi: 10.1037/1082-989x.7.1.41,

Curran P. J. (2003). Have multilevel models been structural equation models all along?
Multivariate Behav. Res.
38, 529–569. doi: 10.1207/s15327906mbr3804_5,

D'Angelo N. (2025). Testing for a general changepoint in medical and psychometric studies: changes detection and sample size planning. Stat. Med.
44:e70150. doi: 10.1002/sim.70150,

Eccles J. S., Midgley C., Wigfield A., Buchanan C. M., Reuman D., Flanagan C., et al. (1993). Development during adolescence: the impact of stage-environment fit on young adolescents' experiences in schools and in families. Am. Psychol.
48, 90–101. doi: 10.1037/0003-066x.48.2.90,

Finch W. H., Bronk K. C. (2011). Conducting confirmatory latent class analysis using Mplus. Struct. Equ. Model.
18, 132–151. doi: 10.1080/10705511.2011.532732

Forman-Hoffman V. L., Sihvonen S., Wielgosz J., Kuhn E., Nelson B. W., Peiper N. C., et al. (2024). Therapist-supported digital mental health intervention for depressive symptoms: a randomized clinical trial. J. Affect. Disord.
349, 494–501. doi: 10.1016/j.jad.2024.01.057,

Grün B., Leisch F. (2008). FlexMix version 2: finite mixtures with concomitant variables and varying and constant parameters. J. Stat. Softw.
28, 1–35. doi: 10.18637/jss.v028.i04

Harring J. R., Strazzeri M. M., Blozis S. A. (2021). Piecewise latent growth models: beyond modeling linear-linear processes. Behav. Res. Methods
53, 593–608. doi: 10.3758/s13428-020-01420-5,

Heo I., Liu R., Liu H., Depaoli S., Jia F. (2026). A study of latent state-trait theory framework in piecewise growth models. Appl. Psychol. Meas.
50, 21–32. doi: 10.1177/01466216251360565,

Howard K. I., Lueger R. J., Maling M. S., Martinovich Z. (1993). A phase model of psychotherapy outcome: causal mediation of change. J. Consult. Clin. Psychol.
61, 678–685. doi: 10.1037//0022-006x.61.4.678,

Huang J., Xie X., Pan Y., Li G., Zhang F., Cui N. (2022). Trajectories of self-esteem development for adolescence based on China family panel studies: a piecewise growth mixture model analysis. SAGE Open
12, 1–9. doi: 10.1177/21582440221086611

Jackson D. L. (2010). Reporting results of latent growth modeling and multilevel modeling analyses: some recommendations for rehabilitation psychology. Rehabil. Psychol.
55, 272–285. doi: 10.4135/9781412984737.n4

Jebb A. T., Tay L. (2017). Introduction to time series analysis for organizational research: methods for longitudinal analyses. Organ. Res. Methods
20, 61–94.

Jung T., Wickrama K. A. S. (2008). An introduction to latent class growth analysis and growth mixture modeling. Soc. Personal. Psychol. Compass
2, 302–317. doi: 10.1111/j.1751-9004.2007.00054.x

Kim S. Y. (2012). Sample size requirements in single-and multiphase growth mixture models: a Monte Carlo simulation study. Struct. Equ. Modeling
19, 457–476. doi: 10.1080/10705511.2012.687672

Kohli N., Harring J. R. (2013). Modeling growth in latent variables using a piecewise function. Multivariate Behav Res
48, 370–397. doi: 10.1080/00273171.2013.778191,

Kohli N., Peralta Y., Zopluoglu C., Davison M. L. (2018). A note on estimating single-class piecewise mixed-effects models with unknown change points. Int. J. Behav. Dev.
42, 518–524. doi: 10.1177/0165025418759237

Kuznetsova A., Brockhoff P. B., Christensen R. H. (2017). lmerTest package: tests in linear mixed effects models. J. Stat. Softw.
82, 1–26. doi: 10.18637/jss.v082.i13

Lanza S. T., Patrick M. E., Maggs J. L. (2010). Latent transition analysis: benefits of a latent variable approach to modeling transitions in substance use. J. Drug Issues
40, 93–120. doi: 10.1177/002204261004000106,

Liu J., Perera R. A. (2023). Assessing mediational processes using piecewise linear growth curve models with individual measurement occasions. Behav. Res. Methods
55, 3218–3240. doi: 10.3758/s13428-022-01940-2,

Muthén B., Muthén L. K. (2000). Integrating person-centered and variable-centered analyses: growth mixture modeling with latent trajectory classes. Alcohol. Clin. Exp. Res.
24, 882–891. doi: 10.1111/j.1530-0277.2000.tb02070.x,

Nagin D. S. (1999). Analyzing developmental trajectories: a semiparametric, group-based approach. Psychol. Methods
4, 139–157. doi: 10.1037/1082-989x.4.2.139

Nagin D. S. (2005). Group-based Modeling of Development. Cambridge, MA, USA: Harvard University Press.

Ning L., Luo W. (2017). Specifying turning point in piecewise growth curve models: challenges and solutions. Front. Appl. Math. Stat.
3:19. doi: 10.3389/fams.2017.00019

Nylund-Gibson K., Choi A. Y. (2018). Ten frequently asked questions about latent class analysis. Transl. Issues Psychol. Sci.
4, 440–461. doi: 10.1037/tps0000176

Nylund-Gibson K., Garber A. C., Carter D. B., Chan M., Arch D. A. N., Simon O., et al. (2023). Ten frequently asked questions about latent transition analysis. Psychol. Methods
28, 284–300. doi: 10.1037/met0000486,

Peralta Y., Kohli N., Lock E. F., Davison M. L. (2022). Bayesian modeling of associations in bivariate piecewise linear mixed-effects models. Psychol. Methods.
27, 44–62. doi: 10.1037/met0000358,

Pinheiro J., Bates D., R Core Team . (2025) nlme: Linear and Nonlinear Mixed Effects Models. R package version 3.1-168. doi: 10.32614/CRAN.package.nlme

Preacher K. J., Wichman A. L., MacCallum R. C., Briggs N. E. (2008). Latent Growth Curve Modeling. Thousand Oaks, CA: Sage, pp. 185–198.

Proust-Lima C., Philipps V., Liquet B. (2017). Estimation of extended mixed models using latent classes and latent processes: the R package lcmm. J. Stat. Softw.
78, 1–56. doi: 10.18637/jss.v078.i02

Rohloff C. T., Kohli N., Lock E. F. (2024). Identifiability and estimability of Bayesian linear and nonlinear crossed random effects models. Br. J. Math. Stat. Psychol.
77, 375–394. doi: 10.1111/bmsp.12334,

Rosenberg J. M., Beymer P. N., Anderson D. J., Van Lissa C. J., Schmidt J. A. (2018). TidyLPA: an R package to easily carry out latent profile analysis (LPA) using open-source or commercial software. J. Open Source Softw.
3:978. doi: 10.21105/joss.00978

Rosseel Y. (2012). Lavaan: an R package for structural equation modeling. J. Stat. Softw.
48, 1–36. doi: 10.18637/jss.v048.i02

Ryoo J. H., Wang C., Swearer S. M., Hull M., Shi D. (2018). Longitudinal model building using latent transition analysis: an example using school bullying data. Front. Psychol.
9:675. doi: 10.3389/fpsyg.2018.00675,

Schwarz G. (1978). Estimating the dimension of a model. Ann. Stat.
6, 461–464. doi: 10.1214/aos/1176344136

Singer J. D., Willett J. B. (2003). Applied Longitudinal Data Analysis: Modeling Change and Event Occurrence. New York, NY, USA: Oxford University Press.

Stulz N., Lutz W., Leach C., Lucock M., Barkham M. (2007). Shapes of early change in psychotherapy under routine outpatient conditions. J. Consult. Clin. Psychol.
75, 864–874. doi: 10.1037/0022-006x.75.6.864,

Tein J. Y., Coxe S., Cham H. (2013). Statistical power to detect the correct number of classes in latent profile analysis. Struct. Equ. Model.
20, 640–657. doi: 10.1080/10705511.2013.824781,

Van Der Nest G., Passos V. L., Candel M. J., van Breukelen G. J. (2020). An overview of mixture modelling for latent evolutions in longitudinal data: modelling approaches, fit statistics and software. Adv. Life Course Res.
43:100323. doi: 10.1016/j.alcr.2019.100323

Visser I., Speekenbrink M. (2010). depmixS4: an R package for hidden Markov models. J. Stat. Softw.
36, 1–21. doi: 10.18637/jss.v036.i07

Zhang Z., Kohli N., Lock E. F., Rosser B. S. (2026). Assessing heterogeneous treatment effects using Bayesian (non) linear growth mixture mediation models. J. Educ. Behav. Stat. doi: 10.3102/10769986261422710

Associated Data

Data Availability Statement

Data collected from the Multicultural Adolescents Panel Study (MAPS) by the National Youth Policy Institute were used in this study. Data are available at the following: https://www.nypi.re.kr/archive/mps. Further inquiries can be directed to the corresponding author/s.

Come citare questo studio

He S, Lee W. (2026). Piecewise modeling for longitudinal psychological research: a tutorial using R.. Frontiers in psychology. DOI: 10.3389/fpsyg.2026.1949552

Consulta la pubblicazione originale ↗