I run a brms model like the following code. It was a multi-level negative binomial model. I was wondering where to find or how to calculate the value of ICC/VPC of this model.
model<- brm(value ~ hour * period + offset(log(n)) + (1 | id),
family=negbinomial(),
data = data,
cores=2,chains = 2,
backend="cmdstanr",
threads=threading((4)),
seed=22323)
I had tried the “variance_decomposition()” of “performance” package. But it gave me some negative values. See the results:
variance_decomposition(model)
# Random Effect Variances and ICC
Conditioned on: all random effects
## Variance Ratio (comparable to ICC)
Ratio: -0.03 CI 95%: [-0.24 0.12]
## Variances of Posterior Predicted Distribution
Conditioned on fixed effects: 1.24 CI 95%: [1.10 1.42]
Conditioned on rand. effects: 1.20 CI 95%: [1.05 1.37]
## Difference in Variances
Difference: -0.04 CI 95%: [-0.27 0.16]
Here are the results of model got from the “summary()”:
Family: negbinomial
Links: mu = log; shape = identity
Formula: value ~ hour * period + offset(log(n)) + (1 | id)
Data: data (Number of observations: 78960)
Samples: 2 chains, each with iter = 2000; warmup = 1000; thin = 1;
total post-warmup samples = 2000
Group-Level Effects:
~id (Number of levels: 50)
Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
sd(Intercept) 0.03 0.02 0.00 0.06 1.00 911 996
Population-Level Effects:
Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
Intercept -3.01 0.08 -3.16 -2.85 1.01 288 664
hour1 -0.88 0.13 -1.13 -0.63 1.00 597 924
hour2 -1.81 0.17 -2.14 -1.49 1.00 1015 1323
hour3 -3.23 0.29 -3.82 -2.72 1.00 1631 1189
hour4 -3.10 0.27 -3.68 -2.59 1.00 1995 1415
hour5 -2.44 0.20 -2.84 -2.04 1.00 1470 1282
hour6 -1.09 0.14 -1.37 -0.83 1.00 779 1043
hour7 -0.45 0.12 -0.68 -0.21 1.00 478 812
hour8 -0.17 0.11 -0.40 0.05 1.01 585 1100
hour9 0.05 0.11 -0.17 0.26 1.00 491 789
hour10 -0.30 0.12 -0.53 -0.07 1.00 662 1075
hour11 -0.07 0.11 -0.28 0.14 1.00 481 986
hour12 0.11 0.11 -0.10 0.32 1.01 477 872
hour13 -0.07 0.11 -0.30 0.16 1.00 606 897
hour14 -0.33 0.12 -0.56 -0.11 1.00 498 1090
hour15 -0.17 0.12 -0.41 0.05 1.00 514 1094
hour16 -0.06 0.11 -0.28 0.14 1.00 440 939
hour17 0.34 0.10 0.14 0.54 1.01 444 1037
hour18 0.31 0.10 0.11 0.51 1.00 404 969
hour19 0.10 0.11 -0.12 0.30 1.00 487 886
hour20 0.12 0.11 -0.09 0.34 1.00 459 966
hour21 0.27 0.11 0.06 0.48 1.00 459 1005
hour22 0.39 0.10 0.18 0.58 1.00 456 772
hour23 0.41 0.11 0.20 0.60 1.01 550 739
period2 0.10 0.11 -0.12 0.31 1.01 278 559
hour1:period2 0.13 0.17 -0.20 0.46 1.01 501 1105
hour2:period2 0.58 0.21 0.19 1.01 1.00 935 1336
hour3:period2 1.46 0.32 0.86 2.09 1.00 1315 1366
hour4:period2 0.59 0.32 -0.01 1.21 1.00 1700 1335
hour5:period2 0.40 0.26 -0.09 0.91 1.00 1181 1295
hour6:period2 -0.24 0.19 -0.60 0.14 1.00 784 1169
hour7:period2 -0.36 0.16 -0.67 -0.01 1.00 546 1051
hour8:period2 -0.46 0.16 -0.76 -0.16 1.00 568 936
hour9:period2 -0.30 0.15 -0.59 -0.00 1.00 491 807
hour10:period2 0.03 0.16 -0.29 0.33 1.00 562 961
hour11:period2 -0.15 0.15 -0.44 0.14 1.00 516 831
hour12:period2 -0.30 0.15 -0.61 -0.00 1.00 524 1073
hour13:period2 -0.03 0.15 -0.33 0.27 1.00 506 842
hour14:period2 0.27 0.15 -0.04 0.58 1.00 476 997
hour15:period2 0.09 0.15 -0.21 0.40 1.00 491 739
hour16:period2 0.03 0.15 -0.27 0.32 1.01 448 558
hour17:period2 -0.37 0.14 -0.65 -0.09 1.00 438 1030
hour18:period2 -0.29 0.14 -0.55 -0.02 1.01 403 993
hour19:period2 -0.05 0.15 -0.33 0.23 1.00 471 835
hour20:period2 -0.09 0.15 -0.37 0.21 1.00 442 792
hour21:period2 -0.09 0.14 -0.37 0.19 1.01 435 813
hour22:period2 -0.08 0.14 -0.35 0.21 1.00 428 692
hour23:period2 -0.16 0.14 -0.44 0.12 1.01 417 1058
Family Specific Parameters:
Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
shape 0.33 0.01 0.32 0.34 1.00 4793 1480
Samples were drawn using sample(hmc). For each parameter, Bulk_ESS
and Tail_ESS are effective sample size measures, and Rhat is the potential
scale reduction factor on split chains (at convergence, Rhat = 1).
Looking forward to some advice! Many thanks!
Best,
Jacob
- Operating System: win10
- brms Version: 2.15.9