Should all adjustments be random effects in a mixed linear effect?Can we really assign random slopes to between-subject effects in a mixed effects model?Mixed model with lmer: Variance of residuals should give the same as level 1 variance?When the dependent variable and random effects 'overlap' in mixed effects modelsIn repeated-measures linear mixed model, should the time variable be fixed or random?How can mixed-effect and fixed-effect generalised linear models be compared using BIC?Clarification on nesting fixed effects within random effects in an mixed effect modelSplit plot in time mixed-effect model in RInterpreting effects of categorical and continuous predictors in multiple linear mixed modelsLinear Mixed Model for partially nested AND crossed factorsAm I employing and interpreting linear mixed-effects modelling correctly here?How to correctly model repeated-measures random effects in a linear mixed effects model

Why did it take so long for Germany to allow electric scooters / e-rollers on the roads?

Why would a rational buyer offer to buy with no conditions precedent?

What is the recommended procedure to land a taildragger in a crosswind?

Of strange atmospheres - the survivable but unbreathable

Storing voxels for a voxel Engine in C++

Time complexity of an algorithm: Is it important to state the base of the logarithm?

Count all vowels in string

If I arrive in the UK, and then head to mainland Europe, does my Schengen visa 90 day limit start when I arrived in the UK, or mainland Europe?

What weight should be given to writers groups critiques?

Are there any German nonsense poems (Jabberwocky)?

Is "vegetable base" a common term in English?

How to politely tell someone they did not hit reply all in email?

Why sampling a periodic signal doesn't yield a periodic discrete signal?

Co-author wants to put their current funding source in the acknowledgements section because they edited the paper

Freedom of Speech and Assembly in China

Shorten or merge multiple lines of `&> /dev/null &`

How can I properly write this equation in Latex?

Interpretation of ROC AUC score

Why did other houses not demand this?

Expected maximum number of unpaired socks

A burglar's sunglasses, a lady's odyssey

Why did Jon Snow admit his fault in S08E06?

How to melt snow without fire or using body heat?

Who knighted this character?



Should all adjustments be random effects in a mixed linear effect?


Can we really assign random slopes to between-subject effects in a mixed effects model?Mixed model with lmer: Variance of residuals should give the same as level 1 variance?When the dependent variable and random effects 'overlap' in mixed effects modelsIn repeated-measures linear mixed model, should the time variable be fixed or random?How can mixed-effect and fixed-effect generalised linear models be compared using BIC?Clarification on nesting fixed effects within random effects in an mixed effect modelSplit plot in time mixed-effect model in RInterpreting effects of categorical and continuous predictors in multiple linear mixed modelsLinear Mixed Model for partially nested AND crossed factorsAm I employing and interpreting linear mixed-effects modelling correctly here?How to correctly model repeated-measures random effects in a linear mixed effects model






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








3












$begingroup$


I've been sometimes taught that when you are performing a mixed model, any variable of which you don't care about estimating a parameter (adjusment variable) should be a random effect, regardless of number of added degrees of freedom.



However, in most online courses and tutorials (this one for instance), this is not really explicit.



Let's take the same example as this tutorial:



lmm <- lmer(Mean.Pitch ~ Sex + Social.Rank + (1 | Group), data = starlings,
REML = FALSE)
summary(lmm)


If I'm only interested in Sex's effect, should I put Social.Rank in the random effects?



If this is true, what will it change? Then, should I perform mixed model even if there is no real grouping?










share|cite|improve this question









$endgroup$











  • $begingroup$
    I have never seen such a claim about adjustment variables as random effects. What rationale did the teacher give for this?
    $endgroup$
    – Heteroskedastic Jim
    May 16 at 13:17










  • $begingroup$
    @HeteroskedasticJim The course was very practical (R course) so there was no time for maths and rationales... But regardless of this statement (which I'm glad I'm not the only one to find it surprising), I'm still interested on what changes if I adjust on some confounding variable with a fixed or a random effect.
    $endgroup$
    – Dan Chaltiel
    May 16 at 13:21











  • $begingroup$
    there are no changes all across the board. They just relate to different model specifications. Try reading about what it means to specify a variable as a random effect (at least in terms of interpretation). Also run it both ways and see. I would also say that if you don't know the rationale for that modeling strategy, then your first task should be finding one.
    $endgroup$
    – Heteroskedastic Jim
    May 16 at 13:25










  • $begingroup$
    @HeteroskedasticJim I dont understand why you are saying this, of course I'm looking for a rationale, this is why I'm posting here! Also, my math skills don't allow me to understand enough random effects to be sure I'm doing good (trust me I tried). Running it both ways won't help neither: I'll have 2 results, maybe close, and won't know which one is better.
    $endgroup$
    – Dan Chaltiel
    May 16 at 13:33










  • $begingroup$
    @DanChaltiel looking at your bio, I see you're a PhD in epidemiology. You don't have to do the complex math to understand models. But I also think you're understanding is deficient here (with all respect). I can recommend two (3) good non-technical (non-algebra, good examples, and detailed technical writing) books appropriate to PhD Epidemiology: Vittinghoff et al Regression Methods in Biostatistics. and Diggle, Heagerty, Liang Zeger "Analysis of Longitudinal Data". Also Wakefield "Bayesian and Frequentist Regression Methods".
    $endgroup$
    – AdamO
    May 16 at 13:45


















3












$begingroup$


I've been sometimes taught that when you are performing a mixed model, any variable of which you don't care about estimating a parameter (adjusment variable) should be a random effect, regardless of number of added degrees of freedom.



However, in most online courses and tutorials (this one for instance), this is not really explicit.



Let's take the same example as this tutorial:



lmm <- lmer(Mean.Pitch ~ Sex + Social.Rank + (1 | Group), data = starlings,
REML = FALSE)
summary(lmm)


If I'm only interested in Sex's effect, should I put Social.Rank in the random effects?



If this is true, what will it change? Then, should I perform mixed model even if there is no real grouping?










share|cite|improve this question









$endgroup$











  • $begingroup$
    I have never seen such a claim about adjustment variables as random effects. What rationale did the teacher give for this?
    $endgroup$
    – Heteroskedastic Jim
    May 16 at 13:17










  • $begingroup$
    @HeteroskedasticJim The course was very practical (R course) so there was no time for maths and rationales... But regardless of this statement (which I'm glad I'm not the only one to find it surprising), I'm still interested on what changes if I adjust on some confounding variable with a fixed or a random effect.
    $endgroup$
    – Dan Chaltiel
    May 16 at 13:21











  • $begingroup$
    there are no changes all across the board. They just relate to different model specifications. Try reading about what it means to specify a variable as a random effect (at least in terms of interpretation). Also run it both ways and see. I would also say that if you don't know the rationale for that modeling strategy, then your first task should be finding one.
    $endgroup$
    – Heteroskedastic Jim
    May 16 at 13:25










  • $begingroup$
    @HeteroskedasticJim I dont understand why you are saying this, of course I'm looking for a rationale, this is why I'm posting here! Also, my math skills don't allow me to understand enough random effects to be sure I'm doing good (trust me I tried). Running it both ways won't help neither: I'll have 2 results, maybe close, and won't know which one is better.
    $endgroup$
    – Dan Chaltiel
    May 16 at 13:33










  • $begingroup$
    @DanChaltiel looking at your bio, I see you're a PhD in epidemiology. You don't have to do the complex math to understand models. But I also think you're understanding is deficient here (with all respect). I can recommend two (3) good non-technical (non-algebra, good examples, and detailed technical writing) books appropriate to PhD Epidemiology: Vittinghoff et al Regression Methods in Biostatistics. and Diggle, Heagerty, Liang Zeger "Analysis of Longitudinal Data". Also Wakefield "Bayesian and Frequentist Regression Methods".
    $endgroup$
    – AdamO
    May 16 at 13:45














