Hey there!
I’m getting unexpected results using a 3x3 categorical interaction with cyclic cubic splines in brms.
I tried fitting a similar model in gamm4 and get different results (but had to remove some group-level varying intercepts to be able to fit it).
The brms model converged, as far as I can judge, but the difference to gamm4 and simple descriptive means (both ignoring some structure in the data, but that should not affect the shape, right?) just seems very stark. I’m now fitting a model in brms that is more comparable to the one in gamm4, but it will take a few days. In addition, I fit a spline-free model (using predicted conception risk which peaks in the middle of RCD_squished) and get the results I expect.
Questions
Anybody have an idea why the results may be so different / what I might be doing wrong / suggestions for steps to take to diagnose the problem?
Happy to explain the model/data more, if that helps.
Differences in specification
- cumulative instead of Gaussian
- allowing for disc to vary by contraception and woman
- varying intercepts for item, day:woman (woman=“short” in the model summary model), cycle_nr:woman
Priors
In retrospect, I’m not sure if I should have set a prior on the intercept (or whether it even applied in a cumulative model).
c(set_prior("normal(0,1)", class = "b"),
set_prior("normal(0,1)", class = "sd"),
set_prior("normal(0,1)", class = "Intercept")),
Differences in results
In the coloured graph (from brms) you can see, for example, the peak in the first column is totally shifted to the left compared to the gamm 4 fit (dashed lines).
Model summary
Family: cumulative
Links: mu = probit; disc = log
Formula: value ~ estrogen_progestogen * who + s(RCD_squished, by = interaction(estrogen_progestogen, who), bs = "cc") + (1 | short:created_diary) + (1 | short:cycle_nr) + (1 | short) + (1 + who | variable)
disc ~ estrogen_progestogen + (1 | short)
Data: diary_long (Number of observations: 128454)
Samples: 3 chains, each with iter = 4000; warmup = 2000; thin = 1;
total post-warmup samples = 6000
Smooth Terms:
Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
sds(sRCD_squishedinteractionestrogen_progestogenwhonon_hormonal.extra_pair_1) 0.10 0.04 0.05 0.20 1792 1.00
sds(sRCD_squishedinteractionestrogen_progestogenwhoprogestogen_and_estrogen.extra_pair_1) 0.05 0.02 0.02 0.11 2556 1.00
sds(sRCD_squishedinteractionestrogen_progestogenwhoprogestogen_only.extra_pair_1) 0.07 0.05 0.01 0.20 2478 1.00
sds(sRCD_squishedinteractionestrogen_progestogenwhonon_hormonal.in_pair_1) 0.06 0.03 0.03 0.13 1922 1.00
sds(sRCD_squishedinteractionestrogen_progestogenwhoprogestogen_and_estrogen.in_pair_1) 0.06 0.04 0.02 0.15 1432 1.00
sds(sRCD_squishedinteractionestrogen_progestogenwhoprogestogen_only.in_pair_1) 0.05 0.05 0.00 0.17 1786 1.00
sds(sRCD_squishedinteractionestrogen_progestogenwhonon_hormonal.single_1) 0.07 0.03 0.03 0.15 1680 1.00
sds(sRCD_squishedinteractionestrogen_progestogenwhoprogestogen_and_estrogen.single_1) 0.13 0.05 0.05 0.26 1850 1.00
sds(sRCD_squishedinteractionestrogen_progestogenwhoprogestogen_only.single_1) 0.09 0.08 0.01 0.31 1699 1.00
Group-Level Effects:
~short (Number of levels: 873)
Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
sd(Intercept) 0.97 0.14 0.70 1.26 999 1.00
sd(disc_Intercept) 0.46 0.01 0.43 0.48 1105 1.00
~short:created_diary (Number of levels: 37895)
Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
sd(Intercept) 0.90 0.13 0.65 1.17 958 1.00
~short:cycle_nr (Number of levels: 2107)
Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
sd(Intercept) 0.40 0.06 0.29 0.52 877 1.00
~variable (Number of levels: 7)
Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
sd(Intercept) 0.71 0.31 0.32 1.53 1665 1.00
sd(whoin_pair) 0.67 0.28 0.30 1.39 2747 1.00
sd(whosingle) 0.53 0.21 0.26 1.05 2035 1.00
cor(Intercept,whoin_pair) 0.07 0.36 -0.64 0.71 3279 1.00
cor(Intercept,whosingle) -0.45 0.31 -0.89 0.29 3927 1.00
cor(whoin_pair,whosingle) 0.09 0.38 -0.64 0.75 2939 1.00
Population-Level Effects:
Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
Intercept[1] 0.74 0.32 -0.04 1.26 1891 1.00
Intercept[2] 1.61 0.35 0.87 2.25 2032 1.00
Intercept[3] 2.70 0.43 1.87 3.57 1748 1.00
Intercept[4] 4.05 0.58 2.94 5.22 1224 1.00
disc_Intercept -0.47 0.15 -0.74 -0.16 966 1.00
estrogen_progestogenprogestogen_and_estrogen -0.58 0.13 -0.85 -0.35 1057 1.00
estrogen_progestogenprogestogen_only -0.06 0.30 -0.64 0.55 2211 1.00
whoin_pair 2.68 0.47 1.77 3.63 1480 1.00
whosingle 1.65 0.31 1.05 2.28 1942 1.00
estrogen_progestogenprogestogen_and_estrogen:whoin_pair 0.77 0.12 0.55 1.01 1024 1.00
estrogen_progestogenprogestogen_only:whoin_pair 0.45 0.11 0.25 0.68 2191 1.00
estrogen_progestogenprogestogen_and_estrogen:whosingle 0.41 0.19 0.06 0.80 1406 1.00
estrogen_progestogenprogestogen_only:whosingle 0.54 0.53 -0.50 1.58 3256 1.00
disc_estrogen_progestogenprogestogen_and_estrogen 0.11 0.04 0.03 0.17 622 1.00
disc_estrogen_progestogenprogestogen_only 0.14 0.12 -0.10 0.37 1370 1.00
Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample
is a crude measure of effective sample size, and Rhat is the potential
scale reduction factor on split chains (at convergence, Rhat = 1).
Warning message:
There were 3 divergent transitions after warmup. Increasing adapt_delta above 0.9 may help.
See http://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
- Operating System: Ubuntu 16.04.5 LTS (R 3.5.2)
- brms Version: 2.7.0