correlation structures for residuals

155 views
Skip to first unread message

Emily Butler

unread,
Apr 12, 2018, 8:42:25 PM4/12/18
to brms-users
Thanks so much for creating brms!!

I teach multilevel modeling to social science graduate students and am beginning to incorporate a Bayesian approach, thanks to brms making it possible. For the frequentist approach, I use nlme (rather than lme4) because it allows the specification of correlation structures for the residuals. It would be wonderful if I could implement all the models I cover in class in both nlme and brms so that the students can learn how to do it either way. So far I have figured out how to do everything except the correlated residuals (at least I think I've figured out how to get most correlation structures for the group effects using the ID approach - I may be asking about that once I get into it deeper!!).

So, my question: Is it possible to specify correlated residuals in brms and if so, can you point me to anything approximating documentation??

Many thanks, Emily

Paul Buerkner

unread,
Apr 13, 2018, 9:47:08 AM4/13/18
to Emily Butler, brms-users
What kind of correlation structures do you want to use?

--
You received this message because you are subscribed to the Google Groups "brms-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brms-users+unsubscribe@googlegroups.com.
To post to this group, send email to brms-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brms-users/058b46e0-cae1-4a91-bdd0-4f6c9504ad0b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Emily Butler

unread,
Apr 13, 2018, 12:25:17 PM4/13/18
to Paul Buerkner, brms-users
Well, at the most basic, see below for the set I cover when discussing repeated measures (compound symmetric, heterogeneous compound symmetric, unstructured, and auto-correlation). With nlme, any of these can be combined with various random effect structures. I also have a wish list for working with repeated measures dyadic models that can be specified in SAS Proc Mixed (for a frequentist approach) but not in nlme - but I can keep the wish list to myself for the moment :)  Thanks for any thoughts!! Cheers, Emily

# start with a "compound symmetric" model that only has one covariance (shared across all time points) and one variance (also shared across all times). This is the model assumed by traditional repeated measures ANOVA.
cs <- gls(hr ~ time, correlation=corCompSymm(form= ~1 |subject), na.action=na.omit, method="ML", data=data)

# compare to a "heterogeneous compound symmetric" model that holds covariances equal but allows variances to be unique
hcs <- gls(hr ~ time, correlation=corCompSymm(form= ~1 |subject), weights=varIdent(form = ~ 1|time), na.action=na.omit, method="ML", data=data)

# compare to an "unstructured" model that allows both the variances and covariances to be anything
unstruct <- gls(hr ~ time, correlation=corSymm(form= ~1 |subject), weights=varIdent(form = ~ 1|time), na.action=na.omit, method="ML", data=data)

# how about an autocorrelation model?
ar <- gls(hr ~ time, correlation=corAR1(form= ~1 |subject), weights=varIdent(form = ~ 1|time), na.action=na.omit, method="ML", data=data)


--
--------------
Emily A. Butler

Associate Professor & Graduate Director
Family Studies and Human Development
College of Agriculture & Life Sciences
University of Arizona
Tucson, AZ, 85721-0033

Paul Buerkner

unread,
Apr 13, 2018, 12:49:52 PM4/13/18
to Emily Butler, brms-users
for random effects you can either use completely flexible or zero correlations. for residual correlations see ?cor_brms for the current options. most of the models you mentioned are not yet supported by brms.

Emily Butler <emily.a...@gmail.com> schrieb am Fr., 13. Apr. 2018, 18:25:
Well, at the most basic, see below for the set I cover when discussing repeated measures (compound symmetric, heterogeneous compound symmetric, unstructured, and auto-correlation). With nlme, any of these can be combined with various random effect structures. I also have a wish list for working with repeated measures dyadic models that can be specified in SAS Proc Mixed (for a frequentist approach) but not in nlme - but I can keep the wish list to myself for the moment :)  Thanks for any thoughts!! Cheers, Emily

# start with a "compound symmetric" model that only has one covariance (shared across all time points) and one variance (also shared across all times). This is the model assumed by traditional repeated measures ANOVA.
cs <- gls(hr ~ time, correlation=corCompSymm(form= ~1 |subject), na.action=na.omit, method="ML", data=data)

