Accounting for grouped random effects in lme4
$begingroup$
I am editing my question as it was not detailed enough. I made an (unsuccessful) shortcut. Sorry, here is the entire story.
In my experiment I test subjects' reactions to some (simulated) situations. The subject read a scenario and then an expert evaluates the subject's behavior. The evaluation ranges from 1 to 5. There are 10 different simulations, and each subject takes all of them; thus, from each subject I have 10 data points. My experiment is went on 30 days. In each day, the same 10 simulations are used. In other words, in each day, subjects and simulations are fully crossed. Each day the simulations are different.
There are 3 categories of simulations (A, B and C). The categories are, from a theoretical perspective, different one from the other. Category A is tested by 3 simulations (a1, a2, a3); B by 3 (b1, b2, b3); C by 4 (c1, c2, c3, c4). a1:c4 at day 1 are different from a1:c4 at day 2 and so on.
The 3 categories are the only ones I am interested in. In that sense, I think they should be treated as fixed effects. Each category is tested/represented by some simulations. Yet, for each category there are an infinity of possible simulations and I just sampled some. In that sense simulations are random.
The only question I am interested in here, is about the effect of the subject gender on the grades. I want to control for all other parameters. My question is how to account for the simulation and category. I would like to extrapolate my results beyond participants and the simulations representing the category. Yet it is also possible that gender would interact with category or simulation.
So here is one "basic" model:
lmer(grade ~ gender + (1|subject) + (1|simulation:day), data = My_data)
Yet, this model does not account for the possibility that gender has a different effect on simulations. So here is another one trying that.
lmer(grade ~ gender + (1|subject) + (1 + gender|simulation:day), data =
My_data)
And here I get stuck. How does category play a role? Do I need to enter it as fixed effect? If yes, what about simulations? Does the following make sense?
lmer(grade ~ gender*category + (1 + category|subject) + (1 +
gender|simulation:day), data = My_data)
Or is it better to give up the simulations, and treat category as random? But in this case, for a given day, the same category will appear several time for each subject (e.g., A will appear 3 times). Is't that a problem? As follow:
lmer(grade ~ gender + (1 + subject) + (1 + gender|category),
data =My_data)
A final point: I have a lot of data (several thousands of participants), so convergence should not be a problem.
Thanks a lot for the help
r mixed-model lme4-nlme
$endgroup$
add a comment |
$begingroup$
I am editing my question as it was not detailed enough. I made an (unsuccessful) shortcut. Sorry, here is the entire story.
In my experiment I test subjects' reactions to some (simulated) situations. The subject read a scenario and then an expert evaluates the subject's behavior. The evaluation ranges from 1 to 5. There are 10 different simulations, and each subject takes all of them; thus, from each subject I have 10 data points. My experiment is went on 30 days. In each day, the same 10 simulations are used. In other words, in each day, subjects and simulations are fully crossed. Each day the simulations are different.
There are 3 categories of simulations (A, B and C). The categories are, from a theoretical perspective, different one from the other. Category A is tested by 3 simulations (a1, a2, a3); B by 3 (b1, b2, b3); C by 4 (c1, c2, c3, c4). a1:c4 at day 1 are different from a1:c4 at day 2 and so on.
The 3 categories are the only ones I am interested in. In that sense, I think they should be treated as fixed effects. Each category is tested/represented by some simulations. Yet, for each category there are an infinity of possible simulations and I just sampled some. In that sense simulations are random.
The only question I am interested in here, is about the effect of the subject gender on the grades. I want to control for all other parameters. My question is how to account for the simulation and category. I would like to extrapolate my results beyond participants and the simulations representing the category. Yet it is also possible that gender would interact with category or simulation.
So here is one "basic" model:
lmer(grade ~ gender + (1|subject) + (1|simulation:day), data = My_data)
Yet, this model does not account for the possibility that gender has a different effect on simulations. So here is another one trying that.
lmer(grade ~ gender + (1|subject) + (1 + gender|simulation:day), data =
My_data)
And here I get stuck. How does category play a role? Do I need to enter it as fixed effect? If yes, what about simulations? Does the following make sense?
lmer(grade ~ gender*category + (1 + category|subject) + (1 +
gender|simulation:day), data = My_data)
Or is it better to give up the simulations, and treat category as random? But in this case, for a given day, the same category will appear several time for each subject (e.g., A will appear 3 times). Is't that a problem? As follow:
lmer(grade ~ gender + (1 + subject) + (1 + gender|category),
data =My_data)
A final point: I have a lot of data (several thousands of participants), so convergence should not be a problem.
Thanks a lot for the help
r mixed-model lme4-nlme
$endgroup$
1
$begingroup$
What is your research question ? Are you interested in the treatment effects ofstimulus
? Please edit your question to include the output ofstr(My_data)
and the output ofxtabs(~ stimulus + subject, My_data)
andxtabs(~ category + subject, My_data)
andxtabs(~ category + stimulus, My_data)
$endgroup$
– Robert Long
10 hours ago
$begingroup$
You say: "for each category there are an infinity of possible simulations and I just sampled some." Were any of the individual simulations used more than once? Or did you have 3N (where N is the number of participants) separate simulations that were in Category A, for example, and similarly for Categories B and C? How many simulations were there overall for each of the Categories?
$endgroup$
– EdM
7 hours ago
$begingroup$
Per your update, I believe we are thinking about different uses for the terms random and fixed effects - see stats.stackexchange.com/questions/4700/… for a discussion and on that page: statmodeling.stat.columbia.edu/2005/01/25/why_i_dont_use. I am not entirely sure how to do what you want within LME4. But in general, if you are asking about a linear mixed effect model, like with lmer( ), people will most likely think you are trying to find effects like I specified below.
$endgroup$
– Craig K. Van Pay
5 hours ago
add a comment |
$begingroup$
I am editing my question as it was not detailed enough. I made an (unsuccessful) shortcut. Sorry, here is the entire story.
In my experiment I test subjects' reactions to some (simulated) situations. The subject read a scenario and then an expert evaluates the subject's behavior. The evaluation ranges from 1 to 5. There are 10 different simulations, and each subject takes all of them; thus, from each subject I have 10 data points. My experiment is went on 30 days. In each day, the same 10 simulations are used. In other words, in each day, subjects and simulations are fully crossed. Each day the simulations are different.
There are 3 categories of simulations (A, B and C). The categories are, from a theoretical perspective, different one from the other. Category A is tested by 3 simulations (a1, a2, a3); B by 3 (b1, b2, b3); C by 4 (c1, c2, c3, c4). a1:c4 at day 1 are different from a1:c4 at day 2 and so on.
The 3 categories are the only ones I am interested in. In that sense, I think they should be treated as fixed effects. Each category is tested/represented by some simulations. Yet, for each category there are an infinity of possible simulations and I just sampled some. In that sense simulations are random.
The only question I am interested in here, is about the effect of the subject gender on the grades. I want to control for all other parameters. My question is how to account for the simulation and category. I would like to extrapolate my results beyond participants and the simulations representing the category. Yet it is also possible that gender would interact with category or simulation.
So here is one "basic" model:
lmer(grade ~ gender + (1|subject) + (1|simulation:day), data = My_data)
Yet, this model does not account for the possibility that gender has a different effect on simulations. So here is another one trying that.
lmer(grade ~ gender + (1|subject) + (1 + gender|simulation:day), data =
My_data)
And here I get stuck. How does category play a role? Do I need to enter it as fixed effect? If yes, what about simulations? Does the following make sense?
lmer(grade ~ gender*category + (1 + category|subject) + (1 +
gender|simulation:day), data = My_data)
Or is it better to give up the simulations, and treat category as random? But in this case, for a given day, the same category will appear several time for each subject (e.g., A will appear 3 times). Is't that a problem? As follow:
lmer(grade ~ gender + (1 + subject) + (1 + gender|category),
data =My_data)
A final point: I have a lot of data (several thousands of participants), so convergence should not be a problem.
Thanks a lot for the help
r mixed-model lme4-nlme
$endgroup$
I am editing my question as it was not detailed enough. I made an (unsuccessful) shortcut. Sorry, here is the entire story.
In my experiment I test subjects' reactions to some (simulated) situations. The subject read a scenario and then an expert evaluates the subject's behavior. The evaluation ranges from 1 to 5. There are 10 different simulations, and each subject takes all of them; thus, from each subject I have 10 data points. My experiment is went on 30 days. In each day, the same 10 simulations are used. In other words, in each day, subjects and simulations are fully crossed. Each day the simulations are different.
There are 3 categories of simulations (A, B and C). The categories are, from a theoretical perspective, different one from the other. Category A is tested by 3 simulations (a1, a2, a3); B by 3 (b1, b2, b3); C by 4 (c1, c2, c3, c4). a1:c4 at day 1 are different from a1:c4 at day 2 and so on.
The 3 categories are the only ones I am interested in. In that sense, I think they should be treated as fixed effects. Each category is tested/represented by some simulations. Yet, for each category there are an infinity of possible simulations and I just sampled some. In that sense simulations are random.
The only question I am interested in here, is about the effect of the subject gender on the grades. I want to control for all other parameters. My question is how to account for the simulation and category. I would like to extrapolate my results beyond participants and the simulations representing the category. Yet it is also possible that gender would interact with category or simulation.
So here is one "basic" model:
lmer(grade ~ gender + (1|subject) + (1|simulation:day), data = My_data)
Yet, this model does not account for the possibility that gender has a different effect on simulations. So here is another one trying that.
lmer(grade ~ gender + (1|subject) + (1 + gender|simulation:day), data =
My_data)
And here I get stuck. How does category play a role? Do I need to enter it as fixed effect? If yes, what about simulations? Does the following make sense?
lmer(grade ~ gender*category + (1 + category|subject) + (1 +
gender|simulation:day), data = My_data)
Or is it better to give up the simulations, and treat category as random? But in this case, for a given day, the same category will appear several time for each subject (e.g., A will appear 3 times). Is't that a problem? As follow:
lmer(grade ~ gender + (1 + subject) + (1 + gender|category),
data =My_data)
A final point: I have a lot of data (several thousands of participants), so convergence should not be a problem.
Thanks a lot for the help
r mixed-model lme4-nlme
r mixed-model lme4-nlme
edited 5 hours ago
Rtist
asked 12 hours ago
RtistRtist
1384
1384
1
$begingroup$
What is your research question ? Are you interested in the treatment effects ofstimulus
? Please edit your question to include the output ofstr(My_data)
and the output ofxtabs(~ stimulus + subject, My_data)
andxtabs(~ category + subject, My_data)
andxtabs(~ category + stimulus, My_data)
$endgroup$
– Robert Long
10 hours ago
$begingroup$
You say: "for each category there are an infinity of possible simulations and I just sampled some." Were any of the individual simulations used more than once? Or did you have 3N (where N is the number of participants) separate simulations that were in Category A, for example, and similarly for Categories B and C? How many simulations were there overall for each of the Categories?
$endgroup$
– EdM
7 hours ago
$begingroup$
Per your update, I believe we are thinking about different uses for the terms random and fixed effects - see stats.stackexchange.com/questions/4700/… for a discussion and on that page: statmodeling.stat.columbia.edu/2005/01/25/why_i_dont_use. I am not entirely sure how to do what you want within LME4. But in general, if you are asking about a linear mixed effect model, like with lmer( ), people will most likely think you are trying to find effects like I specified below.
$endgroup$
– Craig K. Van Pay
5 hours ago
add a comment |
1
$begingroup$
What is your research question ? Are you interested in the treatment effects ofstimulus
? Please edit your question to include the output ofstr(My_data)
and the output ofxtabs(~ stimulus + subject, My_data)
andxtabs(~ category + subject, My_data)
andxtabs(~ category + stimulus, My_data)
$endgroup$
– Robert Long
10 hours ago
$begingroup$
You say: "for each category there are an infinity of possible simulations and I just sampled some." Were any of the individual simulations used more than once? Or did you have 3N (where N is the number of participants) separate simulations that were in Category A, for example, and similarly for Categories B and C? How many simulations were there overall for each of the Categories?
$endgroup$
– EdM
7 hours ago
$begingroup$
Per your update, I believe we are thinking about different uses for the terms random and fixed effects - see stats.stackexchange.com/questions/4700/… for a discussion and on that page: statmodeling.stat.columbia.edu/2005/01/25/why_i_dont_use. I am not entirely sure how to do what you want within LME4. But in general, if you are asking about a linear mixed effect model, like with lmer( ), people will most likely think you are trying to find effects like I specified below.
$endgroup$
– Craig K. Van Pay
5 hours ago
1
1
$begingroup$
What is your research question ? Are you interested in the treatment effects of
stimulus
? Please edit your question to include the output of str(My_data)
and the output of xtabs(~ stimulus + subject, My_data)
and xtabs(~ category + subject, My_data)
and xtabs(~ category + stimulus, My_data)
$endgroup$
– Robert Long
10 hours ago
$begingroup$
What is your research question ? Are you interested in the treatment effects of
stimulus
? Please edit your question to include the output of str(My_data)
and the output of xtabs(~ stimulus + subject, My_data)
and xtabs(~ category + subject, My_data)
and xtabs(~ category + stimulus, My_data)
$endgroup$
– Robert Long
10 hours ago
$begingroup$
You say: "for each category there are an infinity of possible simulations and I just sampled some." Were any of the individual simulations used more than once? Or did you have 3N (where N is the number of participants) separate simulations that were in Category A, for example, and similarly for Categories B and C? How many simulations were there overall for each of the Categories?
$endgroup$
– EdM
7 hours ago
$begingroup$
You say: "for each category there are an infinity of possible simulations and I just sampled some." Were any of the individual simulations used more than once? Or did you have 3N (where N is the number of participants) separate simulations that were in Category A, for example, and similarly for Categories B and C? How many simulations were there overall for each of the Categories?
$endgroup$
– EdM
7 hours ago
$begingroup$
Per your update, I believe we are thinking about different uses for the terms random and fixed effects - see stats.stackexchange.com/questions/4700/… for a discussion and on that page: statmodeling.stat.columbia.edu/2005/01/25/why_i_dont_use. I am not entirely sure how to do what you want within LME4. But in general, if you are asking about a linear mixed effect model, like with lmer( ), people will most likely think you are trying to find effects like I specified below.
$endgroup$
– Craig K. Van Pay
5 hours ago
$begingroup$
Per your update, I believe we are thinking about different uses for the terms random and fixed effects - see stats.stackexchange.com/questions/4700/… for a discussion and on that page: statmodeling.stat.columbia.edu/2005/01/25/why_i_dont_use. I am not entirely sure how to do what you want within LME4. But in general, if you are asking about a linear mixed effect model, like with lmer( ), people will most likely think you are trying to find effects like I specified below.
$endgroup$
– Craig K. Van Pay
5 hours ago
add a comment |
3 Answers
3
active
oldest
votes
$begingroup$
If you believe the different categories vary in terms of their measurement and you want to test that, you need to model the category as a random intercept with (1|category).
However, I think we need more information as to what you are actually looking to decide. For example, are you wondering if each person measures them different? Or if each stimulus is measured differently?
$endgroup$
$begingroup$
The category could vary. Yet, there are only 3 of them (each one being measure with different stimuli) and theoretically there are no other categories. So it would be difficult to model them as random.
$endgroup$
– Rtist
5 hours ago
add a comment |
$begingroup$
It seems that in the model:
lmer(measure ~ category + (1|subject) + (1|stimulus), data = My_data)
category
is being used to denote the levels of stimulus
. As such, this does not make sense, since category
is not an actual variable.
Even though stimulus
is random in the sense that it has (presumably) been randomly assigned to each subject
, this does not mean that is should be included as a random effect - unless there is no interest in the treatment effect of stimulus
. In that case, you would simply be partitioning variance into the subject
level and the stimulus
level.
It seems more likely that you are in fact interested in the associations between each level of the stimulus
and the outcome - that is, you are interested in the treatment effect and therefore the model should be of the form:
measure ~ stimulus + (1|subject)
$endgroup$
2
$begingroup$
Interesting perspective, Robert! If the 10 stimuli are the only ones @Rtist is interested in, then your suggested approach makes sense. But if he only included the 10 stimuli in the study because he is interested in generalizing the findings of the study to all stimuli represented by these 10 items, then stimulus should be treated as a random grouping factor (assuming there are multiple observations for at least some of all the subject by stimulus combinations). It really all depends on the purpose of the study - if we don't know the purpose, we can only speculate about the model set up.
$endgroup$
– Isabella Ghement
11 hours ago
$begingroup$
@IsabellaGhement there are only 3 levels ofstimulus
, so fitting random effects for it and estimating a variance would not be advisable in my opinion.
$endgroup$
– Robert Long
11 hours ago
1
$begingroup$
But the question says each subject sees 10 stimuli and that these 10 stimuli can be categorized into 3 different categories? I am not suggesting stimulus category (3 levels) could be treated as a random grouping factor, but rather stimulus (10 levels). However, if there aren't repeated values of measure for each subject by stimulus combination OR if the research question calls for it (i.e., the 10 stimuli are the only ones @Rtist wants to learn something about), then the option you suggested would work.
$endgroup$
– Isabella Ghement
11 hours ago
1
$begingroup$
@IsabellaGhement perhaps I misunderstood the question. I read it thatstimulus
has 3 levels, not 10. Anyway, we can wait for clarification from @Rtist
$endgroup$
– Robert Long
10 hours ago
add a comment |
$begingroup$
In your setting, subject and stimulus seem to be fully crossed random grouping factors - since each subject sees each stimulus and (I am assuming) you are using the subjects and stimuli included in your studies to represent all the subjects and all the stimuli you wish to generalize your study findings to.
The key word here is grouping - for your model to be a linear mixed effects model (lmer), each subject by stimulus combination should act like a container which holds together a group of values for your measure outcome. All the values of measure that belong to the same container are more similar to each other than values that belong to different containers, as they are subjected to the same subject-level and stimulus-level influences (presuming these influences are constant over time).
The group of values in a specific container could arise, for instance, if you record the value of measure at several time points for each subject by stimulus combination, or under two or more different conditions, etc.
If you only have one value of measure per subject by stimulus combination, then you're dealing with a linear model (lm). There is no grouping of observations according to each subject per stimulus combination, so there are no random grouping factors which means there aren't any effects that can vary randomly across combinations of levels of the grouping factors (i.e., random effects). If there aren't any random effects, there can't be a mixed effects model, as such a model would require both fixed and random effects to be part of it!
If you do have multiple values of measure per container (i.e., subject by stimulus combination), then your model can include subject-level predictors (e.g., subject gender, subject age) and/or stimulus-level predictors (e.g., stimulus category).
$endgroup$
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstats.stackexchange.com%2fquestions%2f394706%2faccounting-for-grouped-random-effects-in-lme4%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
If you believe the different categories vary in terms of their measurement and you want to test that, you need to model the category as a random intercept with (1|category).
However, I think we need more information as to what you are actually looking to decide. For example, are you wondering if each person measures them different? Or if each stimulus is measured differently?
$endgroup$
$begingroup$
The category could vary. Yet, there are only 3 of them (each one being measure with different stimuli) and theoretically there are no other categories. So it would be difficult to model them as random.
$endgroup$
– Rtist
5 hours ago
add a comment |
$begingroup$
If you believe the different categories vary in terms of their measurement and you want to test that, you need to model the category as a random intercept with (1|category).
However, I think we need more information as to what you are actually looking to decide. For example, are you wondering if each person measures them different? Or if each stimulus is measured differently?
$endgroup$
$begingroup$
The category could vary. Yet, there are only 3 of them (each one being measure with different stimuli) and theoretically there are no other categories. So it would be difficult to model them as random.
$endgroup$
– Rtist
5 hours ago
add a comment |
$begingroup$
If you believe the different categories vary in terms of their measurement and you want to test that, you need to model the category as a random intercept with (1|category).
However, I think we need more information as to what you are actually looking to decide. For example, are you wondering if each person measures them different? Or if each stimulus is measured differently?
$endgroup$
If you believe the different categories vary in terms of their measurement and you want to test that, you need to model the category as a random intercept with (1|category).
However, I think we need more information as to what you are actually looking to decide. For example, are you wondering if each person measures them different? Or if each stimulus is measured differently?
answered 12 hours ago
Craig K. Van PayCraig K. Van Pay
687
687
$begingroup$
The category could vary. Yet, there are only 3 of them (each one being measure with different stimuli) and theoretically there are no other categories. So it would be difficult to model them as random.
$endgroup$
– Rtist
5 hours ago
add a comment |
$begingroup$
The category could vary. Yet, there are only 3 of them (each one being measure with different stimuli) and theoretically there are no other categories. So it would be difficult to model them as random.
$endgroup$
– Rtist
5 hours ago
$begingroup$
The category could vary. Yet, there are only 3 of them (each one being measure with different stimuli) and theoretically there are no other categories. So it would be difficult to model them as random.
$endgroup$
– Rtist
5 hours ago
$begingroup$
The category could vary. Yet, there are only 3 of them (each one being measure with different stimuli) and theoretically there are no other categories. So it would be difficult to model them as random.
$endgroup$
– Rtist
5 hours ago
add a comment |
$begingroup$
It seems that in the model:
lmer(measure ~ category + (1|subject) + (1|stimulus), data = My_data)
category
is being used to denote the levels of stimulus
. As such, this does not make sense, since category
is not an actual variable.
Even though stimulus
is random in the sense that it has (presumably) been randomly assigned to each subject
, this does not mean that is should be included as a random effect - unless there is no interest in the treatment effect of stimulus
. In that case, you would simply be partitioning variance into the subject
level and the stimulus
level.
It seems more likely that you are in fact interested in the associations between each level of the stimulus
and the outcome - that is, you are interested in the treatment effect and therefore the model should be of the form:
measure ~ stimulus + (1|subject)
$endgroup$
2
$begingroup$
Interesting perspective, Robert! If the 10 stimuli are the only ones @Rtist is interested in, then your suggested approach makes sense. But if he only included the 10 stimuli in the study because he is interested in generalizing the findings of the study to all stimuli represented by these 10 items, then stimulus should be treated as a random grouping factor (assuming there are multiple observations for at least some of all the subject by stimulus combinations). It really all depends on the purpose of the study - if we don't know the purpose, we can only speculate about the model set up.
$endgroup$
– Isabella Ghement
11 hours ago
$begingroup$
@IsabellaGhement there are only 3 levels ofstimulus
, so fitting random effects for it and estimating a variance would not be advisable in my opinion.
$endgroup$
– Robert Long
11 hours ago
1
$begingroup$
But the question says each subject sees 10 stimuli and that these 10 stimuli can be categorized into 3 different categories? I am not suggesting stimulus category (3 levels) could be treated as a random grouping factor, but rather stimulus (10 levels). However, if there aren't repeated values of measure for each subject by stimulus combination OR if the research question calls for it (i.e., the 10 stimuli are the only ones @Rtist wants to learn something about), then the option you suggested would work.
$endgroup$
– Isabella Ghement
11 hours ago
1
$begingroup$
@IsabellaGhement perhaps I misunderstood the question. I read it thatstimulus
has 3 levels, not 10. Anyway, we can wait for clarification from @Rtist
$endgroup$
– Robert Long
10 hours ago
add a comment |
$begingroup$
It seems that in the model:
lmer(measure ~ category + (1|subject) + (1|stimulus), data = My_data)
category
is being used to denote the levels of stimulus
. As such, this does not make sense, since category
is not an actual variable.
Even though stimulus
is random in the sense that it has (presumably) been randomly assigned to each subject
, this does not mean that is should be included as a random effect - unless there is no interest in the treatment effect of stimulus
. In that case, you would simply be partitioning variance into the subject
level and the stimulus
level.
It seems more likely that you are in fact interested in the associations between each level of the stimulus
and the outcome - that is, you are interested in the treatment effect and therefore the model should be of the form:
measure ~ stimulus + (1|subject)
$endgroup$
2
$begingroup$
Interesting perspective, Robert! If the 10 stimuli are the only ones @Rtist is interested in, then your suggested approach makes sense. But if he only included the 10 stimuli in the study because he is interested in generalizing the findings of the study to all stimuli represented by these 10 items, then stimulus should be treated as a random grouping factor (assuming there are multiple observations for at least some of all the subject by stimulus combinations). It really all depends on the purpose of the study - if we don't know the purpose, we can only speculate about the model set up.
$endgroup$
– Isabella Ghement
11 hours ago
$begingroup$
@IsabellaGhement there are only 3 levels ofstimulus
, so fitting random effects for it and estimating a variance would not be advisable in my opinion.
$endgroup$
– Robert Long
11 hours ago
1
$begingroup$
But the question says each subject sees 10 stimuli and that these 10 stimuli can be categorized into 3 different categories? I am not suggesting stimulus category (3 levels) could be treated as a random grouping factor, but rather stimulus (10 levels). However, if there aren't repeated values of measure for each subject by stimulus combination OR if the research question calls for it (i.e., the 10 stimuli are the only ones @Rtist wants to learn something about), then the option you suggested would work.
$endgroup$
– Isabella Ghement
11 hours ago
1
$begingroup$
@IsabellaGhement perhaps I misunderstood the question. I read it thatstimulus
has 3 levels, not 10. Anyway, we can wait for clarification from @Rtist
$endgroup$
– Robert Long
10 hours ago
add a comment |
$begingroup$
It seems that in the model:
lmer(measure ~ category + (1|subject) + (1|stimulus), data = My_data)
category
is being used to denote the levels of stimulus
. As such, this does not make sense, since category
is not an actual variable.
Even though stimulus
is random in the sense that it has (presumably) been randomly assigned to each subject
, this does not mean that is should be included as a random effect - unless there is no interest in the treatment effect of stimulus
. In that case, you would simply be partitioning variance into the subject
level and the stimulus
level.
It seems more likely that you are in fact interested in the associations between each level of the stimulus
and the outcome - that is, you are interested in the treatment effect and therefore the model should be of the form:
measure ~ stimulus + (1|subject)
$endgroup$
It seems that in the model:
lmer(measure ~ category + (1|subject) + (1|stimulus), data = My_data)
category
is being used to denote the levels of stimulus
. As such, this does not make sense, since category
is not an actual variable.
Even though stimulus
is random in the sense that it has (presumably) been randomly assigned to each subject
, this does not mean that is should be included as a random effect - unless there is no interest in the treatment effect of stimulus
. In that case, you would simply be partitioning variance into the subject
level and the stimulus
level.
It seems more likely that you are in fact interested in the associations between each level of the stimulus
and the outcome - that is, you are interested in the treatment effect and therefore the model should be of the form:
measure ~ stimulus + (1|subject)
answered 11 hours ago
Robert LongRobert Long
10.5k22549
10.5k22549
2
$begingroup$
Interesting perspective, Robert! If the 10 stimuli are the only ones @Rtist is interested in, then your suggested approach makes sense. But if he only included the 10 stimuli in the study because he is interested in generalizing the findings of the study to all stimuli represented by these 10 items, then stimulus should be treated as a random grouping factor (assuming there are multiple observations for at least some of all the subject by stimulus combinations). It really all depends on the purpose of the study - if we don't know the purpose, we can only speculate about the model set up.
$endgroup$
– Isabella Ghement
11 hours ago
$begingroup$
@IsabellaGhement there are only 3 levels ofstimulus
, so fitting random effects for it and estimating a variance would not be advisable in my opinion.
$endgroup$
– Robert Long
11 hours ago
1
$begingroup$
But the question says each subject sees 10 stimuli and that these 10 stimuli can be categorized into 3 different categories? I am not suggesting stimulus category (3 levels) could be treated as a random grouping factor, but rather stimulus (10 levels). However, if there aren't repeated values of measure for each subject by stimulus combination OR if the research question calls for it (i.e., the 10 stimuli are the only ones @Rtist wants to learn something about), then the option you suggested would work.
$endgroup$
– Isabella Ghement
11 hours ago
1
$begingroup$
@IsabellaGhement perhaps I misunderstood the question. I read it thatstimulus
has 3 levels, not 10. Anyway, we can wait for clarification from @Rtist
$endgroup$
– Robert Long
10 hours ago
add a comment |
2
$begingroup$
Interesting perspective, Robert! If the 10 stimuli are the only ones @Rtist is interested in, then your suggested approach makes sense. But if he only included the 10 stimuli in the study because he is interested in generalizing the findings of the study to all stimuli represented by these 10 items, then stimulus should be treated as a random grouping factor (assuming there are multiple observations for at least some of all the subject by stimulus combinations). It really all depends on the purpose of the study - if we don't know the purpose, we can only speculate about the model set up.
$endgroup$
– Isabella Ghement
11 hours ago
$begingroup$
@IsabellaGhement there are only 3 levels ofstimulus
, so fitting random effects for it and estimating a variance would not be advisable in my opinion.
$endgroup$
– Robert Long
11 hours ago
1
$begingroup$
But the question says each subject sees 10 stimuli and that these 10 stimuli can be categorized into 3 different categories? I am not suggesting stimulus category (3 levels) could be treated as a random grouping factor, but rather stimulus (10 levels). However, if there aren't repeated values of measure for each subject by stimulus combination OR if the research question calls for it (i.e., the 10 stimuli are the only ones @Rtist wants to learn something about), then the option you suggested would work.
$endgroup$
– Isabella Ghement
11 hours ago
1
$begingroup$
@IsabellaGhement perhaps I misunderstood the question. I read it thatstimulus
has 3 levels, not 10. Anyway, we can wait for clarification from @Rtist
$endgroup$
– Robert Long
10 hours ago
2
2
$begingroup$
Interesting perspective, Robert! If the 10 stimuli are the only ones @Rtist is interested in, then your suggested approach makes sense. But if he only included the 10 stimuli in the study because he is interested in generalizing the findings of the study to all stimuli represented by these 10 items, then stimulus should be treated as a random grouping factor (assuming there are multiple observations for at least some of all the subject by stimulus combinations). It really all depends on the purpose of the study - if we don't know the purpose, we can only speculate about the model set up.
$endgroup$
– Isabella Ghement
11 hours ago
$begingroup$
Interesting perspective, Robert! If the 10 stimuli are the only ones @Rtist is interested in, then your suggested approach makes sense. But if he only included the 10 stimuli in the study because he is interested in generalizing the findings of the study to all stimuli represented by these 10 items, then stimulus should be treated as a random grouping factor (assuming there are multiple observations for at least some of all the subject by stimulus combinations). It really all depends on the purpose of the study - if we don't know the purpose, we can only speculate about the model set up.
$endgroup$
– Isabella Ghement
11 hours ago
$begingroup$
@IsabellaGhement there are only 3 levels of
stimulus
, so fitting random effects for it and estimating a variance would not be advisable in my opinion.$endgroup$
– Robert Long
11 hours ago
$begingroup$
@IsabellaGhement there are only 3 levels of
stimulus
, so fitting random effects for it and estimating a variance would not be advisable in my opinion.$endgroup$
– Robert Long
11 hours ago
1
1
$begingroup$
But the question says each subject sees 10 stimuli and that these 10 stimuli can be categorized into 3 different categories? I am not suggesting stimulus category (3 levels) could be treated as a random grouping factor, but rather stimulus (10 levels). However, if there aren't repeated values of measure for each subject by stimulus combination OR if the research question calls for it (i.e., the 10 stimuli are the only ones @Rtist wants to learn something about), then the option you suggested would work.
$endgroup$
– Isabella Ghement
11 hours ago
$begingroup$
But the question says each subject sees 10 stimuli and that these 10 stimuli can be categorized into 3 different categories? I am not suggesting stimulus category (3 levels) could be treated as a random grouping factor, but rather stimulus (10 levels). However, if there aren't repeated values of measure for each subject by stimulus combination OR if the research question calls for it (i.e., the 10 stimuli are the only ones @Rtist wants to learn something about), then the option you suggested would work.
$endgroup$
– Isabella Ghement
11 hours ago
1
1
$begingroup$
@IsabellaGhement perhaps I misunderstood the question. I read it that
stimulus
has 3 levels, not 10. Anyway, we can wait for clarification from @Rtist$endgroup$
– Robert Long
10 hours ago
$begingroup$
@IsabellaGhement perhaps I misunderstood the question. I read it that
stimulus
has 3 levels, not 10. Anyway, we can wait for clarification from @Rtist$endgroup$
– Robert Long
10 hours ago
add a comment |
$begingroup$
In your setting, subject and stimulus seem to be fully crossed random grouping factors - since each subject sees each stimulus and (I am assuming) you are using the subjects and stimuli included in your studies to represent all the subjects and all the stimuli you wish to generalize your study findings to.
The key word here is grouping - for your model to be a linear mixed effects model (lmer), each subject by stimulus combination should act like a container which holds together a group of values for your measure outcome. All the values of measure that belong to the same container are more similar to each other than values that belong to different containers, as they are subjected to the same subject-level and stimulus-level influences (presuming these influences are constant over time).
The group of values in a specific container could arise, for instance, if you record the value of measure at several time points for each subject by stimulus combination, or under two or more different conditions, etc.
If you only have one value of measure per subject by stimulus combination, then you're dealing with a linear model (lm). There is no grouping of observations according to each subject per stimulus combination, so there are no random grouping factors which means there aren't any effects that can vary randomly across combinations of levels of the grouping factors (i.e., random effects). If there aren't any random effects, there can't be a mixed effects model, as such a model would require both fixed and random effects to be part of it!
If you do have multiple values of measure per container (i.e., subject by stimulus combination), then your model can include subject-level predictors (e.g., subject gender, subject age) and/or stimulus-level predictors (e.g., stimulus category).
$endgroup$
add a comment |
$begingroup$
In your setting, subject and stimulus seem to be fully crossed random grouping factors - since each subject sees each stimulus and (I am assuming) you are using the subjects and stimuli included in your studies to represent all the subjects and all the stimuli you wish to generalize your study findings to.
The key word here is grouping - for your model to be a linear mixed effects model (lmer), each subject by stimulus combination should act like a container which holds together a group of values for your measure outcome. All the values of measure that belong to the same container are more similar to each other than values that belong to different containers, as they are subjected to the same subject-level and stimulus-level influences (presuming these influences are constant over time).
The group of values in a specific container could arise, for instance, if you record the value of measure at several time points for each subject by stimulus combination, or under two or more different conditions, etc.
If you only have one value of measure per subject by stimulus combination, then you're dealing with a linear model (lm). There is no grouping of observations according to each subject per stimulus combination, so there are no random grouping factors which means there aren't any effects that can vary randomly across combinations of levels of the grouping factors (i.e., random effects). If there aren't any random effects, there can't be a mixed effects model, as such a model would require both fixed and random effects to be part of it!
If you do have multiple values of measure per container (i.e., subject by stimulus combination), then your model can include subject-level predictors (e.g., subject gender, subject age) and/or stimulus-level predictors (e.g., stimulus category).
$endgroup$
add a comment |
$begingroup$
In your setting, subject and stimulus seem to be fully crossed random grouping factors - since each subject sees each stimulus and (I am assuming) you are using the subjects and stimuli included in your studies to represent all the subjects and all the stimuli you wish to generalize your study findings to.
The key word here is grouping - for your model to be a linear mixed effects model (lmer), each subject by stimulus combination should act like a container which holds together a group of values for your measure outcome. All the values of measure that belong to the same container are more similar to each other than values that belong to different containers, as they are subjected to the same subject-level and stimulus-level influences (presuming these influences are constant over time).
The group of values in a specific container could arise, for instance, if you record the value of measure at several time points for each subject by stimulus combination, or under two or more different conditions, etc.
If you only have one value of measure per subject by stimulus combination, then you're dealing with a linear model (lm). There is no grouping of observations according to each subject per stimulus combination, so there are no random grouping factors which means there aren't any effects that can vary randomly across combinations of levels of the grouping factors (i.e., random effects). If there aren't any random effects, there can't be a mixed effects model, as such a model would require both fixed and random effects to be part of it!
If you do have multiple values of measure per container (i.e., subject by stimulus combination), then your model can include subject-level predictors (e.g., subject gender, subject age) and/or stimulus-level predictors (e.g., stimulus category).
$endgroup$
In your setting, subject and stimulus seem to be fully crossed random grouping factors - since each subject sees each stimulus and (I am assuming) you are using the subjects and stimuli included in your studies to represent all the subjects and all the stimuli you wish to generalize your study findings to.
The key word here is grouping - for your model to be a linear mixed effects model (lmer), each subject by stimulus combination should act like a container which holds together a group of values for your measure outcome. All the values of measure that belong to the same container are more similar to each other than values that belong to different containers, as they are subjected to the same subject-level and stimulus-level influences (presuming these influences are constant over time).
The group of values in a specific container could arise, for instance, if you record the value of measure at several time points for each subject by stimulus combination, or under two or more different conditions, etc.
If you only have one value of measure per subject by stimulus combination, then you're dealing with a linear model (lm). There is no grouping of observations according to each subject per stimulus combination, so there are no random grouping factors which means there aren't any effects that can vary randomly across combinations of levels of the grouping factors (i.e., random effects). If there aren't any random effects, there can't be a mixed effects model, as such a model would require both fixed and random effects to be part of it!
If you do have multiple values of measure per container (i.e., subject by stimulus combination), then your model can include subject-level predictors (e.g., subject gender, subject age) and/or stimulus-level predictors (e.g., stimulus category).
edited 11 hours ago
answered 11 hours ago
Isabella GhementIsabella Ghement
6,976320
6,976320
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstats.stackexchange.com%2fquestions%2f394706%2faccounting-for-grouped-random-effects-in-lme4%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
1
$begingroup$
What is your research question ? Are you interested in the treatment effects of
stimulus
? Please edit your question to include the output ofstr(My_data)
and the output ofxtabs(~ stimulus + subject, My_data)
andxtabs(~ category + subject, My_data)
andxtabs(~ category + stimulus, My_data)
$endgroup$
– Robert Long
10 hours ago
$begingroup$
You say: "for each category there are an infinity of possible simulations and I just sampled some." Were any of the individual simulations used more than once? Or did you have 3N (where N is the number of participants) separate simulations that were in Category A, for example, and similarly for Categories B and C? How many simulations were there overall for each of the Categories?
$endgroup$
– EdM
7 hours ago
$begingroup$
Per your update, I believe we are thinking about different uses for the terms random and fixed effects - see stats.stackexchange.com/questions/4700/… for a discussion and on that page: statmodeling.stat.columbia.edu/2005/01/25/why_i_dont_use. I am not entirely sure how to do what you want within LME4. But in general, if you are asking about a linear mixed effect model, like with lmer( ), people will most likely think you are trying to find effects like I specified below.
$endgroup$
– Craig K. Van Pay
5 hours ago