1 Introduction

Efficient agricultural production systems play a key role in ensuring a safe and secure food supply for the rapidly growing global population (Godfray et al. 2010). To succeed at this challenge, food production systems will require truly integrated strategies that cut across scientific disciplines and provide multifaceted solutions. Pivotal to such integrated management is an in-depth mechanistic understanding of the functional mechanisms that underlie the relationships between system outcomes. Classical multiple-trait models (MTM) are often used to investigate associations between outcomes (Johnson and Wichern 2007), but cannot evaluate directionality of such associations, thereby impairing their use for inferring potential causal links between outcome variables in a system.

In contrast to classical MTM, structural equation models (SEMs) (Haavelmo 1943) define a special type of MTM that can, under certain conditions, be used to evaluate the directionality of interconnections between outcomes. The so-called direct effects can inform putative causal links that describe functional networks in a system.

A key assumption underlying SEMs is that of homogeneity of the structural coefficients (Gianola and Sorensen 2004) defining functional links in a network, so that such links are considered impervious to environmental conditions or management factors. This assumption seems questionable as functionality in a system may differ between subpopulations and is often subjected to explicit interventions to optimize the necessary trade-offs between competing outcomes. For example, early work by Wu et al. (2007) showed that direct effects describing simultaneous and recursive associations between milk yield and udder health in dairy cows were yield-dependent and changed during a lactation period. Also, a recent study from our group (Chitakasempornkul et al. 2019) observed distinctly different causal networks for two parity-defined subpopulations of female pigs. Therefore, empirical evidence warrants SEM extensions that accommodate structural heterogeneity of functional networks in complex systems.

In an SEM, structural coefficients may be interpreted as substitutes of residual covariances of the classical MTM (Gianola and Sorensen 2004; Wu et al. 2010). Several methodological developments have been proposed to specify sources of variability on MTM (co)variances and functions thereof (Bello et al. 2010; Yang and Tempelman 2012) and have received increasing attention in agricultural applications (Bello et al. 2013; Tempelman et al. 2015; Ou et al. 2016). Specific to simultaneous and recursive models, Wu et al. (2007) proposed a methodological extension that recognized structural coefficients as specific to pre-defined subpopulations. Here, we generalize the approach by Wu et al. (2007) to enable explicit specification of systematic and non-systematic sources of variation on the structural coefficients determining functional links in a network-type SEM. The hierarchical framework of our proposed approach can easily accommodate data architecture and is thus well suited to structured data from designed experiments or observational studies in agriculture.

The objectives of this article are (1) to propose a general approach for explicit specification of heterogeneous SEM structural coefficients as functions of systematic and non-systematic sources of variability, (2) to validate the properties of the proposed extension using a simulation study and (3) to apply the proposed method to an agricultural dataset corresponding to a designed experiment in swine reproduction. In Sect. 2, we briefly introduce SEMs, delineate the proposed methodological extension and describe the hierarchical Bayesian framework we used for implementation. We then describe the simulation study and the data application. Results are presented in Sect. 3 and discussed in Sect. 4. Section 5 provides concluding remarks.

Fig. 1
figure 1

Directed acyclic graph depicting putative functional links between outcome variables \(y_{1}\), \(y_{2}\), \(y_{3}\) and \(y_{4}\). Directed links with arrowheads indicate that \(y_{1}\) has a direct effect on \(y_{2}\) (i.e., \(y_{1} \rightarrow y_{2})\) and on \(y_3\) (i.e., \(y_{1} \rightarrow y_{3})\). Both \(y_{2}\) and \(y_{3\, }\) have a direct effect on \(y_{4}\) (i.e., \(y_{2} \rightarrow y_{4}\) and \(y_{3} \rightarrow y_{4}\), respectively). Each outcome variable is directly affected by a corresponding residual, \( e_{1}\), \(e_{2}\), \(e_{3}\) and \(e_{4}\) and by mutually correlated random effects \(b_{1}\), \(b_{2}\), \(b_{3}\) and \(b_{4}\). Correlations between random effects are indicated by undirected arcs

2 Methods

2.1 Structural Equation Model Specification

Consider the directed acyclic graph in Fig. 1 representing a hypothetical causal network between outcome variables \(y_{j} (j = 1,2, \ldots , J; J = 4)\). Arrows in Fig. 1 indicate that \(y_{1}\) has a direct effect on \(y_{2}\) and on \(y_{3}\), whereas \(y_{2}\) and \(y_{3}\) directly affect \(y_{4}\). Figure 1 also portrays mutually independent residuals \(e_{j}\) and mutually correlated random effects \(b_{j}\), both of which directly affect the corresponding jth outcome variable. For each ith subject (\(i = 1, 2, \ldots , n\)), a hierarchical SEM can be expressed following Gianola and Sorensen (2004) as:

$$\begin{aligned} {{\varvec{y}}}_{i}={\varvec{\Lambda }}{{\varvec{y}}}_{i}+{{\varvec{X}}}_{i}\varvec{\beta } +{{\varvec{Z}}}_{i}{{\varvec{b}}}+{{\varvec{e}}}_{i} \end{aligned}$$
(1)

where \({{\varvec{y}}}_{i}^{T}{\varvec{=}}\left[ y_{i1}\,\quad y_{i2}\,\quad y_{i3}\, \quad y_{i4}\, \right] \) is a vector of \(J = 4\) observed outcomes and \({\varvec{\Lambda }}\) is a \({J \times J}\) square matrix of zeroes, except that elements of the lower triangle are replaced by unknown structural coefficients \(\lambda _{{jj}^{'}}\) \((j>j^{'})\). The structural coefficient \(\lambda _{jj^{'}}\) represents a functional link whereby outcome \(j^{'} \)has a direct effect on outcome j, as indicated by the arrows in Fig. 1; otherwise, \(\lambda _{jj^{'}}\) is set to zero. As such, the matrix \({\varvec{\Lambda }}\) corresponding to Fig. 1 can be expressed as:

$$\begin{aligned} {\varvec{\Lambda }}=\left[ {\begin{array}{*{20}c} 0 &{} \quad 0 &{} \quad 0 &{} \quad 0\\ \lambda _{21} &{} \quad 0 &{} \quad 0 &{} \quad 0\\ \lambda _{31} &{} \quad 0 &{} \quad 0 &{} \quad 0\\ 0 &{} \quad \lambda _{42} &{} \quad \lambda _{43} &{} \quad 0\\ \end{array} } \right] \end{aligned}$$
(2)

For instance, \(\lambda _{21}\) represents the magnitude of the direct effect of \(y_{1}\) on \(y_{2}\) and represents the expected change in \(y_{2}\) per unit increase in \(y_{1}\). Additional parameters in Eq. (1) consist of \(\varvec{\beta }^{T}{\varvec{=}}\left[ \varvec{\beta }_{1}^{T}\, \varvec{\beta }_{2}^{T}\, \varvec{\beta }_{3}^{T}\, \varvec{\beta }_{4}^{T} \right] \), a vector of unknown fixed-effect location parameters associated with factors and covariates (e.g., treatments, demographics) through the corresponding incidence matrix \({{\varvec{X}}}_{i}=\text {diag}[{{\varvec{x}}}_{i1}^{T}\quad {{\varvec{x}}}_{i2}^{T}\, \quad {{\varvec{x}}}_{i3}^{T}\, \quad {{\varvec{x}}}_{i4}^{T}]\) unique to the ith subject. Also, \({{\varvec{b}}}^{T}=\left[ {{\varvec{b}}}_{1}^{T}\,\quad {{\varvec{b}}}_{2}^{T}\, \quad {{\varvec{b}}}_{3}^{T}\, \quad {{\varvec{b}}}_{4}^{T} \right] \) is a vector of unknown random effects associated with blocking factors or other components of the data architecture through the design matrix \({{\varvec{Z}}}_{i}=\text {diag}[{{\varvec{z}}}_{i}^{T}\,\quad {{\varvec{z}}}_{i}^{T}\, \quad {{\varvec{z}}}_{i}^{T}\,\quad {{\varvec{z}}}_{i}^{T}]\). Random effects \({{\varvec{b}}}\) are assumed multivariate normally distributed such that:

$$\begin{aligned} {{\varvec{b}}}\, \sim \, MVN\left( \mathbf{0 },\, {{\varvec{B}}}\otimes {{\varvec{I}}}_{q} \right) \end{aligned}$$
(3)

where \({{\varvec{B}}}=\, \left[ {\begin{array}{*{20}c} \sigma _{b_{1}}^{2} &{} \sigma _{b_{21}} &{} \sigma _{b_{31}} &{} \sigma _{b_{41}}\\ \sigma _{b_{21}} &{} \sigma _{b_{2}}^{2} &{} \sigma _{b_{32}} &{} \sigma _{b_{42}}\\ \sigma _{b_{31}} &{} \sigma _{b_{32}} &{} \sigma _{b_{3}}^{2} &{} \sigma _{b_{43}}\\ \sigma _{b_{41}} &{} \sigma _{b_{42}} &{} \sigma _{b_{43}} &{} \sigma _{b_{4}}^{2}\\ \end{array} } \right] \), and q is the number of levels of the random effect factor. Finally, \({{\varvec{e}}}_{{{\varvec{i}}}}^{T}{\varvec{=}}\left[ e_{i1}\,\quad e_{i2}\, \quad e_{i3}\, \quad e_{i4} \right] \) is the corresponding set of residuals for subject i and is assumed multivariate normal, as \({{\varvec{e}}}_{i}{ \sim }\, MVN(\mathbf{0 },{{\varvec{R}}})\), where

$$\begin{aligned} {{\varvec{R}}}=\left[ {\begin{array}{*{20}c} \sigma _{e_{1}}^{2} &{} \quad 0 &{} \quad 0 &{} \quad 0\\ 0 &{} \quad \sigma _{e_{2}}^{2} &{} \quad 0 &{} \quad 0\\ 0 &{} \quad 0 &{} \quad \sigma _{e_{3}}^{2} &{} \quad 0\\ 0 &{} \quad 0 &{} \quad 0 &{} \quad \sigma _{e_{4}}^{2}\\ \end{array} } \right] \end{aligned}$$
(4)

The underlying assumption of a diagonal residual covariance matrix \({{\varvec{R}}}\) (i.e., \(\sigma _{e_{jj^{'}}}=0)\) is standard in the context of recursive SEMs to ensure parameter identifiability (Wu et al. 2010; Gianola and Sorensen 2004). This implies that any correlations between outcomes above and beyond those due to random effects in the design structure are attributed to causal effects between outcomes, which are represented by structural coefficients \(\lambda _{jj^{'}}\) (Gianola and Sorensen 2004).

2.2 Heterogeneous Structural Coefficients

The standard specification of SEMs assumes causal homogeneity (Shipley 2002); that is, structural coefficients \(\lambda _{jj^{'}} \quad \left( j^{'}<j \right) \) are considered of the same magnitude for all n subjects in the population. Next, we propose methodological extensions that relax this assumption and, instead, specify each structural coefficient \(\lambda _{{jj}^{'}}\) as a function of fixed effects and random effects, thereby reflecting potential systematic and non-systematic courses of variability in the directed effects connecting outcomes in a network. Specifically, for each ith subject, we specify:

$$\begin{aligned} \lambda _{jj^{'},\, i}=\, {{\varvec{x}}}_{jj^{'},i}^{T}\varvec{\delta }_{jj^{'}}+{{\varvec{z}}}_{jj^{'},i}^{T}{{\varvec{v}}}_{jj^{'}} \end{aligned}$$
(5)

where \(\varvec{\delta }_{jj^{'}}\) is a vector of unknown fixed-effect location parameters (e.g., parity, demographics, etc.), \({{\varvec{v}}}_{jj^{'}}\) is a vector of unknown random effects associated with blocking factors or other design components of the data architecture, such that \({{\varvec{v}}}_{jj^{'}}\, \sim NIID(\mathbf{0 },\sigma _{v_{jj^{'}}}^{2}{\mathbf{I }}_{q})\) , and \({{\varvec{x}}}_{jj^{'},i}^{T}\) and \({{\varvec{z}}}_{jj^{'},i}^{T}\) are known corresponding row incidence vectors unique to each ith subject and specific to the \({jj}^{'}\)th structural coefficient. Further, \({{\varvec{x}}}_{jj^{'},i}^{T}\) and \({{\varvec{z}}}_{jj^{'},i}^{T}\) need not be the same for all \({jj}^{'}\) structural coefficients, neither the same as the rows of matrices \({{\varvec{X}}}_{i}\) and \({{\varvec{Z}}}_{i}\), respectively, as defined in Eq. (1).

2.3 Prior Specifications

The proposed methodological extension to SEMs was implemented in a hierarchical Bayesian framework, whereby all unknown parameters are considered to be random variables. In previous sections, we referred to so-called fixed effects, which may be defined from a Bayesian perspective as those specified by a vague prior to known hyperparameters (Sorensen and Gianola 2002). In turn, our reference to random effect reflects notation often used in mixed models and represented in the Bayesian framework by a structural prior dependent on unknown parameters, which are themselves estimated from data (Sorensen and Gianola 2002).

The elements of location parameters \(\varvec{\beta }_{j}\) were specified to have vague prior densities, i.e., \(p\left( \varvec{\beta }_{j} \right) \propto \) constant for all j (Sorensen and Gianola 2002). For each residual variance \(\sigma _{e_{j}}^{2}\), we generated a proxy for a vague prior using as an instrument the density of a truncated scaled-inverse Chi-square distribution and setting degrees of freedom \(\upsilon _{e_{j}}= -1\) and scale parameter \(s_{e_{j}}^{2}= 0\). This proxy is consistent with the prior \(\sqrt{\sigma }_{e_{j}}^{2} \sim \, U(0,A)\), for any finite but appropriately large value of A such that the resulting distribution is vague, as recommended for variance components by Gelman (2006). On the random effects \({{\varvec{b}}}\), we specified a structural prior such that \(p\left( {\varvec{b }}\vert {\varvec{B}} \right) =\, N(\mathbf{0 },\, {\varvec{B}} \otimes {{\varvec{I}}}_{q})\) to allow for borrowing of information across outcomes within each level of the random effect factor (i.e., random-level covariance), and also across levels of the random effect factor for each jth outcome (i.e., random-level variance), as is common in a multivariate mixed models framework (Robinson 1991). For the random-level (co)variance matrix \({{\varvec{B}}}\), we implemented a proxy for a vague prior using as an instrument the density of a scaled-inverse Wishart distribution, setting degrees of freedom \(\upsilon _{B} = -(J+1)\) and specifying a \(J \times J\) scale matrix of zeroes; this can be interpreted as a multivariate extension of the proxy used for the prior specified on the residual variances.

For SEMs with homogeneous structural coefficients, the prior distribution for each nonzero \(\lambda _{jj^{'}}\) was specified to be vague such that \(p\left( \lambda _{jj^{'}} \right) \propto \) constant for all \(jj^{'}\). For SEMs with heterogeneous structural coefficients, priors were specified on \(\varvec{\delta }_{jj^{'}}\), \({{\varvec{v}}}_{jj^{'}}\) and \(\sigma _{v_{jj^{'}}}^{2}\). More specifically, each element of \(\varvec{\delta }_{jj^{'}}\) was assumed vague a priori such that \(p\left( \varvec{\delta }_{jj^{'}} \right) \propto \) constant, whereas elements of \({{\varvec{v}}}_{jj^{'}}\) were assigned a structural prior density such that \(p\left( {{\varvec{v}}}_{jj^{'}}\vert \sigma _{v_{jj^{'}}}^{2} \right) \, \sim N(\mathbf{0 },\sigma _{v_{jj^{'}}}^{2}{\mathbf{I }}_{q})\). For the random-level variance \(\sigma _{v_{jj^{'}}}^{2}\) of structural coefficients, we implement a proxy for a vague prior as described above for other variance parameters.

Following from the conditionally conjugate prior specification described above, full conditional densities can be directly recognized for all unknown parameters in Eqs. (1) through (5), thus facilitating a Gibbs sampling implementation of the Markov Chain Monte Carlo (MCMC).

2.4 Data Simulation

A simulation study was designed to validate the proposed methodological extensions for specifying heterogeneous structural coefficients on an SEM and to study inferential properties for the corresponding parameters \(\varvec{\delta }_{jj^{'}}\), \({{\varvec{v}}}_{jj^{'}}\) and \(\sigma _{{{\varvec{v}}}_{jj^{'}}}^{2}\). We designed two simulation scenarios that followed the data-generating process reflected by the network in Fig. 1 and in Eq. (1). Simulation scenario A comprised all nonzero structural coefficients being homogeneous across subjects. Specifically, structural coefficients were specified as \(\lambda _{21}\, =\, 0.25,\, \lambda _{31}\, =\, -0.6,\, \lambda _{42}\, =\, 0.4,\ \hbox { and }\, \lambda _{43}\, =\, 0.8\). Simulation scenario B was similar to scenario A, except for structural coefficients \(\lambda _{21,i}\) and \(\lambda _{43,i}\) which were specified as heterogeneous following Eq. (5), with \(\varvec{\delta }_{21}^{T}=[\, 0.25\, -0.25]\), and \(\varvec{\delta }_{43}^{T}=[\, 0.5\,\quad 0.3]\) for \(\lambda _{21,i}\) and \(\lambda _{43,i}\), respectively. The elements of \(\varvec{\delta }_{21}\) and \(\varvec{\delta }_{43}\) identified the effects of two levels of a single fixed effect factor measured on the ith subject, as expressed in the design vector \({{\varvec{x}}}_{jj^{'},i}^{T}\) using an intercept and indicator variable for the second level of the factor, as in a set-to-zero parameterization (Milliken and Johnson 2009). The indicator variables in \({{\varvec{x}}}_{jj^{'},i}^{T}\) were generated from a Bernoulli distribution with probability 0.5 for each ith subject. Also in simulation scenario B, the cluster-level variances for the random effects \({{\varvec{v}}}_{21}\) and \({{\varvec{v}}}_{43}\) on structural coefficients \(\lambda _{21,i}\) and \(\lambda _{43,i}\) were specified as \(\sigma _{v_{21}}^{2}=0.1\) and \(\sigma _{v_{43}}^{2}=0.2\), respectively. For each simulation scenario, we generated ten datasets, with each dataset consisting of observations for \(J = 4\) outcome variables from 2000 subjects arranged in 100 balanced clusters, each of size 20. In both scenarios, the choice of parameter values for data simulation reflected the data application (refer to Sect. 2.4).

In all cases, we simulated location parameters \(\varvec{\beta }\) analogous to a fixed effect factor with two levels using a set-to-zero parameterization (Milliken and Johnson 2009) such that \(\varvec{\beta }_{1}^{T}=\left[ 25\, -12 \right] ,\, \varvec{\beta }_{2}^{T}=\left[ 18\, -6 \right] ,\, \varvec{\beta }_{3}^{T}=\left[ 5\, -3 \right] ,\, \varvec{\beta }_{4}^{T}=\left[ 15\, -5 \right] \), whereby vector elements indicate the intercept and the differential effect of the second level of the factor, as described above. The diagonal elements of the residual (co)variance matrix \({{\varvec{R}}}\) were specified as \(\sigma _{e_{1}}^{2}=9\), \(\sigma _{e_{2}}^{2}=1\), \(\sigma _{e_{3}}^{2}=3\) and \(\sigma _{e_{4}}^{2}=6\), whereas the diagonal elements of the random (co)variance matrix B were specified as \(\sigma _{b_{1}}^{2}=9\), \(\sigma _{b_{2}}^{2}=2\), \(\sigma _{b_{3}}^{2}=1\) and \(\sigma _{b_{4}}^{2}=3\). Finally, the random-level correlations between outcomes were specified as follows:

$$\begin{aligned} \varvec{\rho }_{{{\varvec{b}}}}=\left[ {\begin{array}{*{20}c} 1 &{} \quad -0.7 &{} \quad 0.4 &{} \quad 0.1\\ -0.7 &{} \quad 1 &{} \quad -0.5 &{} \quad -0.2\\ 0.4 &{} \quad -0.5 &{}\quad 1 &{} \quad 0\\ 0.1 &{} \quad -0.2 &{}\quad 0 &{} \quad 1\\ \end{array} } \right] \end{aligned}$$
(6)

2.5 Application to Swine Data

Data were obtained from an experimental study on swine reproduction conducted at a commercial swine farm in northern Ohio. The complete description of the data is available in Gonçalves et al. (2016). Briefly, the outcomes variables consisted of descriptors of reproductive performance, namely female weight gain during late (d 90 to 111) gestation (GAIN, in kg; \(j = 1\)), number born alive in a litter (BA; \(j = 2\)), born alive average birth weight (BABW, in g; \(j = 3\)), total number of piglets born (TB; \(j = 4\)), wean-to-estrous interval (WEI, in days; \(j = 5\)) and total litter size born in the subsequent gestation (SuTB; \(j = 6\)). Both TB and SuTB are defined as total litter size and consisted of the summation of piglets born alive, stillborns and mummies. In this analysis, we only considered females with complete records on all six outcomes (i.e., no missing data). After editing, the final dataset used for analysis consisted of 691 females, 200 of which were multiparous adults (i.e., sows) and 491 were primiparous youngsters (i.e., gilts). Within each parity group, females were arranged in 97 and 222 body weight blocks for sows and gilts, respectively. Dietary treatments consisting of four combinations of energy intake and dietary amino acids were randomly assigned to individual females within each body weight block.

For each jth outcome, the \({{\varvec{x}}}_{ij}\) vector corresponding to Eq. (1) included an intercept and indicator variables for parity groups (sows or gilts), dietary treatments and their combination, such that the corresponding \(\varvec{\beta }_{j}\) was expressed in set-to-zero full-rank parameterization (Milliken and Johnson 2009). The \({{\varvec{z}}}_{i}\) vector corresponding to Eq. (1) consisted of indicator variables that identified the body weight block within parity group for each ith observation.

Specification of the network structure was based on preliminary analyses (Chitakasempornkul et al. 2019) conducted separately for each parity group using SEMs that assumed homogeneous structural coefficients in each case. Briefly, for each parity group, the network structure, and thus the specification of matrix \({\varvec{\Lambda }}\), was learned from the data using the inductive causation algorithm (Verma and Pearl 1991) adapted to a hierarchical Bayesian framework (Valente et al. 2010). Results from such preliminary analyses are depicted in Fig. 2a, b for sows and for gilts, respectively, and suggest distinct causal networks for each parity group. Specifically, sows showed a sparsely connected network with few direct effects and thus few nonzero structural coefficients (i.e., BABW \(\rightarrow \) BA and BA \(\rightarrow \) TB; remaining outcomes were not connected) (Fig. 2a). By contrast, gilts showed a more densely interconnected network between reproductive outcomes (Fig. 2b) (Chitakasempornkul et al. 2019). These preliminary results prompted the methodological SEM extension proposed herein to incorporate modeling of heterogeneous structural coefficients due to both treatment structure and design structure. When structural coefficients were specified as heterogeneous, as in Eq. (5), the corresponding \({{\varvec{x}}}_{jj^{'},i}^{T}\) vector included an intercept and indicator variables for parity group and \({{\varvec{z}}}_{jj^{'},i}^{T}\) consisted of indicator variables for body weight blocks within each parity group.

Fig. 2
figure 2

Results of preliminary analyses (Chitakasempornkul et al. 2019) showing functional links between reproductive performance outcomes in sows (a) and in gilts (b) obtained using the mixed-model adapted inductive causation algorithm (Valente et al. 2010) implemented separately in each parity group using 80% highest posterior density intervals. GAIN = female weight gain during late gestation; TB = total number born in a litter; BA = number born alive in a litter; BABW = born alive average body weight; WEI = wean-to-estrous interval; SuTB = total number born in the subsequent gestation

Fig. 3
figure 3

Alternative causal structures connecting reproductive performance outcomes in the swine data. The black arrow indicates alternative directions of the link between BABW and BA. a Causal effect of BABW on BA (i.e., BA \(\leftarrow \) BABW). b Causal effect of BA on BABW (i.e., BA \(\rightarrow \) BABW). GAIN = female weight gain during late gestation; TB = total number born in a litter; BA = number born alive in a litter; BABW = born alive average body weight; WEI = wean-to-estrous interval; and SuTB = total number born in the subsequent gestation

It was also apparent from preliminary analysis (Chitakasempornkul et al. 2019) that the structure of the sow network was nested within that of gilts, though the direction of the link connecting BA and BABW was reversed (i.e., BA \(\leftarrow \) BABW in sows vs. BA \(\rightarrow \) BABW in gilts; Fig. 2). Therefore, for the joint analysis presented herein, we implemented the most general network structure (i.e., that obtained from preliminary analyses in gilts) and further considered two putative causal structures that differed in the direction of the link connecting BA and BABW (Fig. 3). Here, we refer to the causal structure with direct effect BA \(\leftarrow \) BABW as option A and to that with direct effect BA \(\rightarrow \) BABW as option B (Fig. 3). The matrix \({\varvec{\Lambda }}\) of structural coefficients corresponding to options A and B can be expressed as:

$$\begin{aligned} {\varvec{\Lambda }}_{\mathrm {A}}= & {} \left[ {\begin{array}{*{20}c} 0 &{}\quad 0 &{}\quad 0 &{} \quad 0 &{} \quad 0 &{} \quad 0\\ 0 &{}\quad 0 &{} \quad \lambda _{\mathrm {BA,BABW}} &{} \quad 0 &{} \quad 0 &{}\quad 0\\ \lambda _{\mathrm {BABW,GAIN}} &{} \quad 0 &{} \quad 0 &{} \quad 0 &{} \quad 0 &{} \quad 0\\ 0 &{} \quad \lambda _{\mathrm {TB,BA}} &{} \quad \lambda _{\mathrm {TB,BABW}} &{} \quad 0 &{} \quad 0 &{} \quad 0\\ 0 &{} \quad 0 &{} \quad \lambda _{\mathrm {WEI,BABW}} &{} 0 \quad &{} \quad 0 &{} \quad 0\\ 0 &{}\quad 0 &{} \quad \lambda _{\mathrm {SuTB,BABW}} &{} \quad 0 &{} \quad \lambda _{\mathrm {SuTB,WEI}} &{}\quad 0\\ \end{array} } \right] \end{aligned}$$
(7)
$$\begin{aligned} {\varvec{\Lambda }}_{\mathrm {B}}= & {} \left[ {\begin{array}{*{20}c} 0 &{} \quad 0 &{} \quad 0 &{} \quad 0 &{} \quad 0 &{} \quad 0\\ 0 &{} \quad 0 &{} \quad 0 &{} \quad 0 &{} \quad 0 &{} \quad 0\\ \lambda _{\mathrm {BABW,GAIN}} &{} \quad \lambda _{\mathrm {BABW,BA}} &{} \quad 0 &{} \quad 0 &{} \quad 0 &{} \quad 0\\ 0 &{} \quad \lambda _{\mathrm {TB,BA}} &{} \quad \lambda _{\mathrm {TB,BABW}} &{} \quad 0 &{} \quad 0 &{} \quad 0\\ 0 &{} \quad 0 &{} \quad \lambda _{\mathrm {WEI,BABW}} &{} \quad 0 &{} \quad 0 &{} \quad 0\\ 0 &{} \quad 0 &{} \quad \lambda _{\mathrm {SuTB,BABW}} &{} \quad 0 &{} \quad \lambda _{\mathrm {SuTB,WEI}} &{} \quad 0\\ \end{array} } \right] \end{aligned}$$
(8)

For both \({\varvec{\Lambda }}_{\mathrm {A}}\) and \({\varvec{\Lambda }}_{\mathrm {B}}\), the outcomes are ordered as described earlier in Sect. 2.5. However, we recognize that parameter \(\lambda _{\mathrm {BA,BABW}}\) in \({\varvec{\Lambda }}_{\mathrm {A}}\) is not included in the lower triangle of the matrix. Therefore, to abide by standard SEM notation, we reordered the outcomes under option A as \(j^{*}=1\) for GAIN, \(j^{*}=2\) for BABW, \(j^{*}=3\) for BA, \(j^{*}=4\) for TB, \(j^{*}=5\) for WEI and \(j^{*}=6\) for SuTB and rewrote \({\varvec{\Lambda }}_{\mathrm {A}}\) to include all structural coefficients in the lower triangle of the matrix.

2.6 Alternative SEM Specifications

We fitted alternative SEM specifications to the simulated data in order to validate inferential properties of the proposed methodological extensions. Specifically, Model 0 (M0) was a fully recursive SEM with a complete lower triangle matrix \({\varvec{\Lambda }}\) such that all the \(\lambda _{jj^{'}}\) indicative of recursive effects were estimated. The fully recursive SEM specification in M0 can be shown to be equivalent to a classical MTM (Gianola and Sorensen 2004). Model 1 (M1) was devised as an SEM with selected \(\lambda _{jj^{'}}\) set to zero to reflect the causal structure in Fig. 1 and Eq. (1) (e.g., \(\lambda _{32}=\lambda _{41}=0)\). It is noted that M1 represents the true data-generation process for simulation scenario A. Both M0 and M1 specify homogeneity of any structural coefficient \(\lambda _{jj^{'}}\) not set to zero. Model 2 (M2) expands M1 with a heterogeneous specification of all nonzero \(\lambda _{jj^{'}}\) , which are expressed as functions of fixed effects and random effects, as described in Eq. (5). Model 2* (M2*) expands M1 by enabling a heterogeneous specification of structural coefficients \(\lambda _{21,i}\) and \(\lambda _{43,i}\) only, thereby reflecting the true data-generating process for simulation scenario B. In the simulation study, alternative SEM specifications M0, M1, M2 and M2* were fitted to each of the 20 simulated datasets.

For the swine data application, we implemented SEM specifications M0, M1 and M2 as described for the simulation study. For models M1 and M2, we fitted the two competing putative causal structures represented by \({\varvec{\Lambda }}_{\mathrm {A}^{{*}}}\) and \({\varvec{\Lambda }}_{\mathrm {B}}\) (Fig. 3). Preliminary analyses had indicated substantial evidence for heterogeneity of residual variances as a function of body weight blocks on GAIN, BA, TB, WEI and SuTB (results not shown). Therefore, we devised Model 3 (M3), which expanded M2 to accommodate heterogeneous residual variances for the corresponding outcomes, such that, following Kizilkaya and Tempelman (2005):

$$\begin{aligned} \sigma _{e_{j},i}^{2}=\sigma _{e_{\mathrm{ref},j}}^{2}w_{e_{j,\, i}} \end{aligned}$$
(9)

where \(\sigma _{e_{\mathrm{ref},j}}^{2}\) represents an unknown reference residual variance for the jth outcome (i.e., GAIN, BA, TB, WEI and SuTB), akin to an intercept in the modeling of location parameters, and \(w_{e_{j,\, i}}\) represents the random effect of the body weight block that the ith female corresponds to, and for the jth outcome. For each reference variance parameters \(\sigma _{e_{\mathrm{ref},j}}^{2}\), we generated a proxy for a vague prior using as an instrument the density of a scaled-inverse Chi-square distribution and setting degrees of freedom \(\upsilon _{e_{j}}= -1\) and scale parameter \(s_{e_{j}}^{2}= 0\). Further, each element of the outcome-specific set of random effects \({{\varvec{w}}}_{e_{j}}{\varvec{=\, }}\left\{ w_{e_{j,\, l}} \right\} _{l=1}^{q}\) was assigned an independent structural prior \(\textit{IG}(\alpha _{e_{j}},\, \alpha _{e_{j}}-1)\) such that \(E({{\varvec{w}}}_{e_{j}}\vert \, \alpha _{e_{j}})=1\) and \(var({{\varvec{w}}}_{e_{j}}\vert \, \alpha _{e_{j}})={(\alpha _{e_{j}}-2)}^{-1}\) for \(\alpha _{e_{j}}>2\). Finally, we assigned a vaguely informative yet proper prior density to each \(\alpha _{e_{j}}\), whereby \(\alpha _{e_{j}}\, \sim \, p\left( \alpha _{e_{j}} \right) \propto \, {(1+\alpha _{e_{j}})}^{-2}\), which is commonly used for strictly positive parameters. The full conditional density of \(\alpha _{e_{j}}\) in M3 was not recognizable and thus called for sampling of \(\alpha _{e_{j}}\) using a random walk Metropolis–Hastings algorithm (Kizilkaya and Tempelman 2005).

2.7 Model Comparison

Goodness of fit was compared between alternative SEM specifications M0, M1, M2 and M2* for the simulation study and between M0, M1, M2 and M3 for the data application using deviance information criterion (DIC) (Spiegelhalter et al. 2002). Models with better fit are characterized by smaller DIC values, such that DIC differences of 7 or greater were considered indicative of substantial fit improvement (Spiegelhalter et al. 2002). In the simulation study, we further evaluated accuracy of parameter estimation under alternative SEM specifications based on coverage, defined as whether the 95% highest posterior density (HPD) interval of a parameter contained the true value used for simulation.

Fig. 4
figure 4

Model fit comparison, expressed as differences in deviance information criterion (DIC) relative to the true data-generation model under simulation scenario A (i.e., a: homogeneous structural coefficients, true model = M1; black dots) and simulation scenario B (i.e., b: heterogeneous \(\lambda _{21,i}\) and \(\lambda _{43,i}\), true model = M2*; triangles). M0 = Fully recursive SEM, equivalent to a traditional multiple-trait model (Stars). M1 = SEM with homogeneous specification of structural coefficients defining a preselected causal structure; M2 = SEM with heterogeneous specification of all \(\lambda _{jj^{'},i}\) for \(j^{'}<j\), \(j = 1, 2, \ldots , J\) and \(i = 1, 2, \ldots , n \) defining a preselected causal structure (white dots); M2* = SEM with heterogeneous specification of structural coefficients \(\lambda _{21,i}\) and \(\lambda _{43,i}\) only defining a preselected causal structure. Each point represents a dataset generated under the corresponding scenario and fitted with one of the SEMs M0, M1, M2 or M2*. A reference horizontal line represents a threshold value of 7 indicative of a substantial difference in model fit relative to the true data-generation model in each case

2.8 Bayesian Implementation

Implementation of the proposed methodological extensions used an MCMC method programmed in R (R Development Core Team 2016). In the simulation study, alternative SEMs were fitted to each simulated dataset using a single MCMC chain run for 260,000 iterations after a burn-in period of 60,000 cycles. For the data application, each alternative SEM was fitted using ten MCMC chains run for 100,000 iterations after a burn-in period of 80,000 cycles. In all cases, length of MCMC chains was adjusted to ensure that the estimated number of effectively independent samples among autocorrelated MCMC samples, also known as effective sample size (ESS), was greater than 400 for all hyperparameters. One of every two samples was saved for posterior inference. In all cases, convergence was monitored using the R package CODA, which implemented trace plots on all higher-order hyperparameters and also diagnostic tests, specifically the single-chain approach proposed by Raftery and Lewis (1992) in the simulation study and the multiple-chain testing approach proposed by Gelman and Rubin (1992) in the data application. For each parameter of interest, we summarized posterior inference using posterior means and 95% HPD intervals. Specific to the assessment of heterogeneity of structural coefficients between levels of the fixed-effect factor (i.e., parity groups), we obtained the posterior density of \(\left( \lambda _{jj^{'}}^{\mathrm {Gilt}}-\lambda _{jj^{'}}^{\mathrm {Sow}} \right) \) and computed the probability of such difference (also known as (1 - Bayesian P-value)) as \(1-\left[ 2\times \min \left\{ \text {Pr}\left( {\lambda _{jj^{'}}^{\mathrm {Gilt}}-\lambda _{jj^{'}}^{\mathrm {Sow}}\ge 0}\,\vert \, {{\varvec{y}}}\right) ,\text {Pr}\left( {\lambda _{jj^{'}}^{\mathrm {Gilt}}-\lambda _{jj^{'}}^{\mathrm {Sow}}<0}\,\vert \, {{\varvec{y}}}\right) \right\} \right] \).

3 Results

3.1 Simulation Study

Figure 4 shows comparative model fit of alternative SEM specifications under simulation scenarios A (panel A) and B (panel B), expressed as DIC differences relative to the corresponding true data-generation model in each case. For networks generated under conditions of structural homogeneity (i.e., simulation scenario A), any of the alternative SEM specifications M0, M2 and M2* showed DIC differences indicative of impaired global fit relative to the true data-generation model (i.e., M1). The difference in fit can be explained by a loss in parsimony of M0, M2 and M2* relative to M1. Indeed, the effective number of parameters pD (Spiegelhalter et al. 2002) was estimated to be greater by [minimum, maximum] [368.6, 380.4], [390.9, 412.8] and [377.5, 391.0] for M0, M2 and M2*, respectively, relative to the true data-generation model M1 across simulated datasets under scenario A.

Impaired global fit of alternative SEM misspecifications was even more dramatic under simulation scenario B, as indicated by the logarithmic scale of the y-axis in Fig. 4b. Recall simulation scenario B was characterized by heterogeneity of selected structural coefficients in the network, namely \(\lambda _{21,i}\) and \(\lambda _{43,i}\), such that M2* depicted the true data-generation process. Model specifications that incorrectly assumed homogeneity of all structural coefficients (i.e., M0 and M1) showed drastically impaired fit with DIC differences ranging from 3713 to 4344 points relative to the true model M2* (Fig. 4b). In fact, the observed differences in global fit were explained by differences in model adequacy, as quantified by the deviance term of DIC (Spiegelhalter et al. 2002), which was estimated to be greater by [minimum, maximum] [3832.2, 4479.2] and [3826.4, 4472.45] for alternative SEMs M0 and M1, respectively, relative to the true data-generation model M2*. In turn, SEM M2, which allowed all nonzero structural coefficients to be heterogeneous, also showed impaired fit relative to M2*, though the magnitude of the DIC difference was considerably mitigated and ranged from 59 to 113 points across simulated datasets.

Figure 5a, b illustrates overall accuracy of parameter estimation, expressed as percent coverage of 95% HPD intervals, for alternative SEM specifications M0, M1, M2 and M2* fitted to simulation scenarios A and B, respectively. For networks generated under conditions of homogeneous structural coefficients (i.e., M1 in simulation scenario A), estimation accuracy was within probabilistic expectation for all model parameters regardless of SEM specification. On average, coverage was 93.1, 95., 97.5, 96.8, 94.4 and 99.2 % for parameter sets \(\lambda _{jj^{'}},\, \beta _{1,j},\, \beta _{2,j},\, \sigma _{e_{j}}^{2},\, \sigma _{u_{j}}^{2}\) and \(\sigma _{u_{{jj}^{'}}}\), respectively. This was to be expected as all the fitted SEM specifications were at least as general and flexible as the one used for data generation (i.e., M1). However, for location parameters and structural coefficients, more complex models often yielded wider HPD intervals than more parsimonious models.

Fig. 5
figure 5

Overall accuracy of parameter estimation, defined as percent coverage (%) of 95% highest posterior density intervals under simulation scenario A (i.e., a: homogeneous structural coefficients, true model = M1) and B (i.e., b: heterogeneous \(\lambda _{21,i}\) and \(\lambda _{43,i}\), true model = M2*). M1 = SEM with homogeneous specification of structural coefficients defining a preselected causal structure; M2 = SEM with heterogeneous specification of all \(\lambda _{jj^{'},i}\) for \(j^{'}<j, j = 1, 2, \ldots , J\) and \(i = 1, 2, \ldots , n \) defining a preselected causal structure; M2* = SEM with heterogeneous specification of structural coefficients \(\lambda _{21,i}\) and \(\lambda _{43,i}\) only defining a preselected causal structure. Each dot represents coverage for all parameters from a simulated dataset

Under simulation scenario B with heterogeneous \(\lambda _{21,i}\) and \(\lambda _{43,i}\), estimation accuracy as per average HPD coverage (Fig. 5b) for both SEMs M2 and M2* was \(\sim 100.0 \sim 100., \sim 98.8, \sim 100., \sim 91.3, \sim 98.3, \sim 85., \sim 100.0\) and \(\sim 100.0{\%}\), for \(\lambda _{jj^{'}},\, \beta _{1,j},\, \beta _{2,j},\, \sigma _{e_{j}}^{2},\, \sigma _{u_{j}}^{2},\, \sigma _{u_{{jj}^{'}}}\), \(\delta _{1,jj^{'}},\delta _{2,jj^{'}}\) and \(\sigma _{v_{jj^{'}}}^{2}\), respectively; these results also reflect wider 95% HPD intervals under more complex SEM specifications. In contrast, coverage of the simpler SEM specifications M0 and M1 decreased, thus indicating impaired estimation accuracy (Fig. 5b). In these cases, decreased coverage was explained primarily by underestimation of structural coefficients \(\lambda _{jj^{'}}\) (i.e., average coverage of approximately \(\sim \) 75%) and by biased estimation of location parameters \(\, \beta _{1,j}\) and \(\beta _{2,j}\) (i.e., average coverage of \(\sim 68.8{\%}\) and \(\sim 47.5{\%}\), respectively). Furthermore, (co)variance components \(\sigma _{e_{j}}^{2},\, \sigma _{u_{j}}^{2},\, \sigma _{u_{{jj}^{'}}}\) were mostly overestimated (average coverage of \(\sim 47.5\), \(\sim 43.8\) and \(\sim 71.3{\%}\), respectively) when M0 and M1 were fitted to datasets in simulation scenario B, thus failing to recognize heterogeneity in \(\lambda _{21,i}\) and \(\lambda _{43,i}\).

Table 1 Model fit of alternative SEM specifications and causal structures to swine data, expressed as deviance information criterion (DIC) and effective number of parameters (pD) (Spiegelhalter et al. 2002)

3.2 Application to Swine Data

Table 1 shows DIC-based global fit assessments of alternative SEM specifications M0, M1, M2 and M3 fitted to the swine data with putative causal structures A (i.e., BA \(\leftarrow \) BABW) and B (i.e., BA \(\rightarrow \) BABW) (Fig. 3). Overall, M3 yielded the smallest DIC values, thus indicating evidence for both heterogeneous structural coefficients (based on DIC differences of M3 relative to M0 and M1) and heterogeneous residual variances (based on the DIC difference of M3 relative to M2). Furthermore, DIC comparisons between M3-A and M3-B seemed to slightly favor a causal structure with a direct effect from BA to BABW (i.e., BA \(\rightarrow \) BABW), consistent with Fig. 3b, though the difference was small in magnitude (\(\sim \) 4.4 points; Table 1) and potentially inconclusive. Based on these results, we selected as best fitting SEM M3 with a putative casual structure that included a direct effect BA \(\rightarrow \) BABW and used it for final inference on a heterogeneous network of reproductive performance outcomes in swine females.

Table 2 Posterior summary of structural coefficients for sows and gilts of a typical body weight block based on the best-fitting SEM selected for final inference

3.2.1 Structural Heterogeneity: Structural Coefficients and Direct Effects

Evidence for heterogeneity of direct effects was substantial, as a function of both the systematic effect of parity group and the non-systematic effects of body weight block, as dictated by experimental design. Table 2 shows the posterior summary of the structural coefficients for sows and gilts, as well as their difference, based on the final model selected for inference. Systematic heterogeneity of structural coefficients was mostly apparent for the direct effects of GAIN on BABW (i.e., GAIN \(\rightarrow \) BABW) and of WEI on SuTB (i.e., WEI \(\rightarrow \) SuTB), with posterior probabilities of 0.86 and 0.98 for parity differences, respectively. Specifically, every kg increase in sow GAIN resulted in an estimated increase in BABW of (posterior mean [95% HPD]) 0.07 g [0.02, 1.11]. By contrast, the magnitude of the corresponding value for gilts was approximately halved, with a 95% HPD interval that slightly overlapped zero (Table 2). Furthermore, the direct effect of WEI on SuTB (i.e., WEI \(\rightarrow \) SuTB) was of opposite signs across parities; every additional WEI day decreased SuTB in sows by approximately 0.26 [0.07, 0.48] piglets but increased SuTB in gilts by an estimated 0.16 [0.09, 0.23] piglets (Table 2).

Other direct effects showed a moderate posterior probability of difference between sows and gilts. In particular, our results indicate posterior probabilities of 76% and 78% for differential direct effects of BA on TB (i.e., BA \(\rightarrow \) TB) and of BABW on TB (i.e., BABW \(\rightarrow \) TB) and between gilts and sows (Table 2). For sows, every additional piglet BA increased TB by approximately 0.91 [0.84, 0.99] piglets, whereas for gilts, the increase was just at 0.86 [0.80, 0.92]. In contrast, the direct effects of BA on BABW, of BABW on WEI and of BABW on SuTB showed little to no evidence for heterogeneity across parity groups, as indicated by smaller posterior probabilities (Table 2).

Table 3 shows a posterior summary of the between-block (i.e., random-level) variances \(\sigma _{v_{{jj}^{'}}}^{2}\) on the corresponding structural coefficients \(\lambda _{jj^{'}}\); these variance components describe non-systematic sources of variability on the corresponding direct effects. For further interpretation, we use empirical rule (Moore et al. 2018) and assume \({{\varvec{v}}}_{jj^{'}}\) to be multivariate normal for each \({jj}^{'}\)th direct effect. Using the posterior mean of the between-block variance \(\sigma _{v_{{jj}^{'}}}^{2}\) (Table 3) as a point estimate, one may anticipate direct effects to range by approximately \(\pm 1.96\sqrt{\sigma }_{v_{{jj}^{'}}}^{2} \) between the most extreme body weight blocks. For example, take \(\sigma _{v_{\mathrm {TB,BABW}}}^{2}\), whereby one might expect a range of \(\pm 0.81\) piglets per 100 g BABW across the most extreme body weight blocks. Overlaying this range on the posterior mean of \(\lambda _{\mathrm {TB,BABW}}\), the direct effect BABW \(\rightarrow \) TB might be expected to range from \(-1.45\) to 0.17 piglets TB per 100 g BABW in sows and from \(-0.95\) to 0.67 piglet TB per 100 g BABW in gilts. Applying a similar approach to \(\sigma _{v_{\mathrm {WEI,BABW}}}^{2}\), \(\sigma _{v_{\mathrm {SuTB,BABW}}}^{2}\) and \(\sigma _{v_{\mathrm {SuTB,WEI}}}^{2}\), one might anticipate direct effects to range by ± 1.02 days WEI per 100g BABW, \(\pm 1.87\) piglets SuTB per 100g BABW and \(\pm 0.13\) piglets SuTB per day WEI across the most extreme body weight blocks, respectively (Table 3). Relative to the posterior mean of \(\lambda _{\mathrm {SuTB,WEI}}\), one might expect the direct effect WEI \(\rightarrow \) SuTB to range from \(-0.39\) to \(-0.13\) piglet SuTB in sow litters, and from 0.03 to 0.29 piglet SuTB in gilt litters for every additional day WEI. Remaining variances characterizing variability across body weight blocks on structural coefficients were negligible in magnitude (Table 3) and are not discussed further.

Results on network heterogeneity manifested as indirect effects and total effects between outcomes as well as heteroskedasticity across body weight blocks for GAIN, BA, TB, WEI and SuTB are presented as Supplementary Materials.

Table 3 Posterior summary of random-level (i.e., between-block) variance \(\sigma _{{{\varvec{v}}}_{jj^{'}}}^{2}\) of structural coefficients linking reproductive performance outcomes in swine data, and their interpretation in terms of expected range of the corresponding \(\lambda _{jj^{'}}\) based on empirical rule

4 Discussion

In this study, we proposed a general methodological approach that extends structural equation models to explicitly specify heterogeneity of structural coefficients in the context of network modeling. More specifically, structural coefficients were parameterized as a function of systematic and non-systematic sources of variability in a mixed models-type framework. Our general approach relaxes the assumption of causal homogeneity by enabling a flexible specification of structural coefficients for heterogeneous networks. The proposed methodological extension is implemented in a hierarchical Bayesian framework, which facilitates the joint specification of multifactorial treatment structures and hierarchical data architecture, as is often required for designed experiments; the proposed extension is readily applicable to observational data as well. Using a simulation study, we validated inferential properties of the proposed methodological extensions and applied them to a dataset from a designed experiment in swine reproduction. This agricultural application illustrates how animal-level factors combined with farm management practices may play a role on the relationships between performance outcomes in an animal production system. An explicit specification of heterogeneity in structural coefficients was shown to enhance understanding of the mechanisms underlying reproductive physiology of swine females, thus facilitating targeted management decision for specific subpopulations. Our findings of multi-level heterogeneity are consistent with other agricultural production systems (Bello et al. 2010, 2013).

Previous work by Wu et al. (2007) proposed to incorporate heterogeneity into a general SEM framework by specifying the whole matrix of structural coefficients \({\varvec{\Lambda }}\) to be unique to pre-defined subpopulations. Here, we generalize this proposal and allow for a more flexible specification that can accommodate multifactorial treatment and design structures on individual structural coefficients. Moreover, our approach is computationally simpler as it relies on a Gibbs sampler with fully recognizable full-conditional densities, as opposed to the more intensive implementation in Wu et al. (2007) that relied on a series of Metropolis–Hastings algorithms.

From an application perspective, we highlight that it was possible to diagnose network heterogeneity based on model fit comparisons. Indeed, our simulation study showed that when data were generated under conditions of network heterogeneity (i.e., simulation scenario B), DIC-based differences in global fit between SEMs that assumed structural coefficients as homogeneous (i.e., M1) or heterogeneous (i.e., M2* or M2) were easily detectable and that DIC consistently selected the appropriate model. In fact, DIC seemed to be quite sensitive as a diagnostic tool as model fit indicated preference for an SEM with heterogeneous structural coefficients even when only a subset of the coefficients were actually heterogeneous, as supported by the comparison of M2 versus M1 in simulation scenario B. In turn, underspecified SEMs (i.e., M0 and M1 vs. M2* in scenario B) showed clear evidence for impaired fit, further leading to biased estimation of not only structural coefficients but also mean-level location parameters. Conversely, DIC was also able to identify cases in which an SEM with the standard assumption of structural homogeneity sufficed (i.e., simulation scenario A), thus ensuring model parsimony. These results suggest that DIC-based model fit may be used to identify departures from the assumption of structural homogeneity and prove structural heterogeneity of networks in real data, for which the true state of nature is unknown. This desirable diagnostic behavior of DIC is consistent with that already observed in SEM applications (Inoue et al. 2016, Chitakasempornkul et al. 2018) and other hierarchical multivariate settings (Bello et al. 2010, 2013). Despite the encouraging results on DIC as a diagnostic SEM tool, challenges remain, particularly for assessing directionality of network links. In our data application, the small magnitude of DIC differences between alternative causal structures connecting BA and BABW may be explained by lack of information in data. This is consistent with previous work (Chitakasempornkul et al. 2019) showing sample size-based differences in statistical power for directionality in network learning.

Nevertheless, we acknowledge that the approach to network heterogeneity implemented here assumes a known network structure (i.e., ordering of variables and zero vs. nonzero structural coefficients), such that uncertainty in model selection is unaccounted for. A Bayesian model averaging (BMA)-like (Raftery et al. 1997) extension may be explored to accommodate uncertainty in the selection of network structure, simultaneously with uncertainty in structural heterogeneity of the network. Previous work (Madigan et al. 1995; York et al. 1995) described implementation of BMA in the context of graphical models, of which SEM may be considered a special case.

The importance of correctly recognizing hierarchical data architecture in the context of SEMs was demonstrated by Chitakasempornkul et al. (2018), lest estimation bias and loss of precision impair inference. Data architecture is pervasive in agricultural applications, often resulting in different sizes of experimental units and levels of replication. The hierarchical flexibility of our proposed methodological SEM extension can ensure powerful inference on heterogeneous structural coefficients that is also properly calibrated to the true amount of replication available for a given treatment factor. In so doing, we argue for extending integrity of the inferential scope beyond mean-level location parameters (Bello and Renter 2018) into functional links in a heterogeneous network.

Specific to the swine data application, data architecture was driven by body weight blocks, which identified the unit of experimental replication for the factor defining the source of heterogeneity (i.e., parity group). Random effects are often assumed mutually independent, though this assumption seems questionable in this case as blocks with similar weights can be expected to be similar to each other and thus likely correlated. Instead, one may consider specifying an antedependence-type structure of the (co)variance matrix of random effects along the body weight gradient, thus further accounting for dissipating correlations. An analogous strategy was proposed by Yang and Tempelman (2012) in the context of genomic prediction to account for linkage disequilibrium among genetic markers along a chromosome. Given how common the strategy of blocking along a gradient is, this type of methodological extension is likely to be relevant to the practice of experimental design. Similarly, genetic relationships between animals are another scenario of potentially correlated random effects. To accommodate, one may consider replacing the identity matrix in Eq. (3) with a relationship matrix depicting relatedness between animals, as measured by pedigree or realized genetic relationships.

Specific to swine reproduction, our results indicated evidence for heterogeneity of structural coefficients, some of which differed between parity groups and across body weight blocks. Most notably, the direct effect of WEI \(\rightarrow \) SuTB showed a high posterior probability of differing between sows and gilts, and this was consistent with preliminary results based on separate SEMs fitted to each parity group (Chitakasempornkul et al. 2019). Specifically, gilts showed larger subsequent total litter size (i.e., SuTB) as the interval from weaning to estrous (i.e., WEI) increased, whereas the opposite was true for sows. As a plausible explanation, we note that gilts are immature animals, still growing after their first farrowing event (Kraeling and Webel 2015), and as such, subjected to competing requirements for growth and reproduction. Moreover, post-weaning gilts are usually less effective at recovering body condition compared to sows (Rempel et al. 2015), thus further delaying estrous and rebreeding. It is then not surprising that subsequent reproductive performance of gilts is positively sensitive to WEI, whereas the opposite is true of sows. This type of heterogeneous network inference supports tailored management of gilts after first farrowing, in order to maximize nutrient intake during lactation and facilitate timely reproductive functionality post-weaning.

Outcome variables of discrete nature are common in agricultural production systems. In our data application, BA, TB and SuTB can be formally defined as discrete counts. A normal approximation to discrete variables is often implemented to expedite model fitting and facilitate the estimation process (Stroup 2015); this was our approach in this study. However, we recognize that inappropriately forcing a normal approximation for data analysis can mislead the estimation process and hinder interpretation (Larrabee et al. 2014). Instead, proper recognition of the discrete nature of an outcome variables is increasingly promoted to ensure sound inference (Stroup 2013, 2015). One may consider incorporating an underlying latent variable into SEM, analogous to threshold models (Sorensen and Gianola 2002), thus enabling the joint network analysis of continuous and discrete outcomes. Recent studies by López de Maturana et al. (2007) and Konig et al. (2008) illustrate implementation of a threshold modeling extension to hierarchical SEMs to accommodate categorical outcomes in genetic applications. Extensions that incorporate network heterogeneity to hierarchical threshold SEMs are warranted.

Lastly, we revisit the causal interpretation that can be attached to structural coefficients in an SEM and recognize the need for non-trivial causal assumptions that are not testable from data, namely the Markov condition, faithfulness and causal sufficiency (Pearl 2009). These causal assumptions are paramount, even in the context of randomized designed experiments. Randomization substantiates causal claims for treatments on individual outcomes, but not from one outcome to another. Hence, causal assumptions are still required to infuse causal interpretation to structural coefficients as functional network links regardless of the observational or experimental nature of the data (Bello et al. 2018).

5 Conclusions

In this study, we propose a general approach for explicit specification of heterogeneous structural coefficients in network-type structural equation models. The proposed methodological extension is implemented in a hierarchical Bayesian framework and enables reliable inference on heterogeneous networks based on specification of structural coefficients as functions of systematic and non-systematic sources of variability, as would be expected from a designed experiment. Relevant applications encompass complex systems, including production animal agriculture, for which an in-depth understanding of the mechanisms underlying the system is critical to efficient management and optimal decision making.