**5. SEM example**

#### **5.1 Database**

To illustrate the application of the packages lavaan of the R software, data from a study carried out in a Public Maternal Hospital in the state of Guerrero, Mexico, are used. The database corresponds to a cross-sectional study of pregnant women who presented to the emergency department of the Maternal Hospital with a clinical picture compatible with an obstetric emergency [16]. Two groups of patients were constituted, one group was treated from January 2009 to December 2011, which corresponds to the period before the implementation of a process called Red Code (Before RC), which is aimed at pregnant women with obstetric emergency situations; and another group of patients treated from September 2013 to December 2015, in which the Red Code (RC) procedure was implemented. The observed variables are the same for both cases, and the number of observations for the RC period is 106 and 230 for Before RC. The code and analysis presented below correspond to data from the CR period. For the Before CR case, it is a similar way. Since these are two different data

sets, it is not possible to apply an analysis of variance. Therefore, to compare the results of the studied models, only the fit indices and the coefficients of factor loadings and regression are compared.

SEM is based on the variance/covariance matrix of the observed variables. However, when the observed variables present very different variances, it is suggested to use the correlation matrix. The R software is available on GNU GPL (General Public License) on the CRAN website (Comprehensive R Archive Network) https://CRAN.- R-project.org [17]. To implement SEM using the lavaan [18] package, you first need to install it using the instructions:

install.packages("lavaan"). library(lavaan).

In this data set, the opinions of the expert medical personnel assigned to the Maternal Hospital are considered to determine the following latent variables and observed variables: First Hemodynamic State (FHS) is made up of the variables observed: Temperature (Tm1), heart rate (HR1), blood pressure (BP1), respiratory rate (BF1) and the number of seizures (NC). The latent variable Second Hemodynamic State (SHS) is made up of the observed variables: Temperature (Tm2), heart rate (HR2), blood pressure (BP2), respiratory rate (BF2). Gyneco-obstetric background (OGH) is measured by the variables number of abortions (NumAb), number of cesarean sections (NumCa), weight of the pregnant woman (PW), and number of vaginal deliveries (NVD). Treatment (Treat) formed by Plasma (PLAS), platelets (PLAT), and erythrocyte concentrates (EC).

Results of the Emergency Obstetric Care (Remoc) that measure the consequences of the actions carried out in the RC process, which are the number of sequelae (NumS), the weight of the newborn (NW) in kilograms, and the weeks of gestation (GW).

### **5.2 Model specification**

In this example, it applies the function SEM of library lavaan, which uses the correlation matrix, *Cor.RC*, and the number of observations *N.RC*. The *fit.RC* object is created, where lavaan stores the results of our SEM.

```
### Model especification.
Sm.RC<-'.
FHS = BP1 + BF1 + HR1 + Tm1 + NC.
SHS = HR2 + Tm2 + BP2 + BF2.
OGH = PW + NVD + NumAb + NumCa.
Treat = PLAT + PLAS + EC.
Remoc = NumS + NW + GW.
#### Structural model.
FHS  OGH.
SHS  FHS.
Treat  OGH + FHS + SHS.
Remoc  Treat + OGH + FHS + SHS.
'
```


#### **Table 2.**

*Goodness of fit indices for the two SEMs.*