3












3








3





$begingroup$


I've been sometimes taught that when you are performing a mixed model, any variable of which you don't care about estimating a parameter (adjusment variable) should be a random effect, regardless of number of added degrees of freedom.



However, in most online courses and tutorials (this one for instance), this is not really explicit.



Let's take the same example as this tutorial:



lmm <- lmer(Mean.Pitch ~ Sex + Social.Rank + (1 | Group), data = starlings,
REML = FALSE)
summary(lmm)


If I'm only interested in Sex's effect, should I put Social.Rank in the random effects?



If this is true, what will it change? Then, should I perform mixed model even if there is no real grouping?










share|cite|improve this question









$endgroup$




I've been sometimes taught that when you are performing a mixed model, any variable of which you don't care about estimating a parameter (adjusment variable) should be a random effect, regardless of number of added degrees of freedom.



However, in most online courses and tutorials (this one for instance), this is not really explicit.



Let's take the same example as this tutorial:



lmm <- lmer(Mean.Pitch ~ Sex + Social.Rank + (1 | Group), data = starlings,
REML = FALSE)
summary(lmm)


If I'm only interested in Sex's effect, should I put Social.Rank in the random effects?



If this is true, what will it change? Then, should I perform mixed model even if there is no real grouping?







mixed-model adjustment






share|cite|improve this question













share|cite|improve this question











share|cite|improve this question




share|cite|improve this question










asked May 16 at 13:11









Dan ChaltielDan Chaltiel

398114




398114











  • $begingroup$
    I have never seen such a claim about adjustment variables as random effects. What rationale did the teacher give for this?
    $endgroup$
    – Heteroskedastic Jim
    May 16 at 13:17










  • $begingroup$
    @HeteroskedasticJim The course was very practical (R course) so there was no time for maths and rationales... But regardless of this statement (which I'm glad I'm not the only one to find it surprising), I'm still interested on what changes if I adjust on some confounding variable with a fixed or a random effect.
    $endgroup$
    – Dan Chaltiel
    May 16 at 13:21











  • $begingroup$
    there are no changes all across the board. They just relate to different model specifications. Try reading about what it means to specify a variable as a random effect (at least in terms of interpretation). Also run it both ways and see. I would also say that if you don't know the rationale for that modeling strategy, then your first task should be finding one.
    $endgroup$
    – Heteroskedastic Jim
    May 16 at 13:25










  • $begingroup$
    @HeteroskedasticJim I dont understand why you are saying this, of course I'm looking for a rationale, this is why I'm posting here! Also, my math skills don't allow me to understand enough random effects to be sure I'm doing good (trust me I tried). Running it both ways won't help neither: I'll have 2 results, maybe close, and won't know which one is better.
    $endgroup$
    – Dan Chaltiel
    May 16 at 13:33










  • $begingroup$
    @DanChaltiel looking at your bio, I see you're a PhD in epidemiology. You don't have to do the complex math to understand models. But I also think you're understanding is deficient here (with all respect). I can recommend two (3) good non-technical (non-algebra, good examples, and detailed technical writing) books appropriate to PhD Epidemiology: Vittinghoff et al Regression Methods in Biostatistics. and Diggle, Heagerty, Liang Zeger "Analysis of Longitudinal Data". Also Wakefield "Bayesian and Frequentist Regression Methods".
    $endgroup$
    – AdamO
    May 16 at 13:45

















  • $begingroup$
    I have never seen such a claim about adjustment variables as random effects. What rationale did the teacher give for this?
    $endgroup$
    – Heteroskedastic Jim
    May 16 at 13:17










  • $begingroup$
    @HeteroskedasticJim The course was very practical (R course) so there was no time for maths and rationales... But regardless of this statement (which I'm glad I'm not the only one to find it surprising), I'm still interested on what changes if I adjust on some confounding variable with a fixed or a random effect.
    $endgroup$
    – Dan Chaltiel
    May 16 at 13:21











  • $begingroup$
    there are no changes all across the board. They just relate to different model specifications. Try reading about what it means to specify a variable as a random effect (at least in terms of interpretation). Also run it both ways and see. I would also say that if you don't know the rationale for that modeling strategy, then your first task should be finding one.
    $endgroup$
    – Heteroskedastic Jim
    May 16 at 13:25










  • $begingroup$
    @HeteroskedasticJim I dont understand why you are saying this, of course I'm looking for a rationale, this is why I'm posting here! Also, my math skills don't allow me to understand enough random effects to be sure I'm doing good (trust me I tried). Running it both ways won't help neither: I'll have 2 results, maybe close, and won't know which one is better.
    $endgroup$
    – Dan Chaltiel
    May 16 at 13:33










  • $begingroup$
    @DanChaltiel looking at your bio, I see you're a PhD in epidemiology. You don't have to do the complex math to understand models. But I also think you're understanding is deficient here (with all respect). I can recommend two (3) good non-technical (non-algebra, good examples, and detailed technical writing) books appropriate to PhD Epidemiology: Vittinghoff et al Regression Methods in Biostatistics. and Diggle, Heagerty, Liang Zeger "Analysis of Longitudinal Data". Also Wakefield "Bayesian and Frequentist Regression Methods".
    $endgroup$
    – AdamO
    May 16 at 13:45
















$begingroup$
I have never seen such a claim about adjustment variables as random effects. What rationale did the teacher give for this?
$endgroup$
– Heteroskedastic Jim
May 16 at 13:17




$begingroup$
I have never seen such a claim about adjustment variables as random effects. What rationale did the teacher give for this?
$endgroup$
– Heteroskedastic Jim
May 16 at 13:17












$begingroup$
@HeteroskedasticJim The course was very practical (R course) so there was no time for maths and rationales... But regardless of this statement (which I'm glad I'm not the only one to find it surprising), I'm still interested on what changes if I adjust on some confounding variable with a fixed or a random effect.
$endgroup$
– Dan Chaltiel
May 16 at 13:21





$begingroup$
@HeteroskedasticJim The course was very practical (R course) so there was no time for maths and rationales... But regardless of this statement (which I'm glad I'm not the only one to find it surprising), I'm still interested on what changes if I adjust on some confounding variable with a fixed or a random effect.
$endgroup$
– Dan Chaltiel
May 16 at 13:21













$begingroup$
there are no changes all across the board. They just relate to different model specifications. Try reading about what it means to specify a variable as a random effect (at least in terms of interpretation). Also run it both ways and see. I would also say that if you don't know the rationale for that modeling strategy, then your first task should be finding one.
$endgroup$
– Heteroskedastic Jim
May 16 at 13:25




