Message-ID: <6F9EE5B2-13CC-4A1C-B064-557A83794527@gmail.com>
Date: 2024-03-27T11:13:45Z
From: Mollie Brooks
Subject: GLMM: Should Integers be Levels of Dr. Alexandre F. Souza Prof. Associado a Factor?
In-Reply-To: <CAFXQFgNGrR6s6NYwzhz8fRTQ0ibo8Edm3okXuVMYc9VWHFC9vg@mail.gmail.com>
Dear Alexandre,
Making those changes shouldn?t be necessary with the GLMM packages I?m familiar with (lme4 and glmmTMB). Your data looks correct as it is, assuming you will treat plot numbers, block levels,
sampling year and the ID of individual measured plants as random intercepts, e.g. the formula contains (1|plot)+(1|block) + (1|year)+(1|ID) . The package will automatically interpret the values of those variables as levels of the random effects.
An exception is if you were to treat year as an AR(1) random effect. Then you would need to follow the example here
https://cran.r-project.org/web/packages/glmmTMB/vignettes/covstruct.html
Best,
Mollie
> On 27 Mar 2024, at 00.54, Alexandre F. Souza <alexsouza.cb.ufrn.br at gmail.com> wrote:
>
> Hello all,
>
> Judging by some sources, it seems to me that before running a GLMM I should
> make all categorical variables into factors, including numerical ones that
> are integers like binary response variables, plot numbers, block levels,
> sampling year and the ID of individual measured plants, even if these
> variables are correctly identified as integers as in the example below. Is
> this understanding correct in your opinion?
>
> Thank you very much for any reply,
>
> Alexandre
>
>
>> str(dados)
> 'data.frame': 1428 obs. of 12 variables:
> $ numero : int 4006 4009 4010 4020 4022 4024 4025 4027
> 4035 4036 ...
> $ bloco : int 1 1 1 1 1 1 1 1 1 1 ...
> $ transecto : int 1 1 1 1 1 1 1 1 1 1 ...
> $ parcela : int 1 1 1 1 1 1 1 1 1 1 ...
> $ Tree_Height_m_Fuste_Parc: num 8.32 8.32 8.32 8.32 8.32 ...
> $ Grupos_Finais : Factor w/ 3 levels "Disturbed Unflooded
> Forests",..: 1 1 1 1 1 1 1 1 1 1 ...
> $ ano_medida : int 2016 2016 2016 2016 2016 2016 2016 2016
> 2016 2016 ...
> $ Basal_Area_m2 : num 0.182 0.182 0.182 0.182 0.182 ...
> $ das_mm : num 185 161 167 114 164 ...
> $ reproducao : int 3 0 0 0 0 0 0 0 0 0 ...
> $ reproducao_bin : int 1 0 0 0 0 0 0 0 0 0 ...
> $ R_dens_total : int 31 31 31 31 31 31 31 31 31 31 ...
>
> --
> Dr. Alexandre F. Souza
> Professor Associado
> Chefe do Departamento de Ecologia
> Universidade Federal do Rio Grande do Norte
> CB, Departamento de Ecologia
> Campus Universit?rio - Lagoa Nova
> 59072-970 - Natal, RN - Brasil
> lattes: lattes.cnpq.br/7844758818522706
> http://www.esferacientifica.com.br
> https://www.youtube.com/user/alexfadigas
> http://www.docente.ufrn.br/alexsouza
> orcid.org/0000-0001-7468-3631 <http://www.docente.ufrn.br/alexsouza>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
[[alternative HTML version deleted]]