Good afternoon All
Sample data is supplied at the bottom of this post.
I have an equation defined below that I have modelled using nl (nonlinear least-squares estimation).
y = {b0}*sqrt(1-x)*({b1}*x+1-{b1}
I have been able to graph the differences between binary (e.g. sex) and continuous (e.g. age) predictors , but I would like to be able to determine whether there is a significant difference between the two curves (this would be easy if it was a quadratic fit for example: regress y c.x##c.x##i.sex).
My attempt at including interaction terms (main effect for x and sex, and interaction term between them) in the equation is below, but I am not at all certain whether this is correct at all! The p-value from this sample data suggests that there is no significant difference between sexes (p=0.619):
I'd be super grateful if someone could confirm whether or not the interaction term is correctly fitted in the nl equation!
Thanks for any help or advice,
/Peta
------------------------------------------------------------------------------------------------------------------------------------
Sample data is supplied at the bottom of this post.
I have an equation defined below that I have modelled using nl (nonlinear least-squares estimation).
y = {b0}*sqrt(1-x)*({b1}*x+1-{b1}
Code:
nl (y= {b0}*sqrt(1-x)*({b1}*x+1-{b1})), nolog variables(x) margins, at(x=(0.95(.0025)1)) marginsplot addplot: scatter y x, jitter(1) msym(oh) mcolor(gs10)
Code:
*determine equaton fit by sex, combine curves set more off nl (y= {b0}*sqrt(1-x)*({b1}*x+1-{b1})) if sex==0, nolog variables(x) predict int_female nl (y= {b0}*sqrt(1-x)*({b1}*x+1-{b1})) if sex==1, nolog variables(x) predict int_male scatter y x || lowess int_female x || lowess int_male x, sort
Code:
nl (y = {b0}*sqrt(1-x)*({b1}*x+1-{b1})+{b2}*{sex}+{i1}*({b0}*sqrt(1-x)*({b1}*x+1-{b1}))*sex), nolog variables(x sex) margins, over(sex) at(x=(0.95(.005)1)) marginsplot
Thanks for any help or advice,
/Peta
------------------------------------------------------------------------------------------------------------------------------------
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float y double x byte(sex age) 1.52796 .9892868 1 2 1.89666 .9797394 0 6 1.96257 .978637 1 3 1.98382 .9780292 0 4 2.04352 .9726008 1 3 2.09717 .9673443 1 4 2.1616 .9697651 1 2 2.35337 .9626659 0 4 2.36128 .9639572 0 3 2.39121 .9704398000000001 1 7 2.39734 .9699420999999999 1 6 2.42883 .9548707000000001 1 7 2.4722 .9531984 1 2 2.47434 .9673583000000001 1 3 2.48315 .9524335 1 2 2.54352 .952538 0 3 2.55237 .9584881 0 3 2.62491 .9660379 1 7 2.65316 .9530894000000001 1 4 2.66142 .9520308 1 4 end label values sex sex label def sex 0 "female", modify label def sex 1 "male", modify
Comment