# Structural equation modelling (/docs/analyses/structural-equation-modelling)



## When to use it [#when-to-use-it]

Use structural equation modelling when the claim is a set of paths, not only a measurement model. Factors are defined with `=~`. Regressions between factors or observed variables use `~`. A measurement-only model is [confirmatory factor analysis](/docs/analyses/confirmatory-factor-analysis).

## Assumptions [#assumptions]

Observed variables in the spec must be numeric columns. Rows with a missing value on those columns are dropped. Each factor needs enough indicators to be identified, and the first loading on a factor is fixed at 1. A model that is not identified, or that names a column that is not in the data, fails with an error rather than a blank table.

## Running it in Tensr [#running-it-in-tensr]

<Steps>
  <Step>
    Multivariate → SEM. In chat: “SEM with F2 predicted by F1.”
  </Step>

  <Step>
    Write the model, up to 8000 characters.
  </Step>

  <Step>
    Optionally list the columns. If you leave them out, Tensr reads observed names out of the spec.
  </Step>
</Steps>

## Options [#options]

<TypeTable
  type="{
  model_spec: {
    type: 'string',
    description: 'Model syntax, up to 8000 characters. Factors use =~. Regressions use ~.',
  },
  columns: {
    type: 'string[]',
    description: 'Observed columns. Optional when every observed name appears in the spec.',
    default: 'null',
  },
  decimal_places: {
    type: '0–6',
    description: 'Report output. Decimal places.',
    default: '3',
  },
  apa_format: {
    type: 'boolean',
    description: 'Report output. APA-style p-values.',
    default: 'true',
  },
  include_charts: {
    type: 'boolean',
    description: 'Report output. Shared chart switch. Includes the path diagram.',
    default: 'true',
  },
}"
/>

## Reading the output [#reading-the-output]

Focus measured by item1 to item3, then exam score predicted from Focus and study hours, on 96 people.

| To    | Op | From  |  Estimate | Std. Err | p-value   |
| ----- | -- | ----- | --------: | -------: | --------- |
| item1 | \~ | Focus |         1 |        — | —         |
| item2 | \~ | Focus |   1.38684 | 0.476729 | p = .004  |
| item3 | \~ | Focus |   1.40377 | 0.496276 | p = .005  |
| score | \~ | Focus | -0.309337 |  1.74098 | p = .859  |
| score | \~ | hours |   2.23996 | 0.655468 | p \< .001 |

Structural equation model with semopy fit indices. Structural equation model with semopy fit indices. Metrics: CFI = 1.036; RMSEA = 0; SRMR = 0.077.

## Reporting (APA 7) [#reporting-apa-7]

Structural equation model with semopy fit indices. Report the estimate in the table. This procedure is not summarised by one p-value.

## Coming from SPSS [#coming-from-spss]

The product menu is Multivariate → SEM. SPSS fits path models in Amos. `=~` defines a factor and `~` defines a regression, as in lavaan.
