Discussion:
[R-sig-ME] GAMMs: difference smooths in itsadug
Sebastian Sauppe
2018-07-16 07:20:26 UTC
Permalink
Dear list members,

I have a question on the treatment of random effects in plotting difference smooths for GAMMs with the package itsadug.

I am modelling the time course of binomial data with mgcv::bam. The simplified formula is: cbind(success, failure) ~ 1 + s(Time, by = Condition) + s(Subject, Time, bs = „fs“) + s(Item, Time, bs = „fs“). The two factor smooths are supposed to account for the random effects of participants and stimuli in my experiments.

I would like to use itsadug::plot_diff() to visualize how the two conditions differ over time. However, I am not quite sure what the rm.ranef argument argument of this function does. What I basically want to do is to look at the difference the way one would look at a fixed effect in an GLMER model, i.e., looking at the fixed effect of the interaction of Time:Condition after the variance that can be ascribed to random effects of subjects and items have been accounted for. Would for this rm.ranef=TRUE or rm.ranef=FALSE be the right option?

Kind regards,
Sebastian

-----------
Dr. Sebastian Sauppe
Department of Comparative Linguistics, University of Zurich
Homepage: https://sites.google.com/site/sauppes/ <https://sites.google.com/site/sauppes/>
Twitter: @SebastianSauppe <https://twitter.com/SebastianSauppe>
Google Scholar Citations: https://scholar.google.de/citations?user=wEtciKQAAAAJ <https://scholar.google.de/citations?user=wEtciKQAAAAJ>
ResearchGate: http://www.researchgate.net/profile/Sebastian_Sauppe <http://www.researchgate.net/profile/Sebastian_Sauppe>
ORCID ID: http://orcid.org/0000-0001-8670-8197 <http://orcid.org/0000-0001-8670-8197>

[[alternative HTML version deleted]]
Alday, Phillip
2018-07-16 10:48:29 UTC
Permalink
Hi Sebastian,

are you using gamm4? If so, you can extract the GAM object, which if I'm
not mistaken is already marginalized over the random effects i.e. is
just fixed effects, and just use its plotting functions.

model <- gamm4(....)

plot(model$gam)

Best,
Phillip
Post by Sebastian Sauppe
Dear list members,
I have a question on the treatment of random effects in plotting difference smooths for GAMMs with the package itsadug.
I am modelling the time course of binomial data with mgcv::bam. The simplified formula is: cbind(success, failure) ~ 1 + s(Time, by = Condition) + s(Subject, Time, bs = „fs“) + s(Item, Time, bs = „fs“). The two factor smooths are supposed to account for the random effects of participants and stimuli in my experiments.
I would like to use itsadug::plot_diff() to visualize how the two conditions differ over time. However, I am not quite sure what the rm.ranef argument argument of this function does. What I basically want to do is to look at the difference the way one would look at a fixed effect in an GLMER model, i.e., looking at the fixed effect of the interaction of Time:Condition after the variance that can be ascribed to random effects of subjects and items have been accounted for. Would for this rm.ranef=TRUE or rm.ranef=FALSE be the right option?
Kind regards,
Sebastian
-----------
Dr. Sebastian Sauppe
Department of Comparative Linguistics, University of Zurich
Homepage: https://sites.google.com/site/sauppes/ <https://sites.google.com/site/sauppes/>
Google Scholar Citations: https://scholar.google.de/citations?user=wEtciKQAAAAJ <https://scholar.google.de/citations?user=wEtciKQAAAAJ>
ResearchGate: http://www.researchgate.net/profile/Sebastian_Sauppe <http://www.researchgate.net/profile/Sebastian_Sauppe>
ORCID ID: http://orcid.org/0000-0001-8670-8197 <http://orcid.org/0000-0001-8670-8197>
[[alternative HTML version deleted]]
_______________________________________________
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
Voeten, C.C.
2018-07-16 13:26:34 UTC
Permalink
Hi Sebastian,

Yes, rm.ranef=TRUE will give you precisely this, assuming your random effects are all of the 'fs' and/or 're' category, which is the case for the model you describe.
With rm.ranef=FALSE, you would get the effects specifically for the first subject+item combination in your data set (or, more precisely, whichever of these happened to be the first level in your factor variables for these terms).