# compare to a "heterogeneous compound symmetric" model that holds covariances equal but allows variances to be unique
hcs <- gls(hr ~ time, correlation=corCompSymm(form= ~1 |subject), weights=varIdent(form = ~ 1|time), na.action=na.omit, method="ML", data=data)

# compare to an "unstructured" model that allows both the variances and covariances to be anything
unstruct <- gls(hr ~ time, correlation=corSymm(form= ~1 |subject), weights=varIdent(form = ~ 1|time), na.action=na.omit, method="ML", data=data)

# how about an autocorrelation model?
ar <- gls(hr ~ time, correlation=corAR1(form= ~1 |subject), weights=varIdent(form = ~ 1|time), na.action=na.omit, method="ML", data=data)


On Fri, Apr 13, 2018 at 6:47 AM, Paul Buerkner <paul.b...@gmail.com> wrote:
What kind of correlation structures do you want to use?
2018-04-13 2:42 GMT+02:00 Emily Butler <emily.a...@gmail.com>:
Thanks so much for creating brms!!

I teach multilevel modeling to social science graduate students and am beginning to incorporate a Bayesian approach, thanks to brms making it possible. For the frequentist approach, I use nlme (rather than lme4) because it allows the specification of correlation structures for the residuals. It would be wonderful if I could implement all the models I cover in class in both nlme and brms so that the students can learn how to do it either way. So far I have figured out how to do everything except the correlated residuals (at least I think I've figured out how to get most correlation structures for the group effects using the ID approach - I may be asking about that once I get into it deeper!!).

So, my question: Is it possible to specify correlated residuals in brms and if so, can you point me to anything approximating documentation??

Many thanks, Emily

--
You received this message because you are subscribed to the Google Groups "brms-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brms-users+...@googlegroups.com.

To post to this group, send email to brms-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brms-users/058b46e0-cae1-4a91-bdd0-4f6c9504ad0b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Emily Butler

unread,
Apr 13, 2018, 1:32:07 PM4/13/18
to Paul Buerkner, brms-users
thanks for the response! Any chance they will be supported in the future? And thanks for all your hard work on the package :)

On Fri, Apr 13, 2018 at 9:49 AM, Paul Buerkner <paul.b...@gmail.com> wrote:
for random effects you can either use completely flexible or zero correlations. for residual correlations see ?cor_brms for the current options. most of the models you mentioned are not yet supported by brms.

Emily Butler <emily.a...@gmail.com> schrieb am Fr., 13. Apr. 2018, 18:25:
Well, at the most basic, see below for the set I cover when discussing repeated measures (compound symmetric, heterogeneous compound symmetric, unstructured, and auto-correlation). With nlme, any of these can be combined with various random effect structures. I also have a wish list for working with repeated measures dyadic models that can be specified in SAS Proc Mixed (for a frequentist approach) but not in nlme - but I can keep the wish list to myself for the moment :)  Thanks for any thoughts!! Cheers, Emily

# start with a "compound symmetric" model that only has one covariance (shared across all time points) and one variance (also shared across all times). This is the model assumed by traditional repeated measures ANOVA.
cs <- gls(hr ~ time, correlation=corCompSymm(form= ~1 |subject), na.action=na.omit, method="ML", data=data)

# compare to a "heterogeneous compound symmetric" model that holds covariances equal but allows variances to be unique
hcs <- gls(hr ~ time, correlation=corCompSymm(form= ~1 |subject), weights=varIdent(form = ~ 1|time), na.action=na.omit, method="ML", data=data)

# compare to an "unstructured" model that allows both the variances and covariances to be anything
unstruct <- gls(hr ~ time, correlation=corSymm(form= ~1 |subject), weights=varIdent(form = ~ 1|time), na.action=na.omit, method="ML", data=data)

# how about an autocorrelation model?
ar <- gls(hr ~ time, correlation=corAR1(form= ~1 |subject), weights=varIdent(form = ~ 1|time), na.action=na.omit, method="ML", data=data)


On Fri, Apr 13, 2018 at 6:47 AM, Paul Buerkner <paul.b...@gmail.com> wrote:
What kind of correlation structures do you want to use?
2018-04-13 2:42 GMT+02:00 Emily Butler <emily.a...@gmail.com>:
Thanks so much for creating brms!!

