Hello,
I am working on a longitudinal study looking for differences between two groups in the dependent variable (Y) over continuous time (days). Y does not change linearly with time, and so we are using the flexcurv command to create cubic splines as follows:
Code:
flexcurv, xvar(days) power(2) refpts(30 100 160) generate(cs_)
mixed y cs_* i.gr c.cs_*#gr, nocons || id:
I would like to test the significance of the difference in Y between the two groups at specific timepoints. Without the spline terms, I would do this with a margins command:
Code:
margins gr, at(days= (14)) pwcompare(effects)
However, this does not work since the variable "days" was not part of my regression. I have tried looking for the value of the cubic spline terms at my timepoints of interest, and including that in my margins command instead, but the margins are "not estimable"
Code:
summ cs* if days == 14
margins gr, at(cs_1= (1.379781)) pwcompare(effects)
Does anyone have any suggestions of how to look at differences between groups at specific timepoints in this cubic spline interaction model?
Thank you!
Janna
0 Response to Problem with margins after regression with cubic spline interaction terms
Post a Comment