Best,
Cesko
-----Oorspronkelijk bericht-----
project.org] Namens Sebastian Sauppe
Verzonden: maandag 16 juli 2018 9:20
Onderwerp: [R-sig-ME] GAMMs: difference smooths in itsadug
Dear list members,
I have a question on the treatment of random effects in plotting difference
smooths for GAMMs with the package itsadug.
I am modelling the time course of binomial data with mgcv::bam. The
simplified formula is: cbind(success, failure) ~ 1 + s(Time, by = Condition) +
s(Subject, Time, bs = „fs“) + s(Item, Time, bs = „fs“). The two factor smooths
are supposed to account for the random effects of participants and stimuli in
my experiments.
I would like to use itsadug::plot_diff() to visualize how the two conditions
differ over time. However, I am not quite sure what the rm.ranef argument
argument of this function does. What I basically want to do is to look at the
difference the way one would look at a fixed effect in an GLMER model, i.e.,
looking at the fixed effect of the interaction of Time:Condition after the
variance that can be ascribed to random effects of subjects and items have
been accounted for. Would for this rm.ranef=TRUE or rm.ranef=FALSE be the
right option?
Kind regards,
Sebastian
-----------
Dr. Sebastian Sauppe
Department of Comparative Linguistics, University of Zurich
Homepage: https://sites.google.com/site/sauppes/
<https://sites.google.com/site/sauppes/>
https://scholar.google.de/citations?user=wEtciKQAAAAJ
<https://scholar.google.de/citations?user=wEtciKQAAAAJ>
ResearchGate: http://www.researchgate.net/profile/Sebastian_Sauppe
<http://www.researchgate.net/profile/Sebastian_Sauppe>
ORCID ID: http://orcid.org/0000-0001-8670-8197 <http://orcid.org/0000-0001-
8670-8197>
[[alternative HTML version deleted]]
_______________________________________________
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
Sebastian Sauppe
2018-07-16 13:33:17 UTC
Permalink
Dear Cesko,

Thanks a lot, that was exactly the info I was looking for!

Regards,
Sebastian

-----------
Dr. Sebastian Sauppe
Department of Comparative Linguistics, University of Zurich
Homepage: https://sites.google.com/site/sauppes/ <https://sites.google.com/site/sauppes/>
Twitter: @SebastianSauppe <https://twitter.com/SebastianSauppe>
Google Scholar Citations: https://scholar.google.de/citations?user=wEtciKQAAAAJ <https://scholar.google.de/citations?user=wEtciKQAAAAJ>
ResearchGate: http://www.researchgate.net/profile/Sebastian_Sauppe <http://www.researchgate.net/profile/Sebastian_Sauppe>
ORCID ID: http://orcid.org/0000-0001-8670-8197 <http://orcid.org/0000-0001-8670-8197>
Post by Alday, Phillip
Hi Sebastian,
Yes, rm.ranef=TRUE will give you precisely this, assuming your random effects are all of the 'fs' and/or 're' category, which is the case for the model you describe.
With rm.ranef=FALSE, you would get the effects specifically for the first subject+item combination in your data set (or, more precisely, whichever of these happened to be the first level in your factor variables for these terms).
Best,
Cesko
-----Oorspronkelijk bericht-----
project.org] Namens Sebastian Sauppe
Verzonden: maandag 16 juli 2018 9:20
Onderwerp: [R-sig-ME] GAMMs: difference smooths in itsadug
Dear list members,
I have a question on the treatment of random effects in plotting difference
smooths for GAMMs with the package itsadug.
I am modelling the time course of binomial data with mgcv::bam. The
simplified formula is: cbind(success, failure) ~ 1 + s(Time, by = Condition) +
s(Subject, Time, bs = „fs“) + s(Item, Time, bs = „fs“). The two factor smooths
are supposed to account for the random effects of participants and stimuli in
my experiments.
I would like to use itsadug::plot_diff() to visualize how the two conditions
differ over time. However, I am not quite sure what the rm.ranef argument
argument of this function does. What I basically want to do is to look at the
difference the way one would look at a fixed effect in an GLMER model, i.e.,
looking at the fixed effect of the interaction of Time:Condition after the
variance that can be ascribed to random effects of subjects and items have
been accounted for. Would for this rm.ranef=TRUE or rm.ranef=FALSE be the
right option?
Kind regards,
Sebastian
-----------
Dr. Sebastian Sauppe
Department of Comparative Linguistics, University of Zurich
Homepage: https://sites.google.com/site/sauppes/
<https://sites.google.com/site/sauppes/>
https://scholar.google.de/citations?user=wEtciKQAAAAJ
<https://scholar.google.de/citations?user=wEtciKQAAAAJ>
ResearchGate: http://www.researchgate.net/profile/Sebastian_Sauppe
<http://www.researchgate.net/profile/Sebastian_Sauppe>
ORCID ID: http://orcid.org/0000-0001-8670-8197 <http://orcid.org/0000-0001-
8670-8197>
[[alternative HTML version deleted]]
_______________________________________________
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
[[alternative HTML version deleted]]

Loading...