$begingroup$
there are no changes all across the board. They just relate to different model specifications. Try reading about what it means to specify a variable as a random effect (at least in terms of interpretation). Also run it both ways and see. I would also say that if you don't know the rationale for that modeling strategy, then your first task should be finding one.
$endgroup$
– Heteroskedastic Jim
May 16 at 13:25












$begingroup$
@HeteroskedasticJim I dont understand why you are saying this, of course I'm looking for a rationale, this is why I'm posting here! Also, my math skills don't allow me to understand enough random effects to be sure I'm doing good (trust me I tried). Running it both ways won't help neither: I'll have 2 results, maybe close, and won't know which one is better.
$endgroup$
– Dan Chaltiel
May 16 at 13:33




$begingroup$
@HeteroskedasticJim I dont understand why you are saying this, of course I'm looking for a rationale, this is why I'm posting here! Also, my math skills don't allow me to understand enough random effects to be sure I'm doing good (trust me I tried). Running it both ways won't help neither: I'll have 2 results, maybe close, and won't know which one is better.
$endgroup$
– Dan Chaltiel
May 16 at 13:33












$begingroup$
@DanChaltiel looking at your bio, I see you're a PhD in epidemiology. You don't have to do the complex math to understand models. But I also think you're understanding is deficient here (with all respect). I can recommend two (3) good non-technical (non-algebra, good examples, and detailed technical writing) books appropriate to PhD Epidemiology: Vittinghoff et al Regression Methods in Biostatistics. and Diggle, Heagerty, Liang Zeger "Analysis of Longitudinal Data". Also Wakefield "Bayesian and Frequentist Regression Methods".
$endgroup$
– AdamO
May 16 at 13:45





$begingroup$
@DanChaltiel looking at your bio, I see you're a PhD in epidemiology. You don't have to do the complex math to understand models. But I also think you're understanding is deficient here (with all respect). I can recommend two (3) good non-technical (non-algebra, good examples, and detailed technical writing) books appropriate to PhD Epidemiology: Vittinghoff et al Regression Methods in Biostatistics. and Diggle, Heagerty, Liang Zeger "Analysis of Longitudinal Data". Also Wakefield "Bayesian and Frequentist Regression Methods".
$endgroup$
– AdamO
May 16 at 13:45











2 Answers
2






active

oldest

votes


















6












$begingroup$

That is not right. A mixed effects model is a mixture of random effects and fixed effects. Generally, the point of adjusting for a random effect is to control for clustering indicators or combinations of covariates that are so high in dimension, the fixed effects would be unstable if not singular in a model. Random effects are a kind of last resort in that sense.



Correlated data and model misspecification are highly related, random effects allow you to have a misspecified model, but to borrow information about groups of individuals who tend to be clustered, to yield residuals that are conditionally independent. If you managed to control for all those attributes in the fixed effects there's no need for a random effect at all. If anything, the preference should be to control for the fixed effect whenever possible because the inference is more generalizable.



Take, as an example, a study of fraternal twins. If you studied the phenotype of a heritable disease, and then adjusted for the genetic mutation (SNP) which predisposes individuals to that disease, the data are now independent despite the design because the only "relatedness" that the twins exhibited has been controlled for. There would be no need for a random effect indicating twin-pair in the outcome.






share|cite|improve this answer











$endgroup$












  • $begingroup$
    this is exactly what I thought but I wanted to make sure, thanks for the clear explanation
    $endgroup$
    – Dan Chaltiel
    May 16 at 13:46










  • $begingroup$
    I googled "confraternal", and there didn't seem to be any results other than to pages regarding confraternaties. Do you man just "fraternal"?
    $endgroup$
    – Acccumulation
    May 16 at 19:07






  • 1




    $begingroup$
    @Acccumulation yes I think I accidentally turned my twin research into a Catholic prayer. See edit.
    $endgroup$
    – AdamO
    May 16 at 19:14


















8












$begingroup$

The first and foremost consideration that should drive the specification of random effects in a mixed effects model is the study design. Here are some examples that illustrate how the design affects the model specification.



Example 1



If you have a study in which you randomly selected patients from a target population of patients and measured an outcome variable (e.g., CD4 cell count) at several time points, along with time-varying and/or time-invarying predictor variables, then you would want to include at a minimum a random patient effect (i.e., a random patient intercept) to account for the natural nesting of repeated outcome observations within a patient.



Example 2



If you have a study in which you randomly selected a set of hospitals from a target population of hospitals, and then you randomly selected a set of patients from each hospital such that each patient would provide multiple measurements for an outcome variable (e.g., CD4 count), then you would need to include (at a minimum) a random hospital effect and a random patient effect in your model.



-------------------------------------------------


In the first example, patient is a random grouping factor. In the second example, hospital and patient are random grouping factors, with patient nested within hospital (since the patients randomly selected within a hospital are unique to that hospital and will not appear in any other hospital).



In some study designs, it is possible to have either fully crossed or partially crossed random grouping factors. For instance, you could have a study where some patients end up attending multiple hospitals throughout the duration of the study, in which case the patient and hospital would likely be partially crossed random grouping factors.



So paying attention to the study design helps identify the random grouping factors, each of which will be allowed its own random set of intercepts in the model - one intercept per level of random grouping factor.



The second consideration in the mixed effects model specification is to think about what predictor variables in the model can have varying (or random) effects across the levels of the grouping factor(s).



For Example 1, let's assume we measured the predictor blood pressure for each patient at all the time points where we also measured the outcome variable CD4 cell count - there were 4 time points per patient (say, once a week, for a total of 4 weeks). Let's also assume we measured the predictor gender. The blood pressure values will change from one week to the other for each patient, in tandem with the values of the CD4 cell counts. If we have reasons to believe that the association between CD4 counts and blood pressure values will be different from patient to patient, then we can allow the slope of blood pressure in the model to vary randomly across patients - we can achieve this by including a random effect of blood pressure in the model. The gender value will not change from one week to another for a patient, so there is no need to allow for a random effect of gender in our model. In the context of this example, we say that blood pressure is a within-patient (or within-subject) predictor variable, whereas gender is a between-patients (or between-patients) predictor variable. Only within-patient predictor variables can be allowed to have varying (or random) effects across the levels of the corresponding random grouping factor.



For Example 2, we can have predictor variables that refer to the hospitals included in the study (e.g., type of hospital) and/or predictor variables that refer to the patients within those hospitals (e.g., patient gender, patient blood pressure). The patient-specific predictor variables, for instance, can be within-patient predictors whose values change from occasion to occasion for the same patient, or between-patient predictors, whose values are invariant to occasion for each patient but change from one patient to another. The within-patient predictors can have varying (or random) effects across patients, etc.



So the inclusion of random effects in your model ultimately depends on whether your study design includes any random grouping factor (e.g., patient, hospital) and whether you have predictor variables whose effects can be assumed to vary across the levels of these random grouping factors.






share|cite|improve this answer