I teach multilevel modeling to social science graduate students and am beginning to incorporate a Bayesian approach, thanks to brms making it possible. For the frequentist approach, I use nlme (rather than lme4) because it allows the specification of correlation structures for the residuals. It would be wonderful if I could implement all the models I cover in class in both nlme and brms so that the students can learn how to do it either way. So far I have figured out how to do everything except the correlated residuals (at least I think I've figured out how to get most correlation structures for the group effects using the ID approach - I may be asking about that once I get into it deeper!!).

So, my question: Is it possible to specify correlated residuals in brms and if so, can you point me to anything approximating documentation??

Many thanks, Emily

--
You received this message because you are subscribed to the Google Groups "brms-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brms-users+unsubscribe@googlegroups.com.

To post to this group, send email to brms-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brms-users/058b46e0-cae1-4a91-bdd0-4f6c9504ad0b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
--------------
Emily A. Butler

Associate Professor & Graduate Director
Family Studies and Human Development
College of Agriculture & Life Sciences
University of Arizona
Tucson, AZ, 85721-0033

Emily Butler

unread,
Apr 13, 2018, 1:35:25 PM4/13/18
to Paul Buerkner, brms-users
oh, and one last question - I see that there is a "cor_fixed" that the user can define. Is there any documentation or pointers that someone not particularly strong at math might be able to understand well enough to use that option? Thanks, Emily

On Fri, Apr 13, 2018 at 9:49 AM, Paul Buerkner <paul.b...@gmail.com> wrote:
for random effects you can either use completely flexible or zero correlations. for residual correlations see ?cor_brms for the current options. most of the models you mentioned are not yet supported by brms.

Emily Butler <emily.a...@gmail.com> schrieb am Fr., 13. Apr. 2018, 18:25:
Well, at the most basic, see below for the set I cover when discussing repeated measures (compound symmetric, heterogeneous compound symmetric, unstructured, and auto-correlation). With nlme, any of these can be combined with various random effect structures. I also have a wish list for working with repeated measures dyadic models that can be specified in SAS Proc Mixed (for a frequentist approach) but not in nlme - but I can keep the wish list to myself for the moment :)  Thanks for any thoughts!! Cheers, Emily

# start with a "compound symmetric" model that only has one covariance (shared across all time points) and one variance (also shared across all times). This is the model assumed by traditional repeated measures ANOVA.
cs <- gls(hr ~ time, correlation=corCompSymm(form= ~1 |subject), na.action=na.omit, method="ML", data=data)

# compare to a "heterogeneous compound symmetric" model that holds covariances equal but allows variances to be unique
hcs <- gls(hr ~ time, correlation=corCompSymm(form= ~1 |subject), weights=varIdent(form = ~ 1|time), na.action=na.omit, method="ML", data=data)

# compare to an "unstructured" model that allows both the variances and covariances to be anything
unstruct <- gls(hr ~ time, correlation=corSymm(form= ~1 |subject), weights=varIdent(form = ~ 1|time), na.action=na.omit, method="ML", data=data)

# how about an autocorrelation model?
ar <- gls(hr ~ time, correlation=corAR1(form= ~1 |subject), weights=varIdent(form = ~ 1|time), na.action=na.omit, method="ML", data=data)


On Fri, Apr 13, 2018 at 6:47 AM, Paul Buerkner <paul.b...@gmail.com> wrote:
What kind of correlation structures do you want to use?
2018-04-13 2:42 GMT+02:00 Emily Butler <emily.a...@gmail.com>:
Thanks so much for creating brms!!

