Dear Statalisters,
I have been running a quantile regression analysis looking at the effect of 2 variables (BMI at t1 and SEP (categorical var with 3 levels) (and their interaction) on 3 different quantiles (25th, 50th and 75th) of the outcome variable (BMI at t2).
I have been doing this in three separate models and generating the interaction estimates using nlcom, saving the estimates accordingly (nlcom_1, nlcom_2 and nlcom_3) (see code below)
*25th centile
[qreg z_bmi_2 c.z_bmi_1##i.sep_change xage2 , quantile(25)
nlcom (_Icat_var_1: _b[0.sep_change#c.z_bmi_1] + _b[z_bmi_1]) (_Icat_var_2: _b[1.sep_change#c.z_bmi_1] + _b[z_bmi_1]) (_Icat_var_3: _b[2.sep_change#c.z_bmi_1] + _b[z_bmi_1]), post
est sto nlcom_1]
*50th centile
[qreg z_bmi_2 c.z_bmi_1##i.sep_change xage2 , quantile(50)
nlcom (_Icat_var_1: _b[0.sep_change#c.z_bmi_1] + _b[z_bmi_1]) (_Icat_var_2: _b[1.sep_change#c.z_bmi_1] + _b[z_bmi_1]) (_Icat_var_3: _b[2.sep_change#c.z_bmi_1] + _b[z_bmi_1]), post
est sto nlcom_2]
**75th
[qreg z_bmi_2 c.z_bmi_1##i.sep_change xage2 , quantile(75)
nlcom (_Icat_var_1: _b[0.sep_change#c.z_bmi_1] + _b[z_bmi_1]) (_Icat_var_2: _b[1.sep_change#c.z_bmi_1] + _b[z_bmi_1]) (_Icat_var_3: _b[2.sep_change#c.z_bmi_1] + _b[z_bmi_1]), post
est sto nlcom_3]
I have then been plotting the stored estimates with coefplot using the code below:
[coefplot (nlcom_1, keep(_Icat_var_1 _Icat_var_2 _Icat_var_3) label("25th centile") m(D) mlabel mlabposition(10) ) ///
(nlcom_2, keep(_Icat_var_1 _Icat_var_2 _Icat_var_3) label("50th centile") m(O) mlabel mlabposition(10) ) ///
(nlcom_3, keep(_Icat_var_1 _Icat_var_2 _Icat_var_3) label("75th centile") m(T) mlabel mlabposition(10) ) , ///
vertical ciopts(lwidth(*1.5) lcolor(black) recast(rcap)) mlabc(black) mlcolor(black) mfcolor(white) ///
order(_Icat_var_3 _Icat_var_1 _Icat_var_2) coeflabels(_Icat_var_1 = "Volatile SEP" _Icat_var_2 = "Stable high SEP" ///
_Icat_var_3 = "Stable low SEP") ylabel(, nogrid) graphregion(col(white)) yscale(range(0 1)) ytick(0 (0.1) 1) ///
ylabel(0 (0.1) 1, format(%9.1f) ) xtitle("SEP group", margin(top)) ytitle("Tracking coefficient", margin(right)) ///
title("BMI tracking coefficients at the 25{superscript:th}, 50{superscript:th} and 75{superscript:th}" "centiles by SEP ///
group in the National Study (NS): {it:Females}", margin(bottom) size(small)) format(%9.3f)
]
(hopefully the attachment will show this)
Which produces a nice plot of the 9 coefficients stratified by the levels of the SEP variable (3 for 'stable low SEP', 3 for 'volatile SEP' and 3 for 'high stable SEP') on the x axis and a legend which indicates which quantile the marker refers to, e.g. diamonds for 25th quantile, circles for 50th and triangles for 75th).
What would be preferable though, would be to have the three quantiles on the x axis (25th, 50th, 75th) (instead of the 3 levels of the SEP variable) and then have the three markers per quantile representing the SEP interaction at each of those quantiles.
Any help would be gratefully received.
Kind regards,
tom coefplot all 3_2.tif
I have been running a quantile regression analysis looking at the effect of 2 variables (BMI at t1 and SEP (categorical var with 3 levels) (and their interaction) on 3 different quantiles (25th, 50th and 75th) of the outcome variable (BMI at t2).
I have been doing this in three separate models and generating the interaction estimates using nlcom, saving the estimates accordingly (nlcom_1, nlcom_2 and nlcom_3) (see code below)
*25th centile
[qreg z_bmi_2 c.z_bmi_1##i.sep_change xage2 , quantile(25)
nlcom (_Icat_var_1: _b[0.sep_change#c.z_bmi_1] + _b[z_bmi_1]) (_Icat_var_2: _b[1.sep_change#c.z_bmi_1] + _b[z_bmi_1]) (_Icat_var_3: _b[2.sep_change#c.z_bmi_1] + _b[z_bmi_1]), post
est sto nlcom_1]
*50th centile
[qreg z_bmi_2 c.z_bmi_1##i.sep_change xage2 , quantile(50)
nlcom (_Icat_var_1: _b[0.sep_change#c.z_bmi_1] + _b[z_bmi_1]) (_Icat_var_2: _b[1.sep_change#c.z_bmi_1] + _b[z_bmi_1]) (_Icat_var_3: _b[2.sep_change#c.z_bmi_1] + _b[z_bmi_1]), post
est sto nlcom_2]
**75th
[qreg z_bmi_2 c.z_bmi_1##i.sep_change xage2 , quantile(75)
nlcom (_Icat_var_1: _b[0.sep_change#c.z_bmi_1] + _b[z_bmi_1]) (_Icat_var_2: _b[1.sep_change#c.z_bmi_1] + _b[z_bmi_1]) (_Icat_var_3: _b[2.sep_change#c.z_bmi_1] + _b[z_bmi_1]), post
est sto nlcom_3]
I have then been plotting the stored estimates with coefplot using the code below:
[coefplot (nlcom_1, keep(_Icat_var_1 _Icat_var_2 _Icat_var_3) label("25th centile") m(D) mlabel mlabposition(10) ) ///
(nlcom_2, keep(_Icat_var_1 _Icat_var_2 _Icat_var_3) label("50th centile") m(O) mlabel mlabposition(10) ) ///
(nlcom_3, keep(_Icat_var_1 _Icat_var_2 _Icat_var_3) label("75th centile") m(T) mlabel mlabposition(10) ) , ///
vertical ciopts(lwidth(*1.5) lcolor(black) recast(rcap)) mlabc(black) mlcolor(black) mfcolor(white) ///
order(_Icat_var_3 _Icat_var_1 _Icat_var_2) coeflabels(_Icat_var_1 = "Volatile SEP" _Icat_var_2 = "Stable high SEP" ///
_Icat_var_3 = "Stable low SEP") ylabel(, nogrid) graphregion(col(white)) yscale(range(0 1)) ytick(0 (0.1) 1) ///
ylabel(0 (0.1) 1, format(%9.1f) ) xtitle("SEP group", margin(top)) ytitle("Tracking coefficient", margin(right)) ///
title("BMI tracking coefficients at the 25{superscript:th}, 50{superscript:th} and 75{superscript:th}" "centiles by SEP ///
group in the National Study (NS): {it:Females}", margin(bottom) size(small)) format(%9.3f)
]
(hopefully the attachment will show this)
Which produces a nice plot of the 9 coefficients stratified by the levels of the SEP variable (3 for 'stable low SEP', 3 for 'volatile SEP' and 3 for 'high stable SEP') on the x axis and a legend which indicates which quantile the marker refers to, e.g. diamonds for 25th quantile, circles for 50th and triangles for 75th).
What would be preferable though, would be to have the three quantiles on the x axis (25th, 50th, 75th) (instead of the 3 levels of the SEP variable) and then have the three markers per quantile representing the SEP interaction at each of those quantiles.
Any help would be gratefully received.
Kind regards,
tom coefplot all 3_2.tif