https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
or, via email, send a message with subject or body 'help' to
r-sig-mixed-models-request at r-project.org
You can reach the person managing the list at
r-sig-mixed-models-owner at r-project.org
When replying, please edit your Subject line so it is more specific
than "Re: Contents of R-sig-mixed-models digest..."
Today's Topics:
1. Doubtful significance in mixed effect model (Chia-Yu Chen)
2. Re: Your response to my R-sig-ME question (Lenth, Russell V)
----------------------------------------------------------------------
Message: 1
Date: Sat, 2 Nov 2019 19:40:15 +0100
From: Chia-Yu Chen <jessica821112 at gmail.com>
To: r-sig-mixed-models at r-project.org
Subject: [R-sig-ME] Doubtful significance in mixed effect model
Message-ID: <78B7183F-D5C1-4622-BA8A-B1852C5AD8AB at gmail.com>
Content-Type: text/plain; charset="utf-8"
Hi,
I have a problem on the significance of age and sex when running glmer on my longitudinal data.
My data
A longitudinal data where each patient is tested at 3 timepoints (here, define as ?case?). There are different treatments between cases. Along with ?case?, other factors include age, sex and drug dosages. So it looked something like this (there are 23 patients, each has 3 cases)
Patient Case Age Sex DrugA DrugB Value
1 1 10 0 5 10 20
1 2 10 0 10 0 30
1 3 10 0 15 0 55
What I want to do
The goal of this study is to show that ?value? is significantly different across ?cases?. Age, sex, drugA, drugB are all potential confounders. Here I want to see if either of these factors has confounding effects, that is, whether adding these factors to the model will be better or not.
How I did it
First, I constructed 2 nested models, and then I compared the 2 models with likelihood test. If m2 is better than m1, then I assume this factor has significance for value. Since it?s a longitudinal data, the ?patient? is treated as random factor. I ran through the factors one by one, here take ?sex? for example:
m1 <- lme4::glmer(data = subdata, formula = value ~ Case + (1 | Patient))
m2 <- lme4::glmer(data = subdata, formula = value ~ Case + (1 | Patient) + ( Sex | Patient))
p_value <- lmtest::lrtest (m1, m2)$"Pr(>Chisq)"[2]
My Question
I expected that m2 shouldn?t be better than m1 for sex and age, because for each patient they didn?t change over 3 cases. I thought by specifying "( Sex | Patient)? in the model would tell R that sex doesn?t change for each patient, and thus it doesn?t have any predictive ability for the value. However, lrtest showed that for some patients, m2 is better than m1, meaning that age or sex is significant. I?m wondering is there anything wrong in my codes? Doesn?t ( Sex | Patient) tell R that sex doesn?t change for each patient? How should I code so that m2 won?t be better than m1 for sex and age? Or is there any better way doing this?
I?ve tried many combinations of the code, but I still can?t solve this problem. Could anyone give me some advices? Any suggestion is appreciated! Thank you in advance.
Best,
Chia-Yu
[[alternative HTML version deleted]]
------------------------------
Message: 2
Date: Sat, 2 Nov 2019 22:25:37 +0000
From: "Lenth, Russell V" <russell-lenth at uiowa.edu>
To: Francesco Romano <fbromano77 at gmail.com>
Cc: "r-sig-mixed-models at r-project.org"
<r-sig-mixed-models at r-project.org>
Subject: Re: [R-sig-ME] Your response to my R-sig-ME question
Message-ID:
<DM6PR04MB438084D57E44BFBA85B23DD7F17D0 at DM6PR04MB4380.namprd04.prod.outlook.com>
Content-Type: text/plain; charset="iso-8859-1"
If the question is how to do multiplicity adjustments for multiple sets of comparisons in 'emmeans', that is pretty simple to do. For example, starting with
library("emmeans")
emm <- emmeans(model, ~ factor1 | factor2)
By default,
pairs(emm, by = "factor1")
will apply the Tukey adjustment to the pairwise comparisons of factor2 for each level of factor1, SEPARATELY. If instead, you want to multiplicity-adjust all of those simple comparisons as one family, summarize those results after removing the 'by' variable:
summary(pairs(emm, by = "factor1"), by = NULL, adjust = "mvt")
(Note that the Tukey adjustment is not appropriate for that family because it is not ONE set of pairwise comparisons. The mvt adjustment is the same adjustment that the multcomp package appluies by default.)
You of course may also want simple comparisons of factor1 for each level of factor2; just reverse the roles of the two factors in the above.
If you want to combine both of those families into a single family consisting of all simple comparisons of both factor2|factor1 and factor1|factor2, that can be done as well via 'rbind':
allcmps <- pairs(emm, simple = "each") # creates a list of two emmGrid objects
summary(do.call(rbind, allcmps), adjust = "mvt")
I hope that helps
Russ
Russell V. Lenth - Professor Emeritus
Department of Statistics and Actuarial Science
The University of Iowa - Iowa City, IA 52242 USA
Voice (319)335-0712 (Dept. office) - FAX (319)335-3017
-----Original Message-----
Date: Fri, 1 Nov 2019 21:00:03 -0400
From: Ben Bolker <bbolker at gmail.com>
To: Francesco Romano <fbromano77 at gmail.com>
Cc: "r-sig-mixed-models at r-project.org"
<r-sig-mixed-models at r-project.org>
Subject: Re: [R-sig-ME] Your response to my R-sig-ME question
Message-ID: <c5952d23-0ab9-e201-f775-5c90d89f5dff at gmail.com>
Content-Type: text/plain; charset="utf-8"
[cc'ing r-sig-mixed-models]
Honestly, it looks to me like you *do* need multiple-comparisons corrections here. I can't give you detailed advice about how to do it; emmeans does the pairwise comparisons, but it's not immediately obvious how to do correction for *multiple* sets of pairwise comparisons.
(Perhaps you could get away with only doing the corrections at the level of sets of pairwise comparisons.) As I mentioned before, this is not a particularly mixed-model-related question. You could try CrossValidated (https://stats.stackexchange.com). The emmeans and multcomp packages will probably be what you need in terms of machinery.
sincerely
Ben Bolker
------------------------------
Subject: Digest Footer
_______________________________________________
R-sig-mixed-models mailing list
R-sig-mixed-models at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
------------------------------
End of R-sig-mixed-models Digest, Vol 155, Issue 3
**************************************************