I need to plot the estimated regression coefficients. I have attached my data using dataex and here is my code. I estimate the proportional cox proportional hazard model. Also, I estimate the same model using OLS. My codes are below. I would like to plot the estimated coefficients of "birth order" using both OLS and Cox model. I searched for the coefplot command, and tried several times but I failed. The graph below shows exactly what I would like to do. Thank you very much in advance!!!!
Array
For OLS:
reg bfduration2 i.birth_order mother_age i.male i.completionof8years i.quarter_of_birth i.survey_year i.region5 i.wealth_index i.ever_worked [aw=V005] if age_months<=36
For Cox:
global time age_months if age_months<=36
global event bfduration2
global xlist i.birth_order mother_age i.male i.completionof8years i.quarter_of_birth i.survey_year i.region5 i.wealth_index i.ever_worked
stset $time, failure($event)
stdescribe
stsum
sts list, survival
stcox $xlist, nohr
help coefplot
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(birth_order birth_order_sqr mother_age male completionof8years quarter_of_birth survey_year region5 wealth_index ever_worked) double V005 1 1 28 0 0 3 2018 1 4 0 2356056 1 1 30 0 1 1 2018 1 5 0 2356056 1 1 29 1 1 1 2018 1 5 1 2356056 1 1 35 1 1 1 2018 1 5 1 2356056 2 4 30 0 1 1 2018 1 4 1 2356056 4 16 41 1 1 2 2018 1 3 1 2444963 5 25 35 0 0 1 2018 1 1 0 2444963 2 4 26 0 1 2 2018 1 1 1 2444963 4 16 43 0 0 3 2018 1 1 0 2444963 2 4 32 0 0 3 2018 1 2 1 2444963 3 9 37 0 0 4 2018 1 2 1 2444963 1 1 23 0 1 4 2018 1 3 0 2444963 2 4 42 1 0 3 2018 1 3 0 2356056 2 4 22 1 1 4 2018 1 5 0 2356056 4 16 28 1 1 2 2018 1 1 0 2356056 3 9 32 1 1 3 2018 1 3 1 2356056 2 4 44 0 1 1 2018 1 5 1 2356056 2 4 31 0 1 4 2018 1 4 0 2356056 1 1 32 1 1 4 2018 1 5 0 2356056 1 1 35 0 1 4 2018 1 5 1 2356056 1 1 24 0 1 2 2018 1 3 0 2356056 2 4 29 0 1 3 2018 1 2 0 2356056 4 16 29 1 1 3 2018 1 4 1 2356056 2 4 35 1 1 3 2018 1 5 1 2356056 2 4 26 0 1 3 2018 1 2 1 2356056 5 25 33 0 0 2 2018 1 2 1 2356056 2 4 36 0 1 1 2018 1 5 1 2356056 1 1 26 0 1 1 2018 1 5 1 2356056 1 1 32 0 1 3 2018 1 4 1 2356056 1 1 34 0 1 4 2018 1 5 1 2356056 1 1 32 0 1 4 2018 1 5 1 2356056 1 1 33 0 1 1 2018 1 3 1 2356056 1 1 27 0 1 3 2018 1 4 1 2356056 1 1 41 0 0 1 2018 1 4 1 2356056 2 4 41 1 0 2 2018 1 4 1 2378075 1 1 28 0 1 2 2018 1 2 0 2378075 2 4 35 0 1 1 2018 1 3 0 2378075 1 1 19 1 1 4 2018 1 1 0 2356056 3 9 23 0 0 2 2018 1 1 0 2356056 2 4 22 1 1 4 2018 1 1 1 2356056 2 4 26 0 1 1 2018 1 5 1 2356056 2 4 22 0 0 3 2018 1 1 0 2356056 1 1 35 0 1 1 2018 1 5 1 2356056 2 4 41 1 1 2 2018 1 5 1 2356056 1 1 37 1 1 3 2018 1 5 1 2356056 1 1 33 0 1 2 2018 1 5 1 2356056 2 4 35 0 1 3 2018 1 5 1 2356056 2 4 21 0 1 1 2018 1 4 0 2356056 2 4 21 1 1 1 2018 1 4 1 2356056 3 9 45 1 0 4 2018 1 4 1 2356056 2 4 33 0 0 1 2018 1 3 0 2356056 1 1 25 1 1 4 2018 1 4 1 2356056 3 9 36 0 1 2 2018 1 5 0 2356056 4 16 31 1 0 2 2018 1 2 0 2356056 2 4 33 1 0 4 2018 1 5 1 2356056 1 1 33 1 1 3 2018 1 5 1 2356056 1 1 29 1 1 4 2018 1 5 1 2356056 2 4 25 0 1 4 2018 1 4 0 2356056 3 9 38 0 0 4 2018 1 3 1 2356056 2 4 29 1 1 4 2018 1 4 0 2356056 1 1 25 0 1 2 2018 1 4 0 2356056 1 1 24 1 1 3 2018 1 4 1 2356056 3 9 30 0 0 4 2018 1 3 1 2356056 1 1 28 1 0 1 2018 1 2 1 2356056 2 4 35 1 1 2 2018 1 5 1 2356056 1 1 29 0 1 4 2018 1 3 1 2356056 2 4 31 0 1 1 2018 1 3 1 2356056 4 16 24 1 0 1 2018 1 1 0 2356056 3 9 30 0 1 4 2018 1 5 0 2356056 2 4 23 0 1 2 2018 1 4 1 2356056 2 4 32 1 0 4 2018 1 3 0 2356056 2 4 28 0 1 3 2018 1 5 1 2356056 3 9 26 0 0 3 2018 1 2 0 2356056 1 1 23 1 1 4 2018 1 3 0 2356056 4 16 28 0 0 1 2018 1 3 0 2356056 2 4 38 1 1 3 2018 1 3 1 2356056 1 1 21 0 0 3 2018 1 2 0 2356056 1 1 28 0 1 4 2018 1 3 1 2356056 2 4 34 1 1 4 2018 1 3 1 2356056 3 9 40 0 1 3 2018 1 5 1 2356056 2 4 35 1 1 2 2018 1 5 1 2356056 2 4 33 1 1 2 2018 1 5 0 2356056 3 9 37 1 0 1 2018 1 5 0 2356056 3 9 34 1 1 2 2018 1 5 1 2356056 4 16 32 0 0 2 2018 1 2 1 2356056 3 9 37 1 0 3 2018 1 3 0 2356056 2 4 38 1 0 1 2018 1 4 1 2356056 1 1 23 1 1 4 2018 1 3 1 2356056 1 1 37 1 1 3 2018 1 4 1 2356056 3 9 41 0 1 2 2018 1 5 0 2356056 4 16 37 1 1 3 2018 1 4 1 2356056 3 9 28 1 1 1 2018 1 4 1 2356056 2 4 26 1 1 2 2018 1 3 0 2356056 2 4 25 1 0 2 2018 1 3 1 2356056 2 4 35 0 1 1 2018 1 5 1 2356056 3 9 41 0 0 2 2018 1 3 0 2356056 1 1 25 0 1 1 2018 1 3 0 2356056 3 9 31 1 0 2 2018 1 5 0 2356056 2 4 40 0 1 3 2018 1 5 0 2356056 2 4 18 1 0 4 2018 1 2 0 2356056 end label values male male label def male 0 "female", modify label def male 1 "male", modify label values completionof8years completionof8years label def completionof8years 0 "Not Completed", modify label def completionof8years 1 "Completed", modify label values region5 region5 label def region5 1 " West", modify label values wealth_index wealth_index label def wealth_index 1 "Poorest", modify label def wealth_index 2 "Poorer", modify label def wealth_index 3 "Middle", modify label def wealth_index 4 "Rich", modify label def wealth_index 5 "Richest", modify label values ever_worked ever_worked label def ever_worked 0 "Never Worked", modify label def ever_worked 1 "Ever Worked", modify
0 Response to Plotting regression coefficients using coefplot command
Post a Comment