Plotting nlme results and getting different interceptsPlot two graphs in same plot in RError in model prediction with lmeHow to plot a subset of the factor levels of a mixed model in RPlotting predicted values from a lme model (with polynomials) in RRandom effect predictions from gamm model error: cannot evaluate groups for desired levels on 'newdata'R: how to extract information from summary model fitHow to calculate predictions with both standard errors and random effects for ggplot?I get an error with functions of nlme package in RHow do I plot and pull out my slope and intercept values for different groups from lmer?lmer Model failing to converge with random effects structure
Who are the people reviewing far more papers than they're submitting for review?
Why does an orbit become hyperbolic when total orbital energy is positive?
Are there any “Third Order” acronyms used in space exploration?
Are all men created equal according to Hinduism? Is this predominant western belief in agreement with the Vedas?
Impossible Scrabble Words
What are some examples of research that does not solve a existing problem (maybe the problem is not obvious yet) but present a unique discovery?
Wouldn't Kreacher have been able to escape even without following an order?
What does the Free Recovery sign (UK) actually mean?
Other than good shoes and a stick, what are some ways to preserve your knees on long hikes?
Rare Earth Elements in the outer solar system
Does Forgotten Realms setting count as “High magic”?
Hobby function generators
Statistical tests for benchmark comparison
Is there a theorem in Real analysis similar to Cauchy's theorem in Complex analysis?
Is it possible that the shadow of the moon is a single dot during solar eclipse?
Random restarts for unsatisfiable problems
Tips for remembering the order of parameters for ln?
What did the first ever Hunger Games look like?
Which version of the Pigeonhole principle is correct? One is far stronger than the other
Why is the year in this ISO timestamp not 2019?
Why is the UK still pressing on with Brexit?
Writing a system of Linear Equations
What does the "capacitor into resistance" symbol mean?
What is the source of "You can achieve a lot with hate, but even more with love" (Shakespeare?)
Plotting nlme results and getting different intercepts
Plot two graphs in same plot in RError in model prediction with lmeHow to plot a subset of the factor levels of a mixed model in RPlotting predicted values from a lme model (with polynomials) in RRandom effect predictions from gamm model error: cannot evaluate groups for desired levels on 'newdata'R: how to extract information from summary model fitHow to calculate predictions with both standard errors and random effects for ggplot?I get an error with functions of nlme package in RHow do I plot and pull out my slope and intercept values for different groups from lmer?lmer Model failing to converge with random effects structure
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm running a lme in nlme and when I try to plot the results (using the code from one of the answered questions here), I'm getting different results than the resulting model coefficients, namely the intercept. Is this plotting the random effects intercept and not the fixed effects intercept?
model<-lme(Y~A+ Group + A*Group, random=~1|Subject, data.in2)
> summary(model)
Linear mixed-effects model fit by REML
Data: data.in2
AIC BIC logLik
3203.191 3227.229 -1595.596
Random effects:
Formula: ~1 | Subject
(Intercept) Residual
StdDev: 17.6086 10.03305
Fixed effects: Y ~ A + Group + A * Group
Value Std.Error DF t-value p-value
(Intercept) 42.36244 7.122246 360 5.947905 0.0000
A -1.05472 0.144155 360 -7.316565 0.0000
Group1 -7.49777 12.920964 46 -0.580279 0.5646
A:Group1 0.00180 0.291035 360 0.006195 0.9951
Correlation:
(Intr) A Group1
A -0.902
Group1 -0.551 0.497
A:Group1 0.447 -0.495 -0.888
Standardized Within-Group Residuals:
Min Q1 Med Q3 Max
-2.99649773 -0.50936511 -0.01409361 0.55007319 4.11784199
Number of Observations: 410
Number of Groups: 48
And the graph code is:
newdata<-expand.grid(Group=unique(data.in2$Group), A=c(min(data.in2$A), max(data.in2$A)))
[![ggplot(data.in2, aes(x=A, y=Y, colour=Group)) + geom_point(size=1) +
geom_line(aes(y=predict(model), group=Subject, size="Subjects"))+
geom_line(data=newdata, aes(y=predict(model, level=0, newdata=newdata), size="Population")) +
scale_size_manual(name="Predictions", values=c("Subjects"=0.5, "Population"=3), guide="none")][2]][2]
I'm also trying to attach the image but I'm not sure how. https://i.stack.imgur.com/rfNwP.png
r ggplot2
migrated from stats.stackexchange.com Mar 28 at 12:54
This question came from our site for people interested in statistics, machine learning, data analysis, data mining, and data visualization.
add a comment
|
I'm running a lme in nlme and when I try to plot the results (using the code from one of the answered questions here), I'm getting different results than the resulting model coefficients, namely the intercept. Is this plotting the random effects intercept and not the fixed effects intercept?
model<-lme(Y~A+ Group + A*Group, random=~1|Subject, data.in2)
> summary(model)
Linear mixed-effects model fit by REML
Data: data.in2
AIC BIC logLik
3203.191 3227.229 -1595.596
Random effects:
Formula: ~1 | Subject
(Intercept) Residual
StdDev: 17.6086 10.03305
Fixed effects: Y ~ A + Group + A * Group
Value Std.Error DF t-value p-value
(Intercept) 42.36244 7.122246 360 5.947905 0.0000
A -1.05472 0.144155 360 -7.316565 0.0000
Group1 -7.49777 12.920964 46 -0.580279 0.5646
A:Group1 0.00180 0.291035 360 0.006195 0.9951
Correlation:
(Intr) A Group1
A -0.902
Group1 -0.551 0.497
A:Group1 0.447 -0.495 -0.888
Standardized Within-Group Residuals:
Min Q1 Med Q3 Max
-2.99649773 -0.50936511 -0.01409361 0.55007319 4.11784199
Number of Observations: 410
Number of Groups: 48
And the graph code is:
newdata<-expand.grid(Group=unique(data.in2$Group), A=c(min(data.in2$A), max(data.in2$A)))
[![ggplot(data.in2, aes(x=A, y=Y, colour=Group)) + geom_point(size=1) +
geom_line(aes(y=predict(model), group=Subject, size="Subjects"))+
geom_line(data=newdata, aes(y=predict(model, level=0, newdata=newdata), size="Population")) +
scale_size_manual(name="Predictions", values=c("Subjects"=0.5, "Population"=3), guide="none")][2]][2]
I'm also trying to attach the image but I'm not sure how. https://i.stack.imgur.com/rfNwP.png
r ggplot2
migrated from stats.stackexchange.com Mar 28 at 12:54
This question came from our site for people interested in statistics, machine learning, data analysis, data mining, and data visualization.
add a comment
|
I'm running a lme in nlme and when I try to plot the results (using the code from one of the answered questions here), I'm getting different results than the resulting model coefficients, namely the intercept. Is this plotting the random effects intercept and not the fixed effects intercept?
model<-lme(Y~A+ Group + A*Group, random=~1|Subject, data.in2)
> summary(model)
Linear mixed-effects model fit by REML
Data: data.in2
AIC BIC logLik
3203.191 3227.229 -1595.596
Random effects:
Formula: ~1 | Subject
(Intercept) Residual
StdDev: 17.6086 10.03305
Fixed effects: Y ~ A + Group + A * Group
Value Std.Error DF t-value p-value
(Intercept) 42.36244 7.122246 360 5.947905 0.0000
A -1.05472 0.144155 360 -7.316565 0.0000
Group1 -7.49777 12.920964 46 -0.580279 0.5646
A:Group1 0.00180 0.291035 360 0.006195 0.9951
Correlation:
(Intr) A Group1
A -0.902
Group1 -0.551 0.497
A:Group1 0.447 -0.495 -0.888
Standardized Within-Group Residuals:
Min Q1 Med Q3 Max
-2.99649773 -0.50936511 -0.01409361 0.55007319 4.11784199
Number of Observations: 410
Number of Groups: 48
And the graph code is:
newdata<-expand.grid(Group=unique(data.in2$Group), A=c(min(data.in2$A), max(data.in2$A)))
[![ggplot(data.in2, aes(x=A, y=Y, colour=Group)) + geom_point(size=1) +
geom_line(aes(y=predict(model), group=Subject, size="Subjects"))+
geom_line(data=newdata, aes(y=predict(model, level=0, newdata=newdata), size="Population")) +
scale_size_manual(name="Predictions", values=c("Subjects"=0.5, "Population"=3), guide="none")][2]][2]
I'm also trying to attach the image but I'm not sure how. https://i.stack.imgur.com/rfNwP.png
r ggplot2
I'm running a lme in nlme and when I try to plot the results (using the code from one of the answered questions here), I'm getting different results than the resulting model coefficients, namely the intercept. Is this plotting the random effects intercept and not the fixed effects intercept?
model<-lme(Y~A+ Group + A*Group, random=~1|Subject, data.in2)
> summary(model)
Linear mixed-effects model fit by REML
Data: data.in2
AIC BIC logLik
3203.191 3227.229 -1595.596
Random effects:
Formula: ~1 | Subject
(Intercept) Residual
StdDev: 17.6086 10.03305
Fixed effects: Y ~ A + Group + A * Group
Value Std.Error DF t-value p-value
(Intercept) 42.36244 7.122246 360 5.947905 0.0000
A -1.05472 0.144155 360 -7.316565 0.0000
Group1 -7.49777 12.920964 46 -0.580279 0.5646
A:Group1 0.00180 0.291035 360 0.006195 0.9951
Correlation:
(Intr) A Group1
A -0.902
Group1 -0.551 0.497
A:Group1 0.447 -0.495 -0.888
Standardized Within-Group Residuals:
Min Q1 Med Q3 Max
-2.99649773 -0.50936511 -0.01409361 0.55007319 4.11784199
Number of Observations: 410
Number of Groups: 48
And the graph code is:
newdata<-expand.grid(Group=unique(data.in2$Group), A=c(min(data.in2$A), max(data.in2$A)))
[![ggplot(data.in2, aes(x=A, y=Y, colour=Group)) + geom_point(size=1) +
geom_line(aes(y=predict(model), group=Subject, size="Subjects"))+
geom_line(data=newdata, aes(y=predict(model, level=0, newdata=newdata), size="Population")) +
scale_size_manual(name="Predictions", values=c("Subjects"=0.5, "Population"=3), guide="none")][2]][2]
I'm also trying to attach the image but I'm not sure how. https://i.stack.imgur.com/rfNwP.png
r ggplot2
r ggplot2
asked Mar 27 at 14:25
Mircea_cel_BatranMircea_cel_Batran
407 bronze badges
407 bronze badges
migrated from stats.stackexchange.com Mar 28 at 12:54
This question came from our site for people interested in statistics, machine learning, data analysis, data mining, and data visualization.
migrated from stats.stackexchange.com Mar 28 at 12:54
This question came from our site for people interested in statistics, machine learning, data analysis, data mining, and data visualization.
migrated from stats.stackexchange.com Mar 28 at 12:54
This question came from our site for people interested in statistics, machine learning, data analysis, data mining, and data visualization.
add a comment
|
add a comment
|
1 Answer
1
active
oldest
votes
Your model formula does not match your output notation. The correct model formula for the output you provided is:
model<-lme(Y ~ A + Group + A:Group, random=~1|Subject, data.in2)
which is equivalent with:
model<-lme(Y ~ A*Group, random=~1|Subject, data.in2)
If you tell us more about your A and Group variables, we can comment on the model output you provided.
Addendum:
Not clear from your post what you mean by "getting different intercepts". In your model, the relationship between Y and A for each subject in each group is assumed to be linear (e.g., the value of Y tends to decrease as A increases); the intercept of the straight line capturing that relationship is allowed to be different across subjects within a group but the slope is presumed to be the same across subjects in that group. The slope captures the rate of change in the expected value of Y per 1-unit increase in the value of A for a given subject in a given group.
Because your model includes an intercept between A and Group, there is a further assumption that the slopes of subjects in the first group are different than the slopes of subjects in the second group. The p-value for the interaction between A and Group is quite large, so your data don't seem to support this assumption. This is why, in your plot, you see slopes for subjects in the two groups to be more or less the same.
The 'typical' subject in your first group (Group = 0) has an intercept given by 42.36244 and a slope given by -1.05472. Other subjects in the first group have the same slope but intercepts that vary randomly across the 'typical' intercept value of 42.36244. You can extract the deviations from this 'typical' intercept with the ranef() command. Adding these deviations to the 'typical' intercept in the first group will give you the subject-specific intercepts for the first group subjects.
The 'typical' subject in your second group (Group = 1) has an intercept given by 42.36244 + (-7.49777) a slope given by -1.05472 + (0.00180). Other subjects in the second group have the same slope of -1.05472 + (0.00180) but intercepts that vary randomly across the 'typical' intercept value of 42.36244 + (-7.49777). You can extract the deviations from this 'typical' intercept with the ranef() command - just make sure to match each deviation with the appropriate subject in group 2. Adding these deviations to the 'typical' intercept for the second group will give you the subject-specific intercepts for the second group subjects.
You have enough information in your summary model and the ranef() command to actually build your plot from scratch and see if it matches the plot you showed here.
1
You're absolutely right, B was meant to be Group in the initial statement. A is a continuous variable and Group is a categorical variable with 2 levels.
– Mircea_cel_Batran
Mar 28 at 12:12
Please see my addendum - let me know if that clarifies matters for you. By the way, are you Romanian? I am Romanian myself but established in Canada - my little brother went to the Mircea cel Batran highschool in Constanta.
– Isabella Ghement
Mar 28 at 15:10
1
Thank you! That was a great thorough explanation! I will try this out and see what the new plot will look like! Yes I am Romanian! Bine v-am gasit!
– Mircea_cel_Batran
Mar 28 at 17:43
1
Actually, as it turns out, the scales are off here. I didn't make that connection until I tried your method and naturally the average of the deviations is very close to zero, hence the population line. If I extend the x-axis out to zero, I would get the same intercept. It's always the easiest answer! Thank you anyway!
– Mircea_cel_Batran
Mar 28 at 18:22
add a comment
|
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
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: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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/4.0/"u003ecc by-sa 4.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%2fstackoverflow.com%2fquestions%2f55398193%2fplotting-nlme-results-and-getting-different-intercepts%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Your model formula does not match your output notation. The correct model formula for the output you provided is:
model<-lme(Y ~ A + Group + A:Group, random=~1|Subject, data.in2)
which is equivalent with:
model<-lme(Y ~ A*Group, random=~1|Subject, data.in2)
If you tell us more about your A and Group variables, we can comment on the model output you provided.
Addendum:
Not clear from your post what you mean by "getting different intercepts". In your model, the relationship between Y and A for each subject in each group is assumed to be linear (e.g., the value of Y tends to decrease as A increases); the intercept of the straight line capturing that relationship is allowed to be different across subjects within a group but the slope is presumed to be the same across subjects in that group. The slope captures the rate of change in the expected value of Y per 1-unit increase in the value of A for a given subject in a given group.
Because your model includes an intercept between A and Group, there is a further assumption that the slopes of subjects in the first group are different than the slopes of subjects in the second group. The p-value for the interaction between A and Group is quite large, so your data don't seem to support this assumption. This is why, in your plot, you see slopes for subjects in the two groups to be more or less the same.
The 'typical' subject in your first group (Group = 0) has an intercept given by 42.36244 and a slope given by -1.05472. Other subjects in the first group have the same slope but intercepts that vary randomly across the 'typical' intercept value of 42.36244. You can extract the deviations from this 'typical' intercept with the ranef() command. Adding these deviations to the 'typical' intercept in the first group will give you the subject-specific intercepts for the first group subjects.
The 'typical' subject in your second group (Group = 1) has an intercept given by 42.36244 + (-7.49777) a slope given by -1.05472 + (0.00180). Other subjects in the second group have the same slope of -1.05472 + (0.00180) but intercepts that vary randomly across the 'typical' intercept value of 42.36244 + (-7.49777). You can extract the deviations from this 'typical' intercept with the ranef() command - just make sure to match each deviation with the appropriate subject in group 2. Adding these deviations to the 'typical' intercept for the second group will give you the subject-specific intercepts for the second group subjects.
You have enough information in your summary model and the ranef() command to actually build your plot from scratch and see if it matches the plot you showed here.
1
You're absolutely right, B was meant to be Group in the initial statement. A is a continuous variable and Group is a categorical variable with 2 levels.
– Mircea_cel_Batran
Mar 28 at 12:12
Please see my addendum - let me know if that clarifies matters for you. By the way, are you Romanian? I am Romanian myself but established in Canada - my little brother went to the Mircea cel Batran highschool in Constanta.
– Isabella Ghement
Mar 28 at 15:10
1
Thank you! That was a great thorough explanation! I will try this out and see what the new plot will look like! Yes I am Romanian! Bine v-am gasit!
– Mircea_cel_Batran
Mar 28 at 17:43
1
Actually, as it turns out, the scales are off here. I didn't make that connection until I tried your method and naturally the average of the deviations is very close to zero, hence the population line. If I extend the x-axis out to zero, I would get the same intercept. It's always the easiest answer! Thank you anyway!
– Mircea_cel_Batran
Mar 28 at 18:22
add a comment
|
Your model formula does not match your output notation. The correct model formula for the output you provided is:
model<-lme(Y ~ A + Group + A:Group, random=~1|Subject, data.in2)
which is equivalent with:
model<-lme(Y ~ A*Group, random=~1|Subject, data.in2)
If you tell us more about your A and Group variables, we can comment on the model output you provided.
Addendum:
Not clear from your post what you mean by "getting different intercepts". In your model, the relationship between Y and A for each subject in each group is assumed to be linear (e.g., the value of Y tends to decrease as A increases); the intercept of the straight line capturing that relationship is allowed to be different across subjects within a group but the slope is presumed to be the same across subjects in that group. The slope captures the rate of change in the expected value of Y per 1-unit increase in the value of A for a given subject in a given group.
Because your model includes an intercept between A and Group, there is a further assumption that the slopes of subjects in the first group are different than the slopes of subjects in the second group. The p-value for the interaction between A and Group is quite large, so your data don't seem to support this assumption. This is why, in your plot, you see slopes for subjects in the two groups to be more or less the same.
The 'typical' subject in your first group (Group = 0) has an intercept given by 42.36244 and a slope given by -1.05472. Other subjects in the first group have the same slope but intercepts that vary randomly across the 'typical' intercept value of 42.36244. You can extract the deviations from this 'typical' intercept with the ranef() command. Adding these deviations to the 'typical' intercept in the first group will give you the subject-specific intercepts for the first group subjects.
The 'typical' subject in your second group (Group = 1) has an intercept given by 42.36244 + (-7.49777) a slope given by -1.05472 + (0.00180). Other subjects in the second group have the same slope of -1.05472 + (0.00180) but intercepts that vary randomly across the 'typical' intercept value of 42.36244 + (-7.49777). You can extract the deviations from this 'typical' intercept with the ranef() command - just make sure to match each deviation with the appropriate subject in group 2. Adding these deviations to the 'typical' intercept for the second group will give you the subject-specific intercepts for the second group subjects.
You have enough information in your summary model and the ranef() command to actually build your plot from scratch and see if it matches the plot you showed here.
1
You're absolutely right, B was meant to be Group in the initial statement. A is a continuous variable and Group is a categorical variable with 2 levels.
– Mircea_cel_Batran
Mar 28 at 12:12
Please see my addendum - let me know if that clarifies matters for you. By the way, are you Romanian? I am Romanian myself but established in Canada - my little brother went to the Mircea cel Batran highschool in Constanta.
– Isabella Ghement
Mar 28 at 15:10
1
Thank you! That was a great thorough explanation! I will try this out and see what the new plot will look like! Yes I am Romanian! Bine v-am gasit!
– Mircea_cel_Batran
Mar 28 at 17:43
1
Actually, as it turns out, the scales are off here. I didn't make that connection until I tried your method and naturally the average of the deviations is very close to zero, hence the population line. If I extend the x-axis out to zero, I would get the same intercept. It's always the easiest answer! Thank you anyway!
– Mircea_cel_Batran
Mar 28 at 18:22
add a comment
|
Your model formula does not match your output notation. The correct model formula for the output you provided is:
model<-lme(Y ~ A + Group + A:Group, random=~1|Subject, data.in2)
which is equivalent with:
model<-lme(Y ~ A*Group, random=~1|Subject, data.in2)
If you tell us more about your A and Group variables, we can comment on the model output you provided.
Addendum:
Not clear from your post what you mean by "getting different intercepts". In your model, the relationship between Y and A for each subject in each group is assumed to be linear (e.g., the value of Y tends to decrease as A increases); the intercept of the straight line capturing that relationship is allowed to be different across subjects within a group but the slope is presumed to be the same across subjects in that group. The slope captures the rate of change in the expected value of Y per 1-unit increase in the value of A for a given subject in a given group.
Because your model includes an intercept between A and Group, there is a further assumption that the slopes of subjects in the first group are different than the slopes of subjects in the second group. The p-value for the interaction between A and Group is quite large, so your data don't seem to support this assumption. This is why, in your plot, you see slopes for subjects in the two groups to be more or less the same.
The 'typical' subject in your first group (Group = 0) has an intercept given by 42.36244 and a slope given by -1.05472. Other subjects in the first group have the same slope but intercepts that vary randomly across the 'typical' intercept value of 42.36244. You can extract the deviations from this 'typical' intercept with the ranef() command. Adding these deviations to the 'typical' intercept in the first group will give you the subject-specific intercepts for the first group subjects.
The 'typical' subject in your second group (Group = 1) has an intercept given by 42.36244 + (-7.49777) a slope given by -1.05472 + (0.00180). Other subjects in the second group have the same slope of -1.05472 + (0.00180) but intercepts that vary randomly across the 'typical' intercept value of 42.36244 + (-7.49777). You can extract the deviations from this 'typical' intercept with the ranef() command - just make sure to match each deviation with the appropriate subject in group 2. Adding these deviations to the 'typical' intercept for the second group will give you the subject-specific intercepts for the second group subjects.
You have enough information in your summary model and the ranef() command to actually build your plot from scratch and see if it matches the plot you showed here.
Your model formula does not match your output notation. The correct model formula for the output you provided is:
model<-lme(Y ~ A + Group + A:Group, random=~1|Subject, data.in2)
which is equivalent with:
model<-lme(Y ~ A*Group, random=~1|Subject, data.in2)
If you tell us more about your A and Group variables, we can comment on the model output you provided.
Addendum:
Not clear from your post what you mean by "getting different intercepts". In your model, the relationship between Y and A for each subject in each group is assumed to be linear (e.g., the value of Y tends to decrease as A increases); the intercept of the straight line capturing that relationship is allowed to be different across subjects within a group but the slope is presumed to be the same across subjects in that group. The slope captures the rate of change in the expected value of Y per 1-unit increase in the value of A for a given subject in a given group.
Because your model includes an intercept between A and Group, there is a further assumption that the slopes of subjects in the first group are different than the slopes of subjects in the second group. The p-value for the interaction between A and Group is quite large, so your data don't seem to support this assumption. This is why, in your plot, you see slopes for subjects in the two groups to be more or less the same.
The 'typical' subject in your first group (Group = 0) has an intercept given by 42.36244 and a slope given by -1.05472. Other subjects in the first group have the same slope but intercepts that vary randomly across the 'typical' intercept value of 42.36244. You can extract the deviations from this 'typical' intercept with the ranef() command. Adding these deviations to the 'typical' intercept in the first group will give you the subject-specific intercepts for the first group subjects.
The 'typical' subject in your second group (Group = 1) has an intercept given by 42.36244 + (-7.49777) a slope given by -1.05472 + (0.00180). Other subjects in the second group have the same slope of -1.05472 + (0.00180) but intercepts that vary randomly across the 'typical' intercept value of 42.36244 + (-7.49777). You can extract the deviations from this 'typical' intercept with the ranef() command - just make sure to match each deviation with the appropriate subject in group 2. Adding these deviations to the 'typical' intercept for the second group will give you the subject-specific intercepts for the second group subjects.
You have enough information in your summary model and the ranef() command to actually build your plot from scratch and see if it matches the plot you showed here.
edited Mar 28 at 15:08
answered Mar 27 at 16:03
Isabella GhementIsabella Ghement
3701 silver badge12 bronze badges
3701 silver badge12 bronze badges
1
You're absolutely right, B was meant to be Group in the initial statement. A is a continuous variable and Group is a categorical variable with 2 levels.
– Mircea_cel_Batran
Mar 28 at 12:12
Please see my addendum - let me know if that clarifies matters for you. By the way, are you Romanian? I am Romanian myself but established in Canada - my little brother went to the Mircea cel Batran highschool in Constanta.
– Isabella Ghement
Mar 28 at 15:10
1
Thank you! That was a great thorough explanation! I will try this out and see what the new plot will look like! Yes I am Romanian! Bine v-am gasit!
– Mircea_cel_Batran
Mar 28 at 17:43
1
Actually, as it turns out, the scales are off here. I didn't make that connection until I tried your method and naturally the average of the deviations is very close to zero, hence the population line. If I extend the x-axis out to zero, I would get the same intercept. It's always the easiest answer! Thank you anyway!
– Mircea_cel_Batran
Mar 28 at 18:22
add a comment
|
1
You're absolutely right, B was meant to be Group in the initial statement. A is a continuous variable and Group is a categorical variable with 2 levels.
– Mircea_cel_Batran
Mar 28 at 12:12
Please see my addendum - let me know if that clarifies matters for you. By the way, are you Romanian? I am Romanian myself but established in Canada - my little brother went to the Mircea cel Batran highschool in Constanta.
– Isabella Ghement
Mar 28 at 15:10
1
Thank you! That was a great thorough explanation! I will try this out and see what the new plot will look like! Yes I am Romanian! Bine v-am gasit!
– Mircea_cel_Batran
Mar 28 at 17:43
1
Actually, as it turns out, the scales are off here. I didn't make that connection until I tried your method and naturally the average of the deviations is very close to zero, hence the population line. If I extend the x-axis out to zero, I would get the same intercept. It's always the easiest answer! Thank you anyway!
– Mircea_cel_Batran
Mar 28 at 18:22
1
1
You're absolutely right, B was meant to be Group in the initial statement. A is a continuous variable and Group is a categorical variable with 2 levels.
– Mircea_cel_Batran
Mar 28 at 12:12
You're absolutely right, B was meant to be Group in the initial statement. A is a continuous variable and Group is a categorical variable with 2 levels.
– Mircea_cel_Batran
Mar 28 at 12:12
Please see my addendum - let me know if that clarifies matters for you. By the way, are you Romanian? I am Romanian myself but established in Canada - my little brother went to the Mircea cel Batran highschool in Constanta.
– Isabella Ghement
Mar 28 at 15:10
Please see my addendum - let me know if that clarifies matters for you. By the way, are you Romanian? I am Romanian myself but established in Canada - my little brother went to the Mircea cel Batran highschool in Constanta.
– Isabella Ghement
Mar 28 at 15:10
1
1
Thank you! That was a great thorough explanation! I will try this out and see what the new plot will look like! Yes I am Romanian! Bine v-am gasit!
– Mircea_cel_Batran
Mar 28 at 17:43
Thank you! That was a great thorough explanation! I will try this out and see what the new plot will look like! Yes I am Romanian! Bine v-am gasit!
– Mircea_cel_Batran
Mar 28 at 17:43
1
1
Actually, as it turns out, the scales are off here. I didn't make that connection until I tried your method and naturally the average of the deviations is very close to zero, hence the population line. If I extend the x-axis out to zero, I would get the same intercept. It's always the easiest answer! Thank you anyway!
– Mircea_cel_Batran
Mar 28 at 18:22
Actually, as it turns out, the scales are off here. I didn't make that connection until I tried your method and naturally the average of the deviations is very close to zero, hence the population line. If I extend the x-axis out to zero, I would get the same intercept. It's always the easiest answer! Thank you anyway!
– Mircea_cel_Batran
Mar 28 at 18:22
add a comment
|
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- 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.
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%2fstackoverflow.com%2fquestions%2f55398193%2fplotting-nlme-results-and-getting-different-intercepts%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