I teach multilevel modeling to social science graduate students and am beginning to incorporate a Bayesian approach, thanks to brms making it possible. For the frequentist approach, I use nlme (rather than lme4) because it allows the specification of correlation structures for the residuals. It would be wonderful if I could implement all the models I cover in class in both nlme and brms so that the students can learn how to do it either way. So far I have figured out how to do everything except the correlated residuals (at least I think I've figured out how to get most correlation structures for the group effects using the ID approach - I may be asking about that once I get into it deeper!!).

So, my question: Is it possible to specify correlated residuals in brms and if so, can you point me to anything approximating documentation??

Many thanks, Emily

--
You received this message because you are subscribed to the Google Groups "brms-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brms-users+unsubscribe@googlegroups.com.

To post to this group, send email to brms-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brms-users/058b46e0-cae1-4a91-bdd0-4f6c9504ad0b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
--------------
Emily A. Butler

Associate Professor & Graduate Director
Family Studies and Human Development
College of Agriculture & Life Sciences
University of Arizona
Tucson, AZ, 85721-0033

Paul Buerkner

unread,
Apr 13, 2018, 1:36:05 PM4/13/18
to Emily Butler, brms-users
feel free to open an issue on GitHub.

Emily Butler <emily.a...@gmail.com> schrieb am Fr., 13. Apr. 2018, 19:32:
thanks for the response! Any chance they will be supported in the future? And thanks for all your hard work on the package :)
On Fri, Apr 13, 2018 at 9:49 AM, Paul Buerkner <paul.b...@gmail.com> wrote:
for random effects you can either use completely flexible or zero correlations. for residual correlations see ?cor_brms for the current options. most of the models you mentioned are not yet supported by brms.

Emily Butler <emily.a...@gmail.com> schrieb am Fr., 13. Apr. 2018, 18:25:
Well, at the most basic, see below for the set I cover when discussing repeated measures (compound symmetric, heterogeneous compound symmetric, unstructured, and auto-correlation). With nlme, any of these can be combined with various random effect structures. I also have a wish list for working with repeated measures dyadic models that can be specified in SAS Proc Mixed (for a frequentist approach) but not in nlme - but I can keep the wish list to myself for the moment :)  Thanks for any thoughts!! Cheers, Emily

# start with a "compound symmetric" model that only has one covariance (shared across all time points) and one variance (also shared across all times). This is the model assumed by traditional repeated measures ANOVA.
cs <- gls(hr ~ time, correlation=corCompSymm(form= ~1 |subject), na.action=na.omit, method="ML", data=data)

# compare to a "heterogeneous compound symmetric" model that holds covariances equal but allows variances to be unique
hcs <- gls(hr ~ time, correlation=corCompSymm(form= ~1 |subject), weights=varIdent(form = ~ 1|time), na.action=na.omit, method="ML", data=data)

# compare to an "unstructured" model that allows both the variances and covariances to be anything
unstruct <- gls(hr ~ time, correlation=corSymm(form= ~1 |subject), weights=varIdent(form = ~ 1|time), na.action=na.omit, method="ML", data=data)

# how about an autocorrelation model?
ar <- gls(hr ~ time, correlation=corAR1(form= ~1 |subject), weights=varIdent(form = ~ 1|time), na.action=na.omit, method="ML", data=data)


On Fri, Apr 13, 2018 at 6:47 AM, Paul Buerkner <paul.b...@gmail.com> wrote:
What kind of correlation structures do you want to use?
2018-04-13 2:42 GMT+02:00 Emily Butler <emily.a...@gmail.com>:
Thanks so much for creating brms!!

I teach multilevel modeling to social science graduate students and am beginning to incorporate a Bayesian approach, thanks to brms making it possible. For the frequentist approach, I use nlme (rather than lme4) because it allows the specification of correlation structures for the residuals. It would be wonderful if I could implement all the models I cover in class in both nlme and brms so that the students can learn how to do it either way. So far I have figured out how to do everything except the correlated residuals (at least I think I've figured out how to get most correlation structures for the group effects using the ID approach - I may be asking about that once I get into it deeper!!).

So, my question: Is it possible to specify correlated residuals in brms and if so, can you point me to anything approximating documentation??

Many thanks, Emily

--
You received this message because you are subscribed to the Google Groups "brms-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brms-users+...@googlegroups.com.

To post to this group, send email to brms-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brms-users/058b46e0-cae1-4a91-bdd0-4f6c9504ad0b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
--------------
Emily A. Butler

Associate Professor & Graduate Director
Family Studies and Human Development
College of Agriculture & Life Sciences
University of Arizona
Tucson, AZ, 85721-0033

Emily Butler

unread,
Apr 13, 2018, 1:36:38 PM4/13/18
to Paul Buerkner, brms-users
ok, will do....

To unsubscribe from this group and stop receiving emails from it, send an email to brms-users+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages