I am looking at how my outcome y evolves over time assuming such evolution may differ by x (binary).
I assume a nonlinear effect of time, which I operationalize as a quadratic effect.
Therefore I have time and time squared in my model, and I interact x with time, so my model looks like
xtreg y time##x timesquare##x, i(pid)

How can I plot y trajectories over time by x?
In a model with a linear effect of time or where I treat time with dummies for each time point I would use “marginsplot” as below…but I cannot figure out how to correctly apply that in the case of a quadratic effect.
xtreg y x##c.time, i(pid) /*or i.time if I want dummies for each time*/
margins x, at(time=(0(5)50))
marginsplot


thanks. Any suggestions is welcome.
Anna