I am running a logit model with a cubic term for age (age x age x age). Age ranges from 0 to 17. The cubic term is also interacted with a binary group variable (0, 1). The model looks like:
Is there a way to look at the marginal effect of each group, but only within a specific age-range? For example, can I use margins to look at the marginal effect of age separately for those 0-6, 7-12, and 13-17. I tried a blunt approach of:
That worked, but I don't know if is an appropriate approach. Further, if I wanted to compare the marginal effects between different age ranges (e.g., 0-6 vs. 7-12), I am not sure if this would work...
I would appreciate any advice. Thanks!
Code:
logit y c.age##c.age##c.age##i.group
Code:
margins if age<=6, dydx(age) at=(group=(0 1)) post
I would appreciate any advice. Thanks!
Comment