$endgroup$








  • 1




    $begingroup$
    +1, but "Only within-patient predictor variables can be allowed to have varying (or random) effects across the levels of the corresponding random grouping factor." This is not really true. If patients are measured four times, then there is information to compute a patient-level gender effect. The effect of gender can be allowed to vary across persons. Older ways of formulating the model do not allow for this hence this belief. But more recent model formulations, such as in lme4, allow for between-person variables to have effects that vary by person.
    $endgroup$
    – Heteroskedastic Jim
    May 18 at 15:24










  • $begingroup$
    @HeteroskedasticJim: Interesting! How can we compute the effect of gender within one subject when there is no variability in the values of gender within that subject? The effect of gender within one person would imply that when that person switches genders from male to female, say, there is a difference in the expected value of their response. The variability of the gender effects across subjects would imply that the difference would vary across subjects - so all those subjects would have to have a gender switch! Just trying to understand intuitively what is going on here.
    $endgroup$
    – Isabella Ghement
    May 18 at 15:52







  • 1




    $begingroup$
    Interesting approach to the issue. I see how if one thinks of a person-level dataset, you have a constant for gender alongside another constant (the intercept). But estimation works on the full dataset, and not on a person by person level. And if you look at model specification in lme4 (e.g. equation 2 in cran.r-project.org/web/packages/lme4/vignettes/Theory.pdf), all that matters is that the design matrix for the random effects across all persons is a valid one, so no column is a linear combination of others; and there is information in the data to estimate the variance components.
    $endgroup$
    – Heteroskedastic Jim
    May 18 at 16:50






  • 1




    $begingroup$
    When the model is correctly specified, for females, the male random slope = 0, and vice-versa. Intuitively, the meaning is that the effect of gender is not the same for every human. A standard approach would be to interact gender and race. Here, it's an interaction between gender and person indicator. The difference would vary across subjects, yes. If A is fem and B, F are male. Then the difference "due to" gender comparing A to B is different than same "effect" comparing A to F.
    $endgroup$
    – Heteroskedastic Jim
    May 18 at 17:00






  • 1




    $begingroup$
    Yes, I'd answer the question if you post one. And I have an example in mind.
    $endgroup$
    – Heteroskedastic Jim
    May 18 at 17:13












Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "65"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstats.stackexchange.com%2fquestions%2f408646%2fshould-all-adjustments-be-random-effects-in-a-mixed-linear-effect%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









6












$begingroup$

That is not right. A mixed effects model is a mixture of random effects and fixed effects. Generally, the point of adjusting for a random effect is to control for clustering indicators or combinations of covariates that are so high in dimension, the fixed effects would be unstable if not singular in a model. Random effects are a kind of last resort in that sense.



Correlated data and model misspecification are highly related, random effects allow you to have a misspecified model, but to borrow information about groups of individuals who tend to be clustered, to yield residuals that are conditionally independent. If you managed to control for all those attributes in the fixed effects there's no need for a random effect at all. If anything, the preference should be to control for the fixed effect whenever possible because the inference is more generalizable.



Take, as an example, a study of fraternal twins. If you studied the phenotype of a heritable disease, and then adjusted for the genetic mutation (SNP) which predisposes individuals to that disease, the data are now independent despite the design because the only "relatedness" that the twins exhibited has been controlled for. There would be no need for a random effect indicating twin-pair in the outcome.






share|cite|improve this answer











$endgroup$












  • $begingroup$
    this is exactly what I thought but I wanted to make sure, thanks for the clear explanation
    $endgroup$
    – Dan Chaltiel
    May 16 at 13:46










  • $begingroup$
    I googled "confraternal", and there didn't seem to be any results other than to pages regarding confraternaties. Do you man just "fraternal"?
    $endgroup$
    – Acccumulation
    May 16 at 19:07






  • 1




    $begingroup$
    @Acccumulation yes I think I accidentally turned my twin research into a Catholic prayer. See edit.
    $endgroup$
    – AdamO
    May 16 at 19:14















6












$begingroup$

That is not right. A mixed effects model is a mixture of random effects and fixed effects. Generally, the point of adjusting for a random effect is to control for clustering indicators or combinations of covariates that are so high in dimension, the fixed effects would be unstable if not singular in a model. Random effects are a kind of last resort in that sense.



Correlated data and model misspecification are highly related, random effects allow you to have a misspecified model, but to borrow information about groups of individuals who tend to be clustered, to yield residuals that are conditionally independent. If you managed to control for all those attributes in the fixed effects there's no need for a random effect at all. If anything, the preference should be to control for the fixed effect whenever possible because the inference is more generalizable.



Take, as an example, a study of fraternal twins. If you studied the phenotype of a heritable disease, and then adjusted for the genetic mutation (SNP) which predisposes individuals to that disease, the data are now independent despite the design because the only "relatedness" that the twins exhibited has been controlled for. There would be no need for a random effect indicating twin-pair in the outcome.






share|cite|improve this answer











$endgroup$












  • $begingroup$
    this is exactly what I thought but I wanted to make sure, thanks for the clear explanation
    $endgroup$
    – Dan Chaltiel
    May 16 at 13:46










  • $begingroup$
    I googled "confraternal", and there didn't seem to be any results other than to pages regarding confraternaties. Do you man just "fraternal"?
    $endgroup$
    – Acccumulation
    May 16 at 19:07






  • 1




    $begingroup$
    @Acccumulation yes I think I accidentally turned my twin research into a Catholic prayer. See edit.
    $endgroup$
    – AdamO
    May 16 at 19:14













6












6








6





$begingroup$

That is not right. A mixed effects model is a mixture of random effects and fixed effects. Generally, the point of adjusting for a random effect is to control for clustering indicators or combinations of covariates that are so high in dimension, the fixed effects would be unstable if not singular in a model. Random effects are a kind of last resort in that sense.



Correlated data and model misspecification are highly related, random effects allow you to have a misspecified model, but to borrow information about groups of individuals who tend to be clustered, to yield residuals that are conditionally independent. If you managed to control for all those attributes in the fixed effects there's no need for a random effect at all. If anything, the preference should be to control for the fixed effect whenever possible because the inference is more generalizable.



Take, as an example, a study of fraternal twins. If you studied the phenotype of a heritable disease, and then adjusted for the genetic mutation (SNP) which predisposes individuals to that disease, the data are now independent despite the design because the only "relatedness" that the twins exhibited has been controlled for. There would be no need for a random effect indicating twin-pair in the outcome.






share|cite|improve this answer











$endgroup$



That is not right. A mixed effects model is a mixture of random effects and fixed effects. Generally, the point of adjusting for a random effect is to control for clustering indicators or combinations of covariates that are so high in dimension, the fixed effects would be unstable if not singular in a model. Random effects are a kind of last resort in that sense.



Correlated data and model misspecification are highly related, random effects allow you to have a misspecified model, but to borrow information about groups of individuals who tend to be clustered, to yield residuals that are conditionally independent. If you managed to control for all those attributes in the fixed effects there's no need for a random effect at all. If anything, the preference should be to control for the fixed effect whenever possible because the inference is more generalizable.



Take, as an example, a study of fraternal twins. If you studied the phenotype of a heritable disease, and then adjusted for the genetic mutation (SNP) which predisposes individuals to that disease, the data are now independent despite the design because the only "relatedness" that the twins exhibited has been controlled for. There would be no need for a random effect indicating twin-pair in the outcome.







share|cite|improve this answer














