Sample statistics as input data

keywords SEM, covariances, correlations, lavaan, SEMLj, jamovi

1.3.0

In this example, we demonstrate how to use a variances-covariances matrix as input data of SEMLj. We show input of SEMLj syntax sub-module and interactive sub-module, with particular focus on the latter one. We focus more on the setup of the data, so the example would not be interpreted as for other cases.

The data

For this example, we use the Holzinger and Swineford dataset, which is included in the lavaan R package. The dataset contains nine variables measured on 331 participants. While the original dataset provides disaggregated data, for the purposes of this example we treat the data as if only sample estimates — such as covariances or correlations — were available, similar to what one might find in published articles or statistical reports.

We start with the case in which variances and covariances are available. The data containing the variances and covariances of the observed variables are in the file HS_covs_whole.csv.

The model

Assume we have three latent factors, F1, F2 and F3. Assume that each of these factors is measured by three observed variables:

  • F1: x11, x12, x13
  • F2: m11, m12, m13
  • F3: y11, y12, y13

Basically, we want to estimate the following model:

Interactive (GUI)

Let’s start with the interactive module. In Latent Endogenous Variables (aka factors) we name each factor and put the observed variables measuring it in the field beneath.

and we keep defining the factors with their indicators

until we have three of them. We can see in the Model Info output table that the factors are defined as intended.

Syntax

In the syntax sub-module we can define the three factors in terms of their indicators as follows

F1=~x11+x12+x13
F2=~m21+m22+m23
F3=~y31+y32+y33

We are not going to discuss the output of the syntax sub-module because it is identical to the interactive sub-module output.

Output

As soon as we set the input, we obtain the whole set of results tables. We do not go through the results in detail, but it is interesting to see the basic results

The overall tests are presented in the first three tables. We can use them to compare the results with jamovi CFA command results (see below).

As regards the measurement model table (factor loadings), it indicates the associations between the observed variables and the factors. We can notice that the first indicator of each factor shows a factor loading equal to 1. This is one of the possible ways of setting the latent variable scale. We’ll see that jamovi CFA has a different default, which can be changed to align the results to the ones obtained here (see below). In SEMLj, the scale option is in the Parameters Options panel.

As regards the variances and covariances, we can notice that the three factors are let to be correlated (see bottom part of the table). This happens because the default option in Variances and Covariances panel: Correlated -> Latent vars .

This is basically a CFA run in SEMLj. All options of the module are available, so one can start tweaking the model as required by the researcher interests and aims.

jamovi CFA

We can now check the results using jamovi CFA default command.

First, we setup the three factors as we did in SEMLj.

Then we scale the factor fixing the first indicator loading to 1.

Output

We can see that the results are exactly the same of the ones obtained with SEMLj.

The fit indices are the same:

the factor loadings (Estimates and standard errors) are the same:

and so are the variances and covariances among factors:

Note: Scaling Latent Variables

Scaling latent variables is necessary for the model to be identified, but the method one uses matters only in terms of convenience, because the actual model results are equivalent (apart from the scale of the latent variables). SEMLj default method is to set the first indicator loading equal to zero, whereas CFA default sets the variance of the latent variable equal to 1. If one to use the latter method in SEMLj, simply choose the Latent vars: Fix residual variances (to 1) option in Parameters Options panel.

Comments?

Got comments, issues or spotted a bug? Please open an issue on SEMLj at github or send me an email