Hello Everyone,

I am estimating an age-period-cohort (APC) model to isolate cohort trends in diabetes (0=does not have diabetes, 1=has diabetes) by using a mixed model framework specifying cohort at level 1 and period and age at level 2 such that they are not linear combinations. This method I am using is based on Yang Y, Land KC. Age-Period-Cohort Analysis: New Models, Methods, and Empirical Applications. New York: Chapman and Hall/CRC; 2013.

Code:
meqrlogit diabe i.cohort  || _all:R.period || agecat:, var or
I want to use the estimates from this model to produce two figures: 1) where age is on the x-axis, and 2) where period is on the x-axis. The y-axis is supposed to be the diabetes prediction. The lines are supposed to be each cohort group.

Here's an example of what I want to produce (I am interested in the first two graphs): Array



Source: https://conservancy.umn.edu/bitstrea...=1&isAllowed=y

In searching the forum, I have found a dearth of threads that address APC models, and the ones that do exist have not addressed creating these type of graphs.

From what I have gathered from the forum and Google searching, I believe I need the following pieces:
Code:
// predict fixed part
predict pfx, xb

// predict random effects
predict v0*, reffects  

// predict standard errors
predict v0se*, reses


// Period Probability
gen probPeriod = 1 /(1+exp(-1*(pfx + v01)))
*95% CI
gen probPrL = probPeriod-1.96*v0se1
gen probPrU = probPeriod+1.96*v0se1

// Age Probability
gen probAge = 1 /(1+exp(-1*(pfx + v02)))
*95% CI
gen probArL = probAge-1.96*v0se2
gen probArU = probAge+1.96*v0se2
I have tried using the twoway graph functions and was able to generate an overall period graph:
Code:
preserve
collapse (mean) probP = probPeriod (semean) probPs = probPeriod, by(period)
gen probPrL = probP-1.96*probPs
gen probPrU = probP+1.96*probPs
 
twoway (connected probP period, mcolor(black) lcolor(black)) ///
(connected probPrL period, mcolor(black) lcolor(black) lpattern(dash)) ///
(connected probPrU period, mcolor(black) lcolor(black) lpattern(dash)), ///
ytitle(Predicted probability with 95% confidence band) xtitle(Period) xlabel(#3) legend(off)

restore
I've been trying to figure out how to manipulate this code in order to get cohorts in the lines and diabetes as the y-axis; however, I have exhausted whatever knowledge and Google search skills I have.

I have also been wondering if it is a possibility to use the margins & marginsplot commands to get what I want.

I appreciate you all for reading this and look forward to anyone that may be able to help me learn how to do this.

EDIT: I forgot to include that I am using Stata version 16.