[R-sig-ME] Comparing mixed models

John Fox j|ox @end|ng |rom mcm@@ter@c@
Wed Jun 19 17:20:07 CEST 2024


Dear Carlos,

On 2024-06-19 11:13 a.m., Carlos Barboza wrote:
> 	
> You don't often get email from carlosambarboza using gmail.com. Learn why this 
> is important <https://aka.ms/LearnAboutSenderIdentification>
> 	
> 
> 	
> Caution: External email.
> 
> 
> Thank you Jonh for you answer
> I indeed used contr.sum, contr.poly before to model definition
> after that I get the same results using any names for the same factors
> but, what do you exactly mean when testing for factors for differences 
> over the origin?

The context here is models with both numeric and factor predictors. 
Consider a model of the form y ~ x*f, where x is numeric and f is a 
factor. A type-III test for the "main effect" of f tests for differences 
among factor levels where x = 0 (the origin).

More generally, the issues concerning "types" of tests in models with 
linear predictors are sufficiently complicated that discussing them in a 
help file or by email is likely to prove unsatisfactory. See the first 
two references in ?Anova for more details.

I hope this helps,
  John

> best regards
> Carlos
> 
> 
> Em qua., 19 de jun. de 2024 às 10:14, John Fox <jfox using mcmaster.ca 
> <mailto:jfox using mcmaster.ca>> escreveu:
> 
>     Dear Carlos,
> 
>       From ?Anova:
> 
>     "Warning
> 
>     Be careful of type-III tests: For a traditional multifactor ANOVA model
>     with interactions, for example, these tests will normally only be
>     sensible when using contrasts that, for different terms, are orthogonal
>     in the row-basis of the model, such as those produced by contr.sum,
>     contr.poly, or contr.helmert, but not by the default
>     contr.treatment. In
>     a model that contains factors, numeric covariates, and interactions,
>     main-effect tests for factors will be for differences over the origin.
>     In contrast (pun intended), type-II tests are invariant with respect to
>     (full-rank) contrast coding. If you don't understand this issue, then
>     you probably shouldn't use Anova for type-III tests."
> 
>     I hope this helps,
>        John
> 
>     -- 
>     John Fox, Professor Emeritus
>     McMaster University
>     Hamilton, Ontario, Canada
>     web: https://www.john-fox.ca/ <https://www.john-fox.ca/>
>     --
>     On 2024-06-18 5:59 a.m., Carlos Barboza wrote:
>      > [You don't often get email from carlosambarboza using gmail.com
>     <mailto:carlosambarboza using gmail.com>. Learn why this is important at
>     https://aka.ms/LearnAboutSenderIdentification
>     <https://aka.ms/LearnAboutSenderIdentification> ]
>      >
>      > Caution: External email.
>      >
>      >
>      > sorry, Anova type III function form car package in R
>      >
>      > Em ter., 18 de jun. de 2024 às 06:59, Carlos Barboza <
>      > carlosambarboza using gmail.com <mailto:carlosambarboza using gmail.com>>
>     escreveu:
>      >
>      >> Dear all,
>      >> why Anova type III function gives different results if I change
>     the names
>      >> of a categorical factor? I suspect that is because contrast type
>     but it's
>      >> something strange get different results using the same data.
>      >> thank you
>      >>
>      >> Em sáb., 7 de mai. de 2016 às 12:26, Carlos Barboza <
>      >> carlosambarboza using gmail.com <mailto:carlosambarboza using gmail.com>>
>     escreveu:
>      >>
>      >>> Dear Dr. Ben Bolker
>      >>>
>      >>> My name is Carlos Barboza and I am a Marine Biologist from the
>     Rio de
>      >>> Janeiro University, Brazil. First it's a pleasure to again have the
>      >>> opportunity to send you a message.The reason for it is a simple
>     doubt:
>      >>> Can I compare AIC from:
>      >>>
>      >>> 1. glmmADMB: Density ~ 1 + 1|Site
>      >>>
>      >>> 2. glmmADMB: Density ~ Sector + 1|Site + Cage
>      >>>
>      >>> Note that they have different random and fixed structures. I
>     know that
>      >>> this is not the best choice to model selection but, I think
>     that the AIC
>      >>> values can be compared.
>      >>>
>      >>> thank you very much for your attention
>      >>>
>      >>>
>      >>>    is Cage a random effect?  Are you intentionally leaving out the
>      >>> intercept in the second case (it will be included anyway unless you
>      >>> use -1)?  In any case, I don't see any obvious reason you can't
>      >>> compare AIC values; see
>      >>>
>      >>>
>     https://rawgit.com/bbolker/mixedmodels-misc/master/glmmFAQ.html#can-i-use-aic-for-mixed-models-how-do-i-count-the-number-of-degrees-of-freedom-for-a-random-effect <https://rawgit.com/bbolker/mixedmodels-misc/master/glmmFAQ.html#can-i-use-aic-for-mixed-models-how-do-i-count-the-number-of-degrees-of-freedom-for-a-random-effect>
>      >>>
>      >>>    Follow-ups to r-sig-mixed-models using r-project.org
>     <mailto:r-sig-mixed-models using r-project.org>, please ...
>      >>>
>      >>> sorry, yes, cage was included only to examplify a different random
>      >>> structure in the second case...it should be coded (1|Site) +
>     (1|Cage)
>      >>> yes, I know that the intercept will be included in the second model
>      >>>
>      >>> it's an example of comparing AIC values from mixed models with
>     different
>      >>> fixed and random structures:
>      >>>
>      >>> 1. Density ~ 1 + 1|Site
>      >>>
>      >>> 2. Density ~ Sector + 1|Site + 1|Cage
>      >>>
>      >>> comparing AIC...I beleive that both values can be compared
>      >>>
>      >>> again, thank you very much for your very fast message
>      >>>
>      >>>
>      >>>
>      >>>
>      >>
>      >> --
>      >> Universidade Federal do Rio de Janeiro (UFRJ)
>      >> Instituto de Biodiversidade e Sustentabilidade - NUPEM
>      >> Caixa Postal 119331, CEP 27910-970
>      >> Macaé, RJ, Brazil
>      >> https://www.macae.ufrj.br/nupem/ <https://www.macae.ufrj.br/nupem/>
>      >> http://lattes.cnpq.br/3629226944950076
>     <http://lattes.cnpq.br/3629226944950076>
>      >>
>     https://scholar.google.com.br/citations?user=p-PRvd4AAAAJ&hl=pt-BR
>     <https://scholar.google.com.br/citations?user=p-PRvd4AAAAJ&hl=pt-BR>
>      >> https://www.researchgate.net/profile/Carlos_Barboza3
>     <https://www.researchgate.net/profile/Carlos_Barboza3>
>      >>
>      >
>      >
>      > --
>      > Universidade Federal do Rio de Janeiro (UFRJ)
>      > Instituto de Biodiversidade e Sustentabilidade - NUPEM
>      > Caixa Postal 119331, CEP 27910-970
>      > Macaé, RJ, Brazil
>      > https://www.macae.ufrj.br/nupem/ <https://www.macae.ufrj.br/nupem/>
>      > http://lattes.cnpq.br/3629226944950076
>     <http://lattes.cnpq.br/3629226944950076>
>      >
>     https://scholar.google.com.br/citations?user=p-PRvd4AAAAJ&hl=pt-BR
>     <https://scholar.google.com.br/citations?user=p-PRvd4AAAAJ&hl=pt-BR>
>      > https://www.researchgate.net/profile/Carlos_Barboza3
>     <https://www.researchgate.net/profile/Carlos_Barboza3>
>      >
>      >          [[alternative HTML version deleted]]
>      >
>      > _______________________________________________
>      > R-sig-mixed-models using r-project.org
>     <mailto:R-sig-mixed-models using r-project.org> mailing list
>      > https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>     <https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models>
> 
> 
> 
> -- 
> Universidade Federal do Rio de Janeiro (UFRJ)
> Instituto de Biodiversidade e Sustentabilidade - NUPEM
> Caixa Postal 119331, CEP 27910-970
> Macaé, RJ, Brazil
> https://www.macae.ufrj.br/nupem/ <https://www.macae.ufrj.br/nupem/>
> http://lattes.cnpq.br/3629226944950076 
> <http://lattes.cnpq.br/3629226944950076>
> https://scholar.google.com.br/citations?user=p-PRvd4AAAAJ&hl=pt-BR 
> <https://scholar.google.com.br/citations?user=p-PRvd4AAAAJ&hl=pt-BR>
> https://www.researchgate.net/profile/Carlos_Barboza3 
> <https://www.researchgate.net/profile/Carlos_Barboza3>



More information about the R-sig-mixed-models mailing list