Skip to content
Prev 19377 / 20628 Next

Time-dependent Negative binomial regression

Dear Amir,

Have a look at the lme4, glmmTMB or INLA packages. Note that if you need on
the fly transformations in the model you need to code them as
I(log(person.time)) instead of log(person.time). Personally, I prefer to
create a new variable in the data.frame and use that new variable in the
model.

Another thing is that you shouldn't use gender and baseline.age as random
effects. Either don't use them (as their effect is handled by the id random
effect) or add them as fixed effects.

library(lme4)
glmer.nb(event ~ offset(log_time) + treatment + gender + baseline.age +
(1|id), data = df)

Best regards,


ir. Thierry Onkelinx
Statisticus / Statistician

Vlaamse Overheid / Government of Flanders
INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND
FOREST
Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance
thierry.onkelinx at inbo.be
Havenlaan 88 bus 73, 1000 Brussel
www.inbo.be

///////////////////////////////////////////////////////////////////////////////////////////
To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey
///////////////////////////////////////////////////////////////////////////////////////////

<https://www.inbo.be>


Op do 8 jul. 2021 om 08:59 schreef <
Amirhossein.AmirhosseinTalebi at radboudumc.nl>: