[R-sig-ME] glmmTMB syntax to brm() syntax
Ben Bolker
bbo|ker @end|ng |rom gm@||@com
Mon Oct 28 18:10:22 CET 2024
That's quite old, by R standards (1.1.8 came out a year ago, latest
version is 1.1.10 -- there's a note in the NEWS for 1.1.10
<https://cran.r-project.org/web/packages/glmmTMB/news.html> about fixing
a simulate bug for the beta family
(It's simulate_new(), not new_simulate())
The docs say "(‘beta’, ‘betazi’, ‘betadisp’, ‘theta’, etc.)"; in this
case "etc." includes thetazi (random-effects parameters for ZI terms, if
any) and thetadisp (ditto, dispersion terms).
The 'covstruct' vignette is the best place to read about
parameterization of random-effects components.
On 2024-10-28 1:05 p.m., Simon Harmel wrote:
> Ben, when I run your code below, I get the following error message: y
> values must be 0 <= y < 1. My glmmTMB version is: ‘1.1.7’.
>
> Also, is there any good documentation explaining all possible names
> used in argument `newparams=` in glmmTMB::new_simulate()?
>
> Thank you!
> Simon
>
> On Thu, Oct 24, 2024 at 11:11 AM Ben Bolker <bbolker using gmail.com> wrote:
>>
>> See below. The two models (glmmTMB and brms) give sufficiently
>> similar estimates that I'm confident that the specifications match.
>>
>> set.seed(101)
>> library(glmmTMB)
>> library(brms)
>> library(broom.mixed)
>> library(tidyverse)
>>
>> dd <- data.frame(ID = rep(1:100, each = 10),
>> TRIAL_INDEX = rep(1:10, 100),
>> con = rnorm(1000))
>> dd$pic_percent <- simulate_new(
>> ~ con + (0+con | ID) +
>> (0+con | TRIAL_INDEX),
>> ziformula = ~1,
>> family = beta_family(),
>> newdata = dd,
>> newparams = list(beta = c(0, 0.5), theta = rep(-1,2),
>> betadisp = 1, betazi = -2))[[1]]
>>
>>
>> m1 <- glmmTMB(pic_percent ~ con + (0+con | ID) +
>> (0+con | TRIAL_INDEX),
>> data=dd,
>> family = beta_family(),
>> ziformula = ~1)
>>
>> ##
>> https://mvuorre.github.io/posts/2019-02-18-analyze-analog-scale-ratings-with-zero-one-inflated-beta-models/
>> m2 <- brm(
>> bf(pic_percent ~ con + (0+con | ID) +
>> (0+con | TRIAL_INDEX),
>> zi = ~ 1),
>> data=dd,
>> family = zero_inflated_beta()
>> )
>>
>>
>> (purrr::map_dfr(list(glmmTMB = m1, brms = m2), tidy, .id = "model")
>> |> select(model, effect, component, group, term, estimate)
>> |> pivot_wider(names_from = model, values_from = estimate)
>> )
>>
>>
>>
>> On 10/23/24 19:13, Simon Harmel wrote:
>>> Hello all,
>>>
>>> I was wondering what is the closest equivalent of my glmmTMB syntax below
>>> in brms::brm() syntax?
>>>
>>> glmmTMBglmmTMB(pic_percent ~ con +
>>> (0+con | ID) +
>>> (0+con | TRIAL_INDEX),
>>> data=DATA,
>>> family = beta_family(),
>>> ziformula = ~1)
>>>
>>>
>>> Thank you,
>>>
>>> Simon
>>>
>>> [[alternative HTML version deleted]]
>>>
>>> _______________________________________________
>>> R-sig-mixed-models using r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>>
>> --
>> Dr. Benjamin Bolker
>> Professor, Mathematics & Statistics and Biology, McMaster University
>> Director, School of Computational Science and Engineering
>> * E-mail is sent at my convenience; I don't expect replies outside of
>> working hours.
>>
>> _______________________________________________
>> R-sig-mixed-models using r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
--
Dr. Benjamin Bolker
Professor, Mathematics & Statistics and Biology, McMaster University
Director, School of Computational Science and Engineering
> E-mail is sent at my convenience; I don't expect replies outside of
working hours.
More information about the R-sig-mixed-models
mailing list