Hi!
Maybe a question for FernandoRios
Following up on https://www.statalist.org/forums/for...es-mixed-model New question: I would like to try to model the relationship with splines instead of a quadratic transformation.
We had this code (incl. data) to model weight change (diff) over time (age) adding sex (girl) interacted with age and including the subject (id) as a random effect. The model was forced to go through 0/0 (as the weight difference is measured from timepoint 0) . This was achieved using a mixed model and a quadratic transformation of age in order to handle the non-linear relationship.
Code from previous thread with quadratic transformation:

Now I discovered f_able & f_rcspline and would like to use this instead. I would assume that version 1 (see below) is correct - or am i completely wrong? I also cant explain, why v3 only estimates for girls and not boys.

Version 3 - no margins estimate for boys
Maybe a question for FernandoRios
Following up on https://www.statalist.org/forums/for...es-mixed-model New question: I would like to try to model the relationship with splines instead of a quadratic transformation.
We had this code (incl. data) to model weight change (diff) over time (age) adding sex (girl) interacted with age and including the subject (id) as a random effect. The model was forced to go through 0/0 (as the weight difference is measured from timepoint 0) . This was achieved using a mixed model and a quadratic transformation of age in order to handle the non-linear relationship.
Code from previous thread with quadratic transformation:
Code:
webuse childweight, clear replace brthwt = brthwt/1000 // make it same unit as weight gen diff = weight-brthw mixed diff i.girl#c.age##c.age, nocons || id: margins i.girl, at(age = (0(0.5)2.5)) marginsplot, name(one, replace)
Now I discovered f_able & f_rcspline and would like to use this instead. I would assume that version 1 (see below) is correct - or am i completely wrong? I also cant explain, why v3 only estimates for girls and not boys.
Code:
webuse childweight, clear replace brthwt = brthwt/1000 // make it same unit as weight gen diff = weight-brthw f_rcspline f_age = age, nknots(3) * version 1 - interaction with age and f_age2 mixed diff i.girl#(c.age c.f_age2), nocons || id: f_able f_age2 , auto margins i.girl, at(age = (0(0.5)2.5)) marginsplot, name(one, replace) * version 2 - interaction with age only mixed diff i.girl#c.age c.f_age2, nocons || id: f_able f_age2 , auto margins i.girl, at(age = (0(0.5)2.5)) marginsplot, name(two, replace) * version 3 mixed diff i.girl##(c.age c.f_age2) , nocons || id: f_able f_age2 , auto margins i.girl, at(age = (0(0.5)2.5)) marginsplot, name(three, replace) graph combine one two three, col(3)
Version 3 - no margins estimate for boys
Comment