# Multilevel modelling (/docs/analyses/multilevel-modelling)



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

Use multilevel modelling when a numeric outcome sits inside groups and you want the intraclass correlation as well as the slopes. The ICC is the share of score variance that sits between groups. A high ICC means people in the same clinic resemble each other.

This procedure fits the same REML mixed model as the [linear mixed model](/docs/analyses/linear-mixed-model). The request uses different field names, and the report adds the ICC and a variance split.

## Assumptions [#assumptions]

The outcome and the level-1 predictors are numeric. The level-2 column has at least two groups. This fit uses REML and a random intercept. It does not test residual normality.

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

<Steps>
  <Step>
    Multivariate → Mixed Models → Multilevel Modelling (HLM). In chat: “Multilevel model of score on hours, with clinic as level 2.”
  </Step>

  <Step>
    Outcome is the level-1 score. Level-1 predictors need at least one column. Level-2 grouping variable is the cluster.
  </Step>
</Steps>

## Options [#options]

<TypeTable
  type="{
  outcome_column: {
    type: 'string',
    description: 'Numeric level-1 outcome.',
  },
  level1_predictors: {
    type: 'string[]',
    description: 'Numeric predictors measured on the people. At least one.',
  },
  level2_group_column: {
    type: 'string',
    description: 'Cluster id, such as clinic or school.',
  },
  random_slopes: {
    type: 'string[]',
    description:
      'Optional. Each column must also be a level-1 predictor. The dialog does not send this, so a dialog run is a random intercept only.',
  },
  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. Fitted-versus-residual scatter and a random-intercept bar chart.',
    default: 'true',
  },
}"
/>

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

The same linear mixed model, reported with the intraclass correlation and the split of variance between clinic and residual.

| Term  | Estimate | Std. Err | p-value   |
| ----- | -------: | -------: | --------- |
| const |  45.7742 |  2.35335 | p \< .001 |
| hours | 0.973909 | 0.393446 | p = .013  |

| Level             | Variance | % of total |
| ----------------- | -------: | ---------: |
| Between clinic    |  18.6857 |     47.07% |
| Within (residual) |  21.0128 |     52.93% |

Multilevel model for `score`, ICC = 0.471. Multilevel model for `score`, ICC = 0.471. Metrics: ICC = 0.471; Observations = 120; Groups = 12.

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

Multilevel model for `score`, ICC = 0.471. 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 → Mixed Models → Multilevel Modelling (HLM). SPSS fits this with MIXED. The ICC is the ratio of the random-intercept variance to the total variance.

## Related [#related]

The coefficient table without the ICC is the [linear mixed model](/docs/analyses/linear-mixed-model). A null-model ICC, z, and a confidence interval are on [Mixed Model](/docs/analyses/mixed-model).
