# Estimating difference smooth effects for each level of a factor - WHY?

I am wondering why you would want to use a by variable smooth s(time, by= x)? (time is non-linear hence why I am using GAMs)

I am using GAMs to explore if my response $$y$$ changes over $$x$$ or some other categorical factor. Furthermore, if $$y$$ changes over on $$x$$, have these differences changed over time?

Also, if I have an interaction between $$x$$ and $$z$$, what would be the reasons for me including this interaction in the by = argument over time as s(time, by= interaction(x,z))?

How do you assess if you need to have different smooths/curves for an interaction?

Any help is appreciated, I am new to GAMs!

• Welcome to CV elaine! – Alexis Mar 5 at 18:00
• s(time, by= x) is a very general form of interaction. Say you are modeling the development of some (measurement) for a disease with time, and you have reason to believe this time development is different for men and women. Otherwise, maybe ask for your real applied problem! – kjetil b halvorsen Mar 5 at 19:31
• Hi kjetil! Thanks for your answer. So if I see an interaction between Gender and some other categorical variable ie ethnicity. Would I then fit the smooth s(Year, by= interaction(Gender, ethnicity)) if I had reason to believe that this interaction changed over time? Thanks! – elaine Mar 6 at 13:39
• @elaine: At least that might be a starting point. Maybe ask your real, applied proble with more contextual information. – kjetil b halvorsen Mar 7 at 2:06