Сила влияния социально-экономических факторов (ВВП на душу населения) на удовлетворенность жизнью варьируется между странами, и эту вариативность можно объяснить различиями в уровне политического доверия и качестве государственного управления.
Рассмотрим данные и их тип перед началом анализа
## 'data.frame': 40808 obs. of 25 variables:
## $ name : chr "ESS11e03" "ESS11e03" "ESS11e03" "ESS11e03" ...
## $ essround: int 11 11 11 11 11 11 11 11 11 11 ...
## $ edition : int 3 3 3 3 3 3 3 3 3 3 ...
## $ proddate: chr "02.06.2025" "02.06.2025" "02.06.2025" "02.06.2025" ...
## $ idno : int 50014 50030 50057 50106 50145 50158 50212 50213 50235 50236 ...
## $ cntry : chr "Austria" "Austria" "Austria" "Austria" ...
## $ GDP : num 5.12e+11 5.12e+11 5.12e+11 5.12e+11 5.12e+11 ...
## $ HDI : chr "0,93" "0,93" "0,93" "0,93" ...
## $ dweight : chr "1,1851145" "0,6098981" "1,3923296" "0,5560615" ...
## $ pspwght : chr "0,39289063" "0,32515332" "4,0000234" "0,17622764" ...
## $ pweight : chr "0,33091453" "0,33091453" "0,33091453" "0,33091453" ...
## $ anweight: chr "0,13001321" "0,107597955" "1,3236659" "0,058316287" ...
## $ trstplc : int 10 4 8 9 8 7 9 8 10 8 ...
## $ vote : int 1 1 1 2 1 1 1 1 1 1 ...
## $ stflife : int 8 9 10 7 9 8 8 8 8 8 ...
## $ stfeco : int 6 2 6 4 6 4 6 6 7 6 ...
## $ stfgov : int 4 5 5 4 7 2 6 5 8 6 ...
## $ stfedu : int 8 10 5 5 9 3 6 9 8 6 ...
## $ stfhlth : int 8 10 8 2 9 7 7 9 9 6 ...
## $ gndr : int 1 2 2 2 1 2 2 2 2 2 ...
## $ agea : int 65 21 53 78 64 59 69 52 75 44 ...
## $ edulvlb : num 2 3 3 3 2 2 3 3 2 3 ...
## $ prob : chr "0,000578648" "0,001124391" "0,00049253" "0,001233252" ...
## $ stratum : int 107 69 18 101 115 7 38 62 105 26 ...
## $ psu : int 317 128 418 295 344 373 3 108 314 622 ...
m0 <- lmer(stflife ~ 1 + (1 | cntry), data = data)
summary(m0)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: stflife ~ 1 + (1 | cntry)
## Data: data
##
## REML criterion at convergence: 169652.7
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -4.2217 -0.4661 0.1385 0.6564 2.0288
##
## Random effects:
## Groups Name Variance Std.Dev.
## cntry (Intercept) 0.3826 0.6185
## Residual 3.7286 1.9310
## Number of obs: 40808, groups: cntry, 28
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 7.1580 0.1173 26.9990 61.01 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
performance::icc(m0)
## # Intraclass Correlation Coefficient
##
## Adjusted ICC: 0.093
## Unadjusted ICC: 0.093
# Построим регрессию
model1 <- lmer(stflife ~ GDP_scaled + stfedu + stfgov + (1 | cntry), data = data)
# Смотрим на результаты модели
summary(model1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: stflife ~ GDP_scaled + stfedu + stfgov + (1 | cntry)
## Data: data
##
## REML criterion at convergence: 167489.6
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -4.7841 -0.5194 0.1252 0.6553 2.6001
##
## Random effects:
## Groups Name Variance Std.Dev.
## cntry (Intercept) 0.2159 0.4646
## Residual 3.5357 1.8803
## Number of obs: 40808, groups: cntry, 28
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 6.179e+00 9.235e-02 2.966e+01 66.906 <2e-16 ***
## GDP_scaled 2.334e-01 8.749e-02 2.597e+01 2.667 0.013 *
## stfedu 8.744e-02 4.725e-03 4.068e+04 18.505 <2e-16 ***
## stfgov 1.339e-01 4.262e-03 4.080e+04 31.417 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDP_sc stfedu
## GDP_scaled 0.140
## stfedu -0.189 -0.009
## stfgov -0.075 0.002 -0.429
# FSRI model -----------------------------------------
# Случайный эффект (1|cntr) — учитывает вариацию intercept (среднего уровня) по странам
model_2 <- lmer(stflife ~ GDP_scaled * trstplc + GDP_scaled * stfgov + (1 + GDP_scaled | cntry), data = data)
## boundary (singular) fit: see help('isSingular')
## Warning: Model failed to converge with 1 negative eigenvalue: -1.1e+01
# случайные элементы и взаимодействие
summary(model_2)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## stflife ~ GDP_scaled * trstplc + GDP_scaled * stfgov + (1 + GDP_scaled |
## cntry)
## Data: data
##
## REML criterion at convergence: 166766.4
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -4.6237 -0.5194 0.1166 0.6503 2.6891
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## cntry (Intercept) 0.000 0.000
## GDP_scaled 1.168 1.081 NaN
## Residual 3.470 1.863
## Number of obs: 40808, groups: cntry, 28
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 5.892e+00 7.721e-02 1.382e+01 76.308 <2e-16 ***
## GDP_scaled 5.273e-01 2.093e-01 1.196e+01 2.519 0.0270 *
## trstplc 1.437e-01 4.290e-03 3.880e+04 33.506 <2e-16 ***
## stfgov 1.206e-01 4.079e-03 4.075e+04 29.559 <2e-16 ***
## GDP_scaled:trstplc 8.570e-03 4.284e-03 4.079e+04 2.000 0.0455 *
## GDP_scaled:stfgov 8.389e-03 4.019e-03 4.079e+04 2.087 0.0369 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDP_sc trstpl stfgov GDP_scld:t
## GDP_scaled -0.102
## trstplc -0.299 -0.010
## stfgov -0.096 -0.012 -0.348
## GDP_scld:tr -0.031 -0.103 0.070 0.015
## GDP_scld:st -0.015 -0.036 0.015 0.029 -0.335
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
fixef(model_2)
## (Intercept) GDP_scaled trstplc stfgov
## 5.891555891 0.527290114 0.143739222 0.120559351
## GDP_scaled:trstplc GDP_scaled:stfgov
## 0.008569697 0.008389481
ranef(model_2)
## $cntry
## (Intercept) GDP_scaled
## Austria 0 1.54917185
## Belgium 0 -0.03382683
## Bulgaria 0 0.25805294
## Croatia 0 -0.77341385
## Cyprus 0 -0.17150041
## Finland 0 -2.33230364
## France 0 -0.97969886
## Germany 0 -0.43274713
## Greece 0 1.91311094
## Hungary 0 1.30813829
## Iceland 0 -0.86175816
## Ireland 0 -0.87570787
## Israel 0 0.25306569
## Italy 0 -1.14814738
## Latvia 0 -0.14858211
## Lithuania 0 -0.37132953
## Montenegro 0 -0.17223777
## Netherlands 0 -0.02491341
## Norway 0 0.72243592
## Poland 0 -0.09933659
## Portugal 0 2.92689749
## Serbia 0 -0.21153265
## Slovakia 0 0.62751533
## Slovenia 0 -0.82986045
## Spain 0 -0.46851401
## Sweden 0 0.91195307
## Switzerland 0 0.11736861
## United Kingdom 0 -0.65229951
##
## with conditional variances for "cntry"
coef(model_2)
## $cntry
## (Intercept) GDP_scaled trstplc stfgov GDP_scaled:trstplc
## Austria 5.891556 2.07646196 0.1437392 0.1205594 0.008569697
## Belgium 5.891556 0.49346329 0.1437392 0.1205594 0.008569697
## Bulgaria 5.891556 0.78534305 0.1437392 0.1205594 0.008569697
## Croatia 5.891556 -0.24612374 0.1437392 0.1205594 0.008569697
## Cyprus 5.891556 0.35578971 0.1437392 0.1205594 0.008569697
## Finland 5.891556 -1.80501352 0.1437392 0.1205594 0.008569697
## France 5.891556 -0.45240874 0.1437392 0.1205594 0.008569697
## Germany 5.891556 0.09454299 0.1437392 0.1205594 0.008569697
## Greece 5.891556 2.44040106 0.1437392 0.1205594 0.008569697
## Hungary 5.891556 1.83542840 0.1437392 0.1205594 0.008569697
## Iceland 5.891556 -0.33446805 0.1437392 0.1205594 0.008569697
## Ireland 5.891556 -0.34841775 0.1437392 0.1205594 0.008569697
## Israel 5.891556 0.78035581 0.1437392 0.1205594 0.008569697
## Italy 5.891556 -0.62085727 0.1437392 0.1205594 0.008569697
## Latvia 5.891556 0.37870800 0.1437392 0.1205594 0.008569697
## Lithuania 5.891556 0.15596059 0.1437392 0.1205594 0.008569697
## Montenegro 5.891556 0.35505235 0.1437392 0.1205594 0.008569697
## Netherlands 5.891556 0.50237670 0.1437392 0.1205594 0.008569697
## Norway 5.891556 1.24972603 0.1437392 0.1205594 0.008569697
## Poland 5.891556 0.42795353 0.1437392 0.1205594 0.008569697
## Portugal 5.891556 3.45418760 0.1437392 0.1205594 0.008569697
## Serbia 5.891556 0.31575746 0.1437392 0.1205594 0.008569697
## Slovakia 5.891556 1.15480545 0.1437392 0.1205594 0.008569697
## Slovenia 5.891556 -0.30257033 0.1437392 0.1205594 0.008569697
## Spain 5.891556 0.05877611 0.1437392 0.1205594 0.008569697
## Sweden 5.891556 1.43924318 0.1437392 0.1205594 0.008569697
## Switzerland 5.891556 0.64465872 0.1437392 0.1205594 0.008569697
## United Kingdom 5.891556 -0.12500940 0.1437392 0.1205594 0.008569697
## GDP_scaled:stfgov
## Austria 0.008389481
## Belgium 0.008389481
## Bulgaria 0.008389481
## Croatia 0.008389481
## Cyprus 0.008389481
## Finland 0.008389481
## France 0.008389481
## Germany 0.008389481
## Greece 0.008389481
## Hungary 0.008389481
## Iceland 0.008389481
## Ireland 0.008389481
## Israel 0.008389481
## Italy 0.008389481
## Latvia 0.008389481
## Lithuania 0.008389481
## Montenegro 0.008389481
## Netherlands 0.008389481
## Norway 0.008389481
## Poland 0.008389481
## Portugal 0.008389481
## Serbia 0.008389481
## Slovakia 0.008389481
## Slovenia 0.008389481
## Spain 0.008389481
## Sweden 0.008389481
## Switzerland 0.008389481
## United Kingdom 0.008389481
##
## attr(,"class")
## [1] "coef.mer"
# График взаимодействия GDP_scaled * trstplc
plot_model(model_2,
type = "pred",
terms = c("GDP_scaled", "trstplc [mean, +1SD, -1SD]"),
title = "Interaction between GDP and police confidence",
axis.title = c("GDP (standardized)", "Satisfaction with life"),
colors = "Set1")
# График взаимодействия GDP_scaled * stfgov
plot_model(model_2,
type = "pred",
terms = c("GDP_scaled", "stfgov [mean, +1SD, -1SD]"),
title = "Interaction of GDP and trust in government",
axis.title = c("GDP (standardized)", "Satisfaction with life"),
colors = "Set2")
# График фиксированных эффектов
plot_model(model_2,
show.values = TRUE,
value.offset = 0.3,
title = "Model coefficients",
axis.labels = c("GDP:Trust in government",
"GDP:Trust in the police",
"Trust in government",
"Trust in the police",
"GDP"))
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: stflife ~ GDP_scaled + (1 + GDP_scaled | cntry)
## Data: data
##
## REML criterion at convergence: 169650
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -4.2214 -0.4664 0.1375 0.6554 2.0311
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## cntry (Intercept) 0.30842 0.5554
## GDP_scaled 0.01577 0.1256 -0.17
## Residual 3.72857 1.9310
## Number of obs: 40808, groups: cntry, 28
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 7.2011 0.1084 24.8229 66.446 <2e-16 ***
## GDP_scaled 0.2429 0.1115 8.8650 2.178 0.0578 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## GDP_scaled 0.063
## (Intercept) GDP_scaled
## 7.2010577 0.2429397
## $cntry
## (Intercept) GDP_scaled
## Austria 0.61771064 -0.0177837108
## Belgium 0.28787339 -0.0061058191
## Bulgaria -0.69998876 0.0554375810
## Croatia 0.25936926 -0.0220460491
## Cyprus -0.32920003 0.0367548891
## Finland 0.79507061 -0.0369225269
## France -0.72605879 -0.0233320191
## Germany 0.07655370 0.0035484749
## Greece -0.67505888 0.0354762184
## Hungary -0.51691192 0.0293775216
## Iceland 0.85499676 -0.0973771968
## Ireland 0.10826503 -0.0028526776
## Israel -0.04563376 0.0013081943
## Italy -0.73043183 -0.0161598240
## Latvia -0.36955996 0.0389195063
## Lithuania 0.15387977 -0.0133368589
## Montenegro -0.36471848 0.0558668296
## Netherlands 0.52583918 -0.0009051005
## Norway 0.55018157 -0.0167872887
## Poland 0.11556129 -0.0015806047
## Portugal -0.59159889 0.0278852018
## Serbia -0.16830494 0.0144904995
## Slovakia -0.67683258 0.0482551755
## Slovenia 0.57138311 -0.0519482366
## Spain 0.04493990 0.0004444429
## Sweden 0.59416110 -0.0145052015
## Switzerland 0.82259357 -0.0087907602
## United Kingdom -0.48408006 -0.0173306605
##
## with conditional variances for "cntry"
## $cntry
## (Intercept) GDP_scaled
## Austria 7.818768 0.2251560
## Belgium 7.488931 0.2368339
## Bulgaria 6.501069 0.2983773
## Croatia 7.460427 0.2208936
## Cyprus 6.871858 0.2796946
## Finland 7.996128 0.2060172
## France 6.474999 0.2196077
## Germany 7.277611 0.2464882
## Greece 6.525999 0.2784159
## Hungary 6.684146 0.2723172
## Iceland 8.056054 0.1455625
## Ireland 7.309323 0.2400870
## Israel 7.155424 0.2442479
## Italy 6.470626 0.2267799
## Latvia 6.831498 0.2818592
## Lithuania 7.354937 0.2296028
## Montenegro 6.836339 0.2988065
## Netherlands 7.726897 0.2420346
## Norway 7.751239 0.2261524
## Poland 7.316619 0.2413591
## Portugal 6.609459 0.2708249
## Serbia 7.032753 0.2574302
## Slovakia 6.524225 0.2911949
## Slovenia 7.772441 0.1909914
## Spain 7.245998 0.2433841
## Sweden 7.795219 0.2284345
## Switzerland 8.023651 0.2341489
## United Kingdom 6.716978 0.2256090
##
## attr(,"class")
## [1] "coef.mer"
## Data points may overlap. Use the `jitter` argument to add some amount of
## random variation to the location of data points and avoid overplotting.
anova(model1, model_2, model_3) # вторая лучше
## refitting model(s) with ML (instead of REML)
## Data: data
## Models:
## model1: stflife ~ GDP_scaled + stfedu + stfgov + (1 | cntry)
## model_3: stflife ~ GDP_scaled + (1 + GDP_scaled | cntry)
## model_2: stflife ~ GDP_scaled * trstplc + GDP_scaled * stfgov + (1 + GDP_scaled | cntry)
## npar AIC BIC logLik -2*log(L) Chisq Df Pr(>Chisq)
## model1 6 167477 167529 -83733 167465
## model_3 6 169657 169708 -84822 169645 0.0 0
## model_2 10 166745 166831 -83362 166725 2919.9 4 < 2.2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1