use simulated_multilevel_data.dta // use data
3 Unconditional Model
An unconditional multilevel model is a model with no independent variables. One should always run an unconditional model as the first step of a multilevel model in order to get a sense of the way that variation is apportioned in the model across the different levels.
3.1 The Equation
\[\text{outcome}_{ij}= \beta_0 + u_{0j} + e_{ij} \tag{3.1}\]
The Intraclass Correlation Coefficient (ICC) is given by:
\[\text{ICC} = \frac{var(u_{0j})}{var(u_{0j}) + var(e_{ij})} \tag{3.2}\]
In a two level multilevel model, the ICC provides a measure of the amount of variation attributable to Level 2.
3.2 Run Models
// unconditional model
mixed outcome || country:
Performing EM optimization ...
Performing gradient-based optimization:
Iteration 0: Log likelihood = -9802.8371
Iteration 1: Log likelihood = -9802.8371
Computing standard errors ...
Mixed-effects ML regression Number of obs = 3,000
Group variable: country Number of groups = 30
Obs per group:
min = 100
avg = 100.0
max = 100
Wald chi2(0) = .
Log likelihood = -9802.8371 Prob > chi2 = .
------------------------------------------------------------------------------
outcome | Coefficient Std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
_cons | 52.43327 .3451217 151.93 0.000 51.75685 53.1097
------------------------------------------------------------------------------
------------------------------------------------------------------------------
Random-effects parameters | Estimate Std. err. [95% conf. interval]
-----------------------------+------------------------------------------------
country: Identity |
var(_cons) | 3.178658 .9226737 1.799552 5.614658
-----------------------------+------------------------------------------------
var(Residual) | 39.46106 1.024013 37.50421 41.52
------------------------------------------------------------------------------
LR test vs. linear model: chibar2(01) = 166.31 Prob >= chibar2 = 0.0000
estat icc // ICC
Intraclass correlation
------------------------------------------------------------------------------
Level | ICC Std. err. [95% conf. interval]
-----------------------------+------------------------------------------------
country | .0745469 .0201254 .0434963 .1248696
------------------------------------------------------------------------------
library(haven)
<- read_dta("simulated_multilevel_data.dta") df
library(lme4) # estimate multilevel models
<- lmer(outcome ~ (1 | country),
fit0 data = df) # unconditional model
summary(fit0)
Linear mixed model fit by REML ['lmerMod']
Formula: outcome ~ (1 | country)
Data: df
REML criterion at convergence: 19605.9
Scaled residuals:
Min 1Q Median 3Q Max
-3.3844 -0.6655 -0.0086 0.6725 3.6626
Random effects:
Groups Name Variance Std.Dev.
country (Intercept) 3.302 1.817
Residual 39.461 6.282
Number of obs: 3000, groups: country, 30
Fixed effects:
Estimate Std. Error t value
(Intercept) 52.433 0.351 149.4
library(performance)
::icc(fit0) # ICC performance
# Intraclass Correlation Coefficient
Adjusted ICC: 0.077
Unadjusted ICC: 0.077
using Tables, MixedModels, MixedModelsExtras,
StatFiles, DataFrames, CategoricalArrays, DataFramesMeta
= DataFrame(load("simulated_multilevel_data.dta")) df
@transform!(df, :country = categorical(:country))
= fit(MixedModel,
m0 @formula(outcome ~ (1 | country)), df) # unconditional model
Linear mixed model fit by maximum likelihood
outcome ~ 1 + (1 | country)
logLik -2 logLik AIC AICc BIC
-9802.8371 19605.6742 19611.6742 19611.6822 19629.6933
Variance components:
Column Variance Std.Dev.
country (Intercept) 3.17863 1.78287
Residual 39.46106 6.28180
Number of obs: 3000; levels of grouping factors: 30
Fixed-effects parameters:
──────────────────────────────────────────────────
Coef. Std. Error z Pr(>|z|)
──────────────────────────────────────────────────
(Intercept) 52.4333 0.345121 151.93 <1e-99
──────────────────────────────────────────────────
icc(m0) # ICC
0.07454637475695493
3.3 Interpretation
In each case, the software finds that nearly 8% of the variation in the outcome is explainable by the clustering of the observations in each country.