I ran a mixed (fractional polynomial) model and would like to use margins to estimated ethnic differences in y.
I have not been found the right answer to it on this forum and wonder if anyone would be able to help.
The model that I ran is a mixed fractional polynomial model with interactions between ethnic and age_1, and between ethnic ang age_2
Question 1: if I want to estimate ethnic differences in y outcome at ages of 3, 5 and 7 years. Is there a better way to write the code apart from the following?
over(age_1) option does not work; at(age_1=(3 5 7)) does not produce the right values)
Question 2: if I want to plot the estimated outcome (smooth trajectory) from the age of 3 to 15 years by ethnic groups with 95% CI, how best to do it using margins and marginsplot?
I have not been found the right answer to it on this forum and wonder if anyone would be able to help.
Code:
y: continuous variable, outcome age: continous variable, age in years age_1: age age_2: age^3 age_3: ln(age) ethnic: categorial ethnicity variable with 3 groups (White, Asian, Black)
Code:
mixed y age_1 age_2 age_3 i.ethnic i.ethnic#c.age_1 i.ethnic#c.age_2 || id:age_1 age_2, mle cov(un)
Code:
margins ethnic, at(age_1=3 age_2=27 age_3=29.662532) margins ethnic, at(age_1=5 age_2=125 age_3=201.17974) margins ethnic, at(age_1=7 age_2=343 age_3=667.44718)
Question 2: if I want to plot the estimated outcome (smooth trajectory) from the age of 3 to 15 years by ethnic groups with 95% CI, how best to do it using margins and marginsplot?