Re: [R] Lme4 and syntax of random factors
Thank you for your answer Ben B., it is helpful. The post on Fixed vs Random effects is particularly interesting. I had in mind to create a fixed interaction, as you propose (time*A). I actually wanted to compare it with a random interaction, so to decide on which model to go with based on this comparison... I would just ask one more thing, if someone is feeling like answering... what's the difference between (1 | A:B) and (1 | A/B) ? I though it was exactly the same thing, but the (1 | A/B) form was used in older versions of the lmer package...? Regards De : Ben Bolker bbol...@gmail.com À : r-h...@stat.math.ethz.ch Envoyé le : Mardi 13 août 2013 15h55 Objet : Re: [R] Lme4 and syntax of random factors Robert U tacsunday at yahoo.fr writes: Dear R-users, [snip] This question probably belongs on r-sig-mixed-mod...@r-project.org . Followups there, please. Let's say that I have 2 random effects, A (e.g. species, k=2) and B (e.g. individuals, n=100). I made some research about model syntax, and I have the understanding that everything at the left side of the random parameter is about SLOPE and everything at the right side about intercept : You really can't practically fit a random effect to 2 species (see http://glmm.wikidot.com/faq#fixed_vs_random + (1 |B) would give me an intercept per individual. + (1 |A) would give me an intercept per species. yes + (1 |A:B) would give me an intercept per individuals with nested effect (individual inside species) This would be the same as (1|B) if the individuals are uniquely identified. Otherwise you probably want (1|A/B) [except that you can't really fit a random effect for k=2, as discussed above] I would like to have random slopes per species. So I thought I could do something like that : Probably not feasible. + (A |B) so to have an intercept per individual and a slope value per species. Graphically, I would therefore obtain 100 lines with 100 different intercepts and 2 possible slopes (1 per species). However, when I extract random parameter values (ranef()), I have : what variable is your slope with respect to? Suppose it's time. Then I would recommend ~ A*time + (1|A:B) which will fit a (FIXED effect) interaction between species and time (different slopes and intercepts for each species), and a random intercept per individual. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Lme4 and syntax of random factors
Dear Robert, (1|A/B) is shorthand for (1|A) + (1|A:B) ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie Kwaliteitszorg / team Biometrics Quality Assurance Kliniekstraat 25 1070 Anderlecht Belgium + 32 2 525 02 51 + 32 54 43 61 85 thierry.onkel...@inbo.be 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 -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Robert U Verzonden: woensdag 14 augustus 2013 12:10 Aan: Ben Bolker; r-h...@stat.math.ethz.ch Onderwerp: Re: [R] Lme4 and syntax of random factors Thank you for your answer Ben B., it is helpful. The post on Fixed vs Random effects is particularly interesting. I had in mind to create a fixed interaction, as you propose (time*A). I actually wanted to compare it with a random interaction, so to decide on which model to go with based on this comparison... I would just ask one more thing, if someone is feeling like answering... what's the difference between (1 | A:B) and (1 | A/B) ? I though it was exactly the same thing, but the (1 | A/B) form was used in older versions of the lmer package...? Regards De : Ben Bolker bbol...@gmail.com À : r-h...@stat.math.ethz.ch Envoyé le : Mardi 13 août 2013 15h55 Objet : Re: [R] Lme4 and syntax of random factors Robert U tacsunday at yahoo.fr writes: Dear R-users, [snip] This question probably belongs on r-sig-mixed-mod...@r-project.org . Followups there, please. Let's say that I have 2 random effects, A (e.g. species, k=2) and B (e.g. individuals, n=100). I made some research about model syntax, and I have the understanding that everything at the left side of the random parameter is about SLOPE and everything at the right side about intercept : You really can't practically fit a random effect to 2 species (see http://glmm.wikidot.com/faq#fixed_vs_random + (1 |B) would give me an intercept per individual. + (1 |A) would give me an intercept per species. yes + (1 |A:B) would give me an intercept per individuals with nested effect (individual inside species) This would be the same as (1|B) if the individuals are uniquely identified. Otherwise you probably want (1|A/B) [except that you can't really fit a random effect for k=2, as discussed above] I would like to have random slopes per species. So I thought I could do something like that : Probably not feasible. + (A |B) so to have an intercept per individual and a slope value per species. Graphically, I would therefore obtain 100 lines with 100 different intercepts and 2 possible slopes (1 per species). However, when I extract random parameter values (ranef()), I have : what variable is your slope with respect to? Suppose it's time. Then I would recommend ~ A*time + (1|A:B) which will fit a (FIXED effect) interaction between species and time (different slopes and intercepts for each species), and a random intercept per individual. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] * * * * * * * * * * * * * D I S C L A I M E R * * * * * * * * * * * * * Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Lme4 and syntax of random factors
Dear R-users, Iâve been looking at the lmer function (lme4 package) in order to set up a mixed linear model and something about the syntax of the random effects eludes me. Iâd like a hand with understanding a specific point, if someone does master this function⦠Letâs say that I have 2 random effects, A (e.g. species, k=2) and B (e.g. individuals, n=100). I made some research about model syntax, and I have the understanding that everything at the left side of the random âparameterâ is about SLOPE and everything at the right side about intercept : ⦠+ (1 |B) would give me an intercept per individual. ⦠+ (1 |A) would give me an intercept per species. ⦠+ (1 |A:B) would give me an intercept per individuals with nested effect (individual inside species). I would like to have random slopes per species. So I thought I could do something like that : ⦠+ (A |B) so to have an intercept per individual and a slope value per species. Graphically, I would therefore obtain 100 lines with 100 different intercepts and 2 possible slopes (1 per species). However, when I extract random parameter values (ranef()), I have : ·        First column is the intercept : varying values per line (individuals), so OK ·        2nd and 3rd column are Species 1 and 2: I have different across individuals (without obvious pattern: I do not have similar values for individual of the same species), which is not what I was expecting (1 value per species : the slope parameter). Is the mistake Iâm doing (or in my understanding of lme4) obvious to somebody? With regards [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Lme4 and syntax of random factors
Robert U tacsunday at yahoo.fr writes: Dear R-users, [snip] This question probably belongs on r-sig-mixed-mod...@r-project.org . Followups there, please. Let's say that I have 2 random effects, A (e.g. species, k=2) and B (e.g. individuals, n=100). I made some research about model syntax, and I have the understanding that everything at the left side of the random parameter is about SLOPE and everything at the right side about intercept : You really can't practically fit a random effect to 2 species (see http://glmm.wikidot.com/faq#fixed_vs_random + (1 |B) would give me an intercept per individual. + (1 |A) would give me an intercept per species. yes + (1 |A:B) would give me an intercept per individuals with nested effect (individual inside species) This would be the same as (1|B) if the individuals are uniquely identified. Otherwise you probably want (1|A/B) [except that you can't really fit a random effect for k=2, as discussed above] I would like to have random slopes per species. So I thought I could do something like that : Probably not feasible. + (A |B) so to have an intercept per individual and a slope value per species. Graphically, I would therefore obtain 100 lines with 100 different intercepts and 2 possible slopes (1 per species). However, when I extract random parameter values (ranef()), I have : what variable is your slope with respect to? Suppose it's time. Then I would recommend ~ A*time + (1|A:B) which will fit a (FIXED effect) interaction between species and time (different slopes and intercepts for each species), and a random intercept per individual. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.