share|cite|improve this answer



share|cite|improve this answer








edited May 16 at 19:14

























answered May 16 at 13:35









AdamOAdamO

36.3k266145




36.3k266145











  • $begingroup$
    this is exactly what I thought but I wanted to make sure, thanks for the clear explanation
    $endgroup$
    – Dan Chaltiel
    May 16 at 13:46










  • $begingroup$
    I googled "confraternal", and there didn't seem to be any results other than to pages regarding confraternaties. Do you man just "fraternal"?
    $endgroup$
    – Acccumulation
    May 16 at 19:07






  • 1




    $begingroup$
    @Acccumulation yes I think I accidentally turned my twin research into a Catholic prayer. See edit.
    $endgroup$
    – AdamO
    May 16 at 19:14
















  • $begingroup$
    this is exactly what I thought but I wanted to make sure, thanks for the clear explanation
    $endgroup$
    – Dan Chaltiel
    May 16 at 13:46










  • $begingroup$
    I googled "confraternal", and there didn't seem to be any results other than to pages regarding confraternaties. Do you man just "fraternal"?
    $endgroup$
    – Acccumulation
    May 16 at 19:07






  • 1




    $begingroup$
    @Acccumulation yes I think I accidentally turned my twin research into a Catholic prayer. See edit.
    $endgroup$
    – AdamO
    May 16 at 19:14















$begingroup$
this is exactly what I thought but I wanted to make sure, thanks for the clear explanation
$endgroup$
– Dan Chaltiel
May 16 at 13:46




$begingroup$
this is exactly what I thought but I wanted to make sure, thanks for the clear explanation
$endgroup$
– Dan Chaltiel
May 16 at 13:46












$begingroup$
I googled "confraternal", and there didn't seem to be any results other than to pages regarding confraternaties. Do you man just "fraternal"?
$endgroup$
– Acccumulation
May 16 at 19:07




$begingroup$
I googled "confraternal", and there didn't seem to be any results other than to pages regarding confraternaties. Do you man just "fraternal"?
$endgroup$
– Acccumulation
May 16 at 19:07




1




1




$begingroup$
@Acccumulation yes I think I accidentally turned my twin research into a Catholic prayer. See edit.
$endgroup$
– AdamO
May 16 at 19:14




$begingroup$
@Acccumulation yes I think I accidentally turned my twin research into a Catholic prayer. See edit.
$endgroup$
– AdamO
May 16 at 19:14













8












$begingroup$

The first and foremost consideration that should drive the specification of random effects in a mixed effects model is the study design. Here are some examples that illustrate how the design affects the model specification.



Example 1



If you have a study in which you randomly selected patients from a target population of patients and measured an outcome variable (e.g., CD4 cell count) at several time points, along with time-varying and/or time-invarying predictor variables, then you would want to include at a minimum a random patient effect (i.e., a random patient intercept) to account for the natural nesting of repeated outcome observations within a patient.



Example 2



If you have a study in which you randomly selected a set of hospitals from a target population of hospitals, and then you randomly selected a set of patients from each hospital such that each patient would provide multiple measurements for an outcome variable (e.g., CD4 count), then you would need to include (at a minimum) a random hospital effect and a random patient effect in your model.



-------------------------------------------------


In the first example, patient is a random grouping factor. In the second example, hospital and patient are random grouping factors, with patient nested within hospital (since the patients randomly selected within a hospital are unique to that hospital and will not appear in any other hospital).



In some study designs, it is possible to have either fully crossed or partially crossed random grouping factors. For instance, you could have a study where some patients end up attending multiple hospitals throughout the duration of the study, in which case the patient and hospital would likely be partially crossed random grouping factors.



So paying attention to the study design helps identify the random grouping factors, each of which will be allowed its own random set of intercepts in the model - one intercept per level of random grouping factor.



The second consideration in the mixed effects model specification is to think about what predictor variables in the model can have varying (or random) effects across the levels of the grouping factor(s).



For Example 1, let's assume we measured the predictor blood pressure for each patient at all the time points where we also measured the outcome variable CD4 cell count - there were 4 time points per patient (say, once a week, for a total of 4 weeks). Let's also assume we measured the predictor gender. The blood pressure values will change from one week to the other for each patient, in tandem with the values of the CD4 cell counts. If we have reasons to believe that the association between CD4 counts and blood pressure values will be different from patient to patient, then we can allow the slope of blood pressure in the model to vary randomly across patients - we can achieve this by including a random effect of blood pressure in the model. The gender value will not change from one week to another for a patient, so there is no need to allow for a random effect of gender in our model. In the context of this example, we say that blood pressure is a within-patient (or within-subject) predictor variable, whereas gender is a between-patients (or between-patients) predictor variable. Only within-patient predictor variables can be allowed to have varying (or random) effects across the levels of the corresponding random grouping factor.



For Example 2, we can have predictor variables that refer to the hospitals included in the study (e.g., type of hospital) and/or predictor variables that refer to the patients within those hospitals (e.g., patient gender, patient blood pressure). The patient-specific predictor variables, for instance, can be within-patient predictors whose values change from occasion to occasion for the same patient, or between-patient predictors, whose values are invariant to occasion for each patient but change from one patient to another. The within-patient predictors can have varying (or random) effects across patients, etc.



So the inclusion of random effects in your model ultimately depends on whether your study design includes any random grouping factor (e.g., patient, hospital) and whether you have predictor variables whose effects can be assumed to vary across the levels of these random grouping factors.






share|cite|improve this answer











$endgroup$








  • 1




    $begingroup$
    +1, but "Only within-patient predictor variables can be allowed to have varying (or random) effects across the levels of the corresponding random grouping factor." This is not really true. If patients are measured four times, then there is information to compute a patient-level gender effect. The effect of gender can be allowed to vary across persons. Older ways of formulating the model do not allow for this hence this belief. But more recent model formulations, such as in lme4, allow for between-person variables to have effects that vary by person.
    $endgroup$
    – Heteroskedastic Jim
    May 18 at 15:24










  • $begingroup$
    @HeteroskedasticJim: Interesting! How can we compute the effect of gender within one subject when there is no variability in the values of gender within that subject? The effect of gender within one person would imply that when that person switches genders from male to female, say, there is a difference in the expected value of their response. The variability of the gender effects across subjects would imply that the difference would vary across subjects - so all those subjects would have to have a gender switch! Just trying to understand intuitively what is going on here.
    $endgroup$
    – Isabella Ghement
    May 18 at 15:52







  • 1




    $begingroup$
    Interesting approach to the issue. I see how if one thinks of a person-level dataset, you have a constant for gender alongside another constant (the intercept). But estimation works on the full dataset, and not on a person by person level. And if you look at model specification in lme4 (e.g. equation 2 in cran.r-project.org/web/packages/lme4/vignettes/Theory.pdf), all that matters is that the design matrix for the random effects across all persons is a valid one, so no column is a linear combination of others; and there is information in the data to estimate the variance components.
    $endgroup$
    – Heteroskedastic Jim
    May 18 at 16:50






  • 1




    $begingroup$
    When the model is correctly specified, for females, the male random slope = 0, and vice-versa. Intuitively, the meaning is that the effect of gender is not the same for every human. A standard approach would be to interact gender and race. Here, it's an interaction between gender and person indicator. The difference would vary across subjects, yes. If A is fem and B, F are male. Then the difference "due to" gender comparing A to B is different than same "effect" comparing A to F.
    $endgroup$
    – Heteroskedastic Jim
    May 18 at 17:00






  • 1




    $begingroup$
    Yes, I'd answer the question if you post one. And I have an example in mind.
    $endgroup$
    – Heteroskedastic Jim
    May 18 at 17:13
















