Dear statalist users,
I am currently using margins to estimate predicted values for logged NfL at different CAG repeat lengths and ages. I am doing this for each CAG individually and plotting a marginsplot for each individual CAG. Please see my code below:
What I want to now is to plot all of the different margin estimate models onto one graph as separate lines. Is there a way to do this? I have saved all of the models in a local and I have tried using coefplot to plot the individual models but I don't know if this is appropriate for margins.
I look forward to your responses.
Thank you,
Annabelle
I am currently using margins to estimate predicted values for logged NfL at different CAG repeat lengths and ages. I am doing this for each CAG individually and plotting a marginsplot for each individual CAG. Please see my code below:
Code:
regress logNfL Age i.CAG if disease_grp==1 sum CAG if disease_grp==1, meanonly local min_cag = round(r(min)) local max_cag = round(r(max)) forvalues e = `min_cag'/`max_cag' { levelsof Age if CAG==`e' & disease_grp==1 margins, at(Age=(`r(levels)') CAG=`e') est store model_cag`e' marginsplot, recast(line) noci plotopts(lcolor("179 50 40")) title("") ytitle("logNfL pg/mL") /// xlabel(20(5)46) xscale(range(20 46)) ylabel(1(0.5)4) yscale(range(1 4)) legend(off) /// addplot( /// (scatter `analyte' Age if disease_grp==1 & CAG==`e', mcolor("179 50 40") /// xlabel(20(5)46) xscale(range(20 46)) /// ylabel(1(0.5)4') yscale(range(1 4))) /// ) /// name(control_`model'_`e', replace)
I look forward to your responses.
Thank you,
Annabelle
Comment