8












$begingroup$

The first and foremost consideration that should drive the specification of random effects in a mixed effects model is the study design. Here are some examples that illustrate how the design affects the model specification.



Example 1



If you have a study in which you randomly selected patients from a target population of patients and measured an outcome variable (e.g., CD4 cell count) at several time points, along with time-varying and/or time-invarying predictor variables, then you would want to include at a minimum a random patient effect (i.e., a random patient intercept) to account for the natural nesting of repeated outcome observations within a patient.



Example 2



If you have a study in which you randomly selected a set of hospitals from a target population of hospitals, and then you randomly selected a set of patients from each hospital such that each patient would provide multiple measurements for an outcome variable (e.g., CD4 count), then you would need to include (at a minimum) a random hospital effect and a random patient effect in your model.



-------------------------------------------------


In the first example, patient is a random grouping factor. In the second example, hospital and patient are random grouping factors, with patient nested within hospital (since the patients randomly selected within a hospital are unique to that hospital and will not appear in any other hospital).



In some study designs, it is possible to have either fully crossed or partially crossed random grouping factors. For instance, you could have a study where some patients end up attending multiple hospitals throughout the duration of the study, in which case the patient and hospital would likely be partially crossed random grouping factors.



So paying attention to the study design helps identify the random grouping factors, each of which will be allowed its own random set of intercepts in the model - one intercept per level of random grouping factor.



The second consideration in the mixed effects model specification is to think about what predictor variables in the model can have varying (or random) effects across the levels of the grouping factor(s).



For Example 1, let's assume we measured the predictor blood pressure for each patient at all the time points where we also measured the outcome variable CD4 cell count - there were 4 time points per patient (say, once a week, for a total of 4 weeks). Let's also assume we measured the predictor gender. The blood pressure values will change from one week to the other for each patient, in tandem with the values of the CD4 cell counts. If we have reasons to believe that the association between CD4 counts and blood pressure values will be different from patient to patient, then we can allow the slope of blood pressure in the model to vary randomly across patients - we can achieve this by including a random effect of blood pressure in the model. The gender value will not change from one week to another for a patient, so there is no need to allow for a random effect of gender in our model. In the context of this example, we say that blood pressure is a within-patient (or within-subject) predictor variable, whereas gender is a between-patients (or between-patients) predictor variable. Only within-patient predictor variables can be allowed to have varying (or random) effects across the levels of the corresponding random grouping factor.



For Example 2, we can have predictor variables that refer to the hospitals included in the study (e.g., type of hospital) and/or predictor variables that refer to the patients within those hospitals (e.g., patient gender, patient blood pressure). The patient-specific predictor variables, for instance, can be within-patient predictors whose values change from occasion to occasion for the same patient, or between-patient predictors, whose values are invariant to occasion for each patient but change from one patient to another. The within-patient predictors can have varying (or random) effects across patients, etc.



So the inclusion of random effects in your model ultimately depends on whether your study design includes any random grouping factor (e.g., patient, hospital) and whether you have predictor variables whose effects can be assumed to vary across the levels of these random grouping factors.






share|cite|improve this answer











$endgroup$








  • 1




    $begingroup$
    +1, but "Only within-patient predictor variables can be allowed to have varying (or random) effects across the levels of the corresponding random grouping factor." This is not really true. If patients are measured four times, then there is information to compute a patient-level gender effect. The effect of gender can be allowed to vary across persons. Older ways of formulating the model do not allow for this hence this belief. But more recent model formulations, such as in lme4, allow for between-person variables to have effects that vary by person.
    $endgroup$
    – Heteroskedastic Jim
    May 18 at 15:24










  • $begingroup$
    @HeteroskedasticJim: Interesting! How can we compute the effect of gender within one subject when there is no variability in the values of gender within that subject? The effect of gender within one person would imply that when that person switches genders from male to female, say, there is a difference in the expected value of their response. The variability of the gender effects across subjects would imply that the difference would vary across subjects - so all those subjects would have to have a gender switch! Just trying to understand intuitively what is going on here.
    $endgroup$
    – Isabella Ghement
    May 18 at 15:52







  • 1




    $begingroup$
    Interesting approach to the issue. I see how if one thinks of a person-level dataset, you have a constant for gender alongside another constant (the intercept). But estimation works on the full dataset, and not on a person by person level. And if you look at model specification in lme4 (e.g. equation 2 in cran.r-project.org/web/packages/lme4/vignettes/Theory.pdf), all that matters is that the design matrix for the random effects across all persons is a valid one, so no column is a linear combination of others; and there is information in the data to estimate the variance components.
    $endgroup$
    – Heteroskedastic Jim
    May 18 at 16:50






  • 1




    $begingroup$
    When the model is correctly specified, for females, the male random slope = 0, and vice-versa. Intuitively, the meaning is that the effect of gender is not the same for every human. A standard approach would be to interact gender and race. Here, it's an interaction between gender and person indicator. The difference would vary across subjects, yes. If A is fem and B, F are male. Then the difference "due to" gender comparing A to B is different than same "effect" comparing A to F.
    $endgroup$
    – Heteroskedastic Jim
    May 18 at 17:00






  • 1




    $begingroup$
    Yes, I'd answer the question if you post one. And I have an example in mind.
    $endgroup$
    – Heteroskedastic Jim
    May 18 at 17:13














8












8








8





$begingroup$

The first and foremost consideration that should drive the specification of random effects in a mixed effects model is the study design. Here are some examples that illustrate how the design affects the model specification.



Example 1



If you have a study in which you randomly selected patients from a target population of patients and measured an outcome variable (e.g., CD4 cell count) at several time points, along with time-varying and/or time-invarying predictor variables, then you would want to include at a minimum a random patient effect (i.e., a random patient intercept) to account for the natural nesting of repeated outcome observations within a patient.



Example 2



If you have a study in which you randomly selected a set of hospitals from a target population of hospitals, and then you randomly selected a set of patients from each hospital such that each patient would provide multiple measurements for an outcome variable (e.g., CD4 count), then you would need to include (at a minimum) a random hospital effect and a random patient effect in your model.



-------------------------------------------------


In the first example, patient is a random grouping factor. In the second example, hospital and patient are random grouping factors, with patient nested within hospital (since the patients randomly selected within a hospital are unique to that hospital and will not appear in any other hospital).



In some study designs, it is possible to have either fully crossed or partially crossed random grouping factors. For instance, you could have a study where some patients end up attending multiple hospitals throughout the duration of the study, in which case the patient and hospital would likely be partially crossed random grouping factors.



So paying attention to the study design helps identify the random grouping factors, each of which will be allowed its own random set of intercepts in the model - one intercept per level of random grouping factor.



The second consideration in the mixed effects model specification is to think about what predictor variables in the model can have varying (or random) effects across the levels of the grouping factor(s).



For Example 1, let's assume we measured the predictor blood pressure for each patient at all the time points where we also measured the outcome variable CD4 cell count - there were 4 time points per patient (say, once a week, for a total of 4 weeks). Let's also assume we measured the predictor gender. The blood pressure values will change from one week to the other for each patient, in tandem with the values of the CD4 cell counts. If we have reasons to believe that the association between CD4 counts and blood pressure values will be different from patient to patient, then we can allow the slope of blood pressure in the model to vary randomly across patients - we can achieve this by including a random effect of blood pressure in the model. The gender value will not change from one week to another for a patient, so there is no need to allow for a random effect of gender in our model. In the context of this example, we say that blood pressure is a within-patient (or within-subject) predictor variable, whereas gender is a between-patients (or between-patients) predictor variable. Only within-patient predictor variables can be allowed to have varying (or random) effects across the levels of the corresponding random grouping factor.



For Example 2, we can have predictor variables that refer to the hospitals included in the study (e.g., type of hospital) and/or predictor variables that refer to the patients within those hospitals (e.g., patient gender, patient blood pressure). The patient-specific predictor variables, for instance, can be within-patient predictors whose values change from occasion to occasion for the same patient, or between-patient predictors, whose values are invariant to occasion for each patient but change from one patient to another. The within-patient predictors can have varying (or random) effects across patients, etc.



So the inclusion of random effects in your model ultimately depends on whether your study design includes any random grouping factor (e.g., patient, hospital) and whether you have predictor variables whose effects can be assumed to vary across the levels of these random grouping factors.






share|cite|improve this answer











$endgroup$



The first and foremost consideration that should drive the specification of random effects in a mixed effects model is the study design. Here are some examples that illustrate how the design affects the model specification.



Example 1



If you have a study in which you randomly selected patients from a target population of patients and measured an outcome variable (e.g., CD4 cell count) at several time points, along with time-varying and/or time-invarying predictor variables, then you would want to include at a minimum a random patient effect (i.e., a random patient intercept) to account for the natural nesting of repeated outcome observations within a patient.



Example 2



If you have a study in which you randomly selected a set of hospitals from a target population of hospitals, and then you randomly selected a set of patients from each hospital such that each patient would provide multiple measurements for an outcome variable (e.g., CD4 count), then you would need to include (at a minimum) a random hospital effect and a random patient effect in your model.



-------------------------------------------------


In the first example, patient is a random grouping factor. In the second example, hospital and patient are random grouping factors, with patient nested within hospital (since the patients randomly selected within a hospital are unique to that hospital and will not appear in any other hospital).



In some study designs, it is possible to have either fully crossed or partially crossed random grouping factors. For instance, you could have a study where some patients end up attending multiple hospitals throughout the duration of the study, in which case the patient and hospital would likely be partially crossed random grouping factors.



So paying attention to the study design helps identify the random grouping factors, each of which will be allowed its own random set of intercepts in the model - one intercept per level of random grouping factor.



The second consideration in the mixed effects model specification is to think about what predictor variables in the model can have varying (or random) effects across the levels of the grouping factor(s).



For Example 1, let's assume we measured the predictor blood pressure for each patient at all the time points where we also measured the outcome variable CD4 cell count - there were 4 time points per patient (say, once a week, for a total of 4 weeks). Let's also assume we measured the predictor gender. The blood pressure values will change from one week to the other for each patient, in tandem with the values of the CD4 cell counts. If we have reasons to believe that the association between CD4 counts and blood pressure values will be different from patient to patient, then we can allow the slope of blood pressure in the model to vary randomly across patients - we can achieve this by including a random effect of blood pressure in the model. The gender value will not change from one week to another for a patient, so there is no need to allow for a random effect of gender in our model. In the context of this example, we say that blood pressure is a within-patient (or within-subject) predictor variable, whereas gender is a between-patients (or between-patients) predictor variable. Only within-patient predictor variables can be allowed to have varying (or random) effects across the levels of the corresponding random grouping factor.



For Example 2, we can have predictor variables that refer to the hospitals included in the study (e.g., type of hospital) and/or predictor variables that refer to the patients within those hospitals (e.g., patient gender, patient blood pressure). The patient-specific predictor variables, for instance, can be within-patient predictors whose values change from occasion to occasion for the same patient, or between-patient predictors, whose values are invariant to occasion for each patient but change from one patient to another. The within-patient predictors can have varying (or random) effects across patients, etc.



So the inclusion of random effects in your model ultimately depends on whether your study design includes any random grouping factor (e.g., patient, hospital) and whether you have predictor variables whose effects can be assumed to vary across the levels of these random grouping factors.







share|cite|improve this answer














share|cite|improve this answer



share|cite|improve this answer








edited May 16 at 18:54

























answered May 16 at 15:57









Isabella GhementIsabella Ghement

8,4551423




8,4551423







  • 1




    $begingroup$
    +1, but "Only within-patient predictor variables can be allowed to have varying (or random) effects across the levels of the corresponding random grouping factor." This is not really true. If patients are measured four times, then there is information to compute a patient-level gender effect. The effect of gender can be allowed to vary across persons. Older ways of formulating the model do not allow for this hence this belief. But more recent model formulations, such as in lme4, allow for between-person variables to have effects that vary by person.
    $endgroup$
    – Heteroskedastic Jim
    May 18 at 15:24










  • $begingroup$
    @HeteroskedasticJim: Interesting! How can we compute the effect of gender within one subject when there is no variability in the values of gender within that subject? The effect of gender within one person would imply that when that person switches genders from male to female, say, there is a difference in the expected value of their response. The variability of the gender effects across subjects would imply that the difference would vary across subjects - so all those subjects would have to have a gender switch! Just trying to understand intuitively what is going on here.
    $endgroup$
    – Isabella Ghement
    May 18 at 15:52







  • 1




    $begingroup$
    Interesting approach to the issue. I see how if one thinks of a person-level dataset, you have a constant for gender alongside another constant (the intercept). But estimation works on the full dataset, and not on a person by person level. And if you look at model specification in lme4 (e.g. equation 2 in cran.r-project.org/web/packages/lme4/vignettes/Theory.pdf), all that matters is that the design matrix for the random effects across all persons is a valid one, so no column is a linear combination of others; and there is information in the data to estimate the variance components.
    $endgroup$
    – Heteroskedastic Jim
    May 18 at 16:50






  • 1




    $begingroup$
    When the model is correctly specified, for females, the male random slope = 0, and vice-versa. Intuitively, the meaning is that the effect of gender is not the same for every human. A standard approach would be to interact gender and race. Here, it's an interaction between gender and person indicator. The difference would vary across subjects, yes. If A is fem and B, F are male. Then the difference "due to" gender comparing A to B is different than same "effect" comparing A to F.
    $endgroup$
    – Heteroskedastic Jim
    May 18 at 17:00






  • 1




    $begingroup$
    Yes, I'd answer the question if you post one. And I have an example in mind.
    $endgroup$
    – Heteroskedastic Jim
    May 18 at 17:13













  • 1




    $begingroup$
    +1, but "Only within-patient predictor variables can be allowed to have varying (or random) effects across the levels of the corresponding random grouping factor." This is not really true. If patients are measured four times, then there is information to compute a patient-level gender effect. The effect of gender can be allowed to vary across persons. Older ways of formulating the model do not allow for this hence this belief. But more recent model formulations, such as in lme4, allow for between-person variables to have effects that vary by person.
    $endgroup$
    – Heteroskedastic Jim
    May 18 at 15:24










  • $begingroup$
    @HeteroskedasticJim: Interesting! How can we compute the effect of gender within one subject when there is no variability in the values of gender within that subject? The effect of gender within one person would imply that when that person switches genders from male to female, say, there is a difference in the expected value of their response. The variability of the gender effects across subjects would imply that the difference would vary across subjects - so all those subjects would have to have a gender switch! Just trying to understand intuitively what is going on here.
    $endgroup$
    – Isabella Ghement
    May 18 at 15:52







  • 1




    $begingroup$
    Interesting approach to the issue. I see how if one thinks of a person-level dataset, you have a constant for gender alongside another constant (the intercept). But estimation works on the full dataset, and not on a person by person level. And if you look at model specification in lme4 (e.g. equation 2 in cran.r-project.org/web/packages/lme4/vignettes/Theory.pdf), all that matters is that the design matrix for the random effects across all persons is a valid one, so no column is a linear combination of others; and there is information in the data to estimate the variance components.
    $endgroup$
    – Heteroskedastic Jim
    May 18 at 16:50






  • 1




    $begingroup$
    When the model is correctly specified, for females, the male random slope = 0, and vice-versa. Intuitively, the meaning is that the effect of gender is not the same for every human. A standard approach would be to interact gender and race. Here, it's an interaction between gender and person indicator. The difference would vary across subjects, yes. If A is fem and B, F are male. Then the difference "due to" gender comparing A to B is different than same "effect" comparing A to F.
    $endgroup$
    – Heteroskedastic Jim
    May 18 at 17:00






  • 1




    $begingroup$
    Yes, I'd answer the question if you post one. And I have an example in mind.
    $endgroup$
    – Heteroskedastic Jim
    May 18 at 17:13








1




1




$begingroup$
+1, but "Only within-patient predictor variables can be allowed to have varying (or random) effects across the levels of the corresponding random grouping factor." This is not really true. If patients are measured four times, then there is information to compute a patient-level gender effect. The effect of gender can be allowed to vary across persons. Older ways of formulating the model do not allow for this hence this belief. But more recent model formulations, such as in lme4, allow for between-person variables to have effects that vary by person.
$endgroup$
– Heteroskedastic Jim
May 18 at 15:24




$begingroup$
+1, but "Only within-patient predictor variables can be allowed to have varying (or random) effects across the levels of the corresponding random grouping factor." This is not really true. If patients are measured four times, then there is information to compute a patient-level gender effect. The effect of gender can be allowed to vary across persons. Older ways of formulating the model do not allow for this hence this belief. But more recent model formulations, such as in lme4, allow for between-person variables to have effects that vary by person.
$endgroup$
– Heteroskedastic Jim
May 18 at 15:24












$begingroup$
@HeteroskedasticJim: Interesting! How can we compute the effect of gender within one subject when there is no variability in the values of gender within that subject? The effect of gender within one person would imply that when that person switches genders from male to female, say, there is a difference in the expected value of their response. The variability of the gender effects across subjects would imply that the difference would vary across subjects - so all those subjects would have to have a gender switch! Just trying to understand intuitively what is going on here.
$endgroup$
– Isabella Ghement
May 18 at 15:52





$begingroup$
@HeteroskedasticJim: Interesting! How can we compute the effect of gender within one subject when there is no variability in the values of gender within that subject? The effect of gender within one person would imply that when that person switches genders from male to female, say, there is a difference in the expected value of their response. The variability of the gender effects across subjects would imply that the difference would vary across subjects - so all those subjects would have to have a gender switch! Just trying to understand intuitively what is going on here.
$endgroup$
– Isabella Ghement
May 18 at 15:52





1




1




$begingroup$
Interesting approach to the issue. I see how if one thinks of a person-level dataset, you have a constant for gender alongside another constant (the intercept). But estimation works on the full dataset, and not on a person by person level. And if you look at model specification in lme4 (e.g. equation 2 in cran.r-project.org/web/packages/lme4/vignettes/Theory.pdf), all that matters is that the design matrix for the random effects across all persons is a valid one, so no column is a linear combination of others; and there is information in the data to estimate the variance components.
$endgroup$
– Heteroskedastic Jim
May 18 at 16:50




$begingroup$
Interesting approach to the issue. I see how if one thinks of a person-level dataset, you have a constant for gender alongside another constant (the intercept). But estimation works on the full dataset, and not on a person by person level. And if you look at model specification in lme4 (e.g. equation 2 in cran.r-project.org/web/packages/lme4/vignettes/Theory.pdf), all that matters is that the design matrix for the random effects across all persons is a valid one, so no column is a linear combination of others; and there is information in the data to estimate the variance components.
$endgroup$
– Heteroskedastic Jim
May 18 at 16:50




1




1




$begingroup$
When the model is correctly specified, for females, the male random slope = 0, and vice-versa. Intuitively, the meaning is that the effect of gender is not the same for every human. A standard approach would be to interact gender and race. Here, it's an interaction between gender and person indicator. The difference would vary across subjects, yes. If A is fem and B, F are male. Then the difference "due to" gender comparing A to B is different than same "effect" comparing A to F.
$endgroup$
– Heteroskedastic Jim
May 18 at 17:00




$begingroup$
When the model is correctly specified, for females, the male random slope = 0, and vice-versa. Intuitively, the meaning is that the effect of gender is not the same for every human. A standard approach would be to interact gender and race. Here, it's an interaction between gender and person indicator. The difference would vary across subjects, yes. If A is fem and B, F are male. Then the difference "due to" gender comparing A to B is different than same "effect" comparing A to F.
$endgroup$
– Heteroskedastic Jim
May 18 at 17:00




1




1




$begingroup$
Yes, I'd answer the question if you post one. And I have an example in mind.
$endgroup$
– Heteroskedastic Jim
May 18 at 17:13





$begingroup$
Yes, I'd answer the question if you post one. And I have an example in mind.
$endgroup$
– Heteroskedastic Jim
May 18 at 17:13


















draft saved

draft discarded
















































Thanks for contributing an answer to Cross Validated!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

Use MathJax to format equations. MathJax reference.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstats.stackexchange.com%2fquestions%2f408646%2fshould-all-adjustments-be-random-effects-in-a-mixed-linear-effect%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

Get RecordId in LWC From Community PageLWC Community recordId undefinedhow to get Personal Access Token from my integrated application LWC. I am using js onlylwc quick action from Opportunity page(aura:component) and not getting @api recordIdLWC Community recordId undefinedLWC - How to get label name of buttonsLWC: Add a region in custom community themeVisual force page redirection from lightning communityLWC NavigationMixin does not work in CommunityInvoking LWC component from a plain URL - Read URL Parameter inside LWCLWC download PDF fileLWC Get Pick-list Field Values