Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Headings for coefplot graph but want to exclude ref category for categorical variables

    Hi all,
    I am using coefplot to create a graph of ORs for odds of contraceptive discontinuation by method. I have quite a few covariates in my model. I'd like to produce this graph, but with headings or groups to identify the covariates, which are all categorical variables.

    coefplot allreason_total allreason_pill allreason_iud allreason_inj allreason_condom , plotlabels("total" "pill" "iud" "inj" "condom" ) eform xline(1) yla(, labsize(tiny)) msize(tiny) legend(r(1) size(vsmall)) xla(, labsize(tiny)) drop(_cons *parity_new *v190 *urban *marital_status *limit *prevuser_switch)
    Click image for larger version

Name:	image_24770.png
Views:	1
Size:	159.2 KB
ID:	1637297



    I found two ways to do it using headings() or groups(), but they all seem to require the inclusion of the reference category, which I don't want to include in the graph. For example, here is the group heading for region, you'll see the reference categories for all covariates are now included.

    coefplot allreason_total allreason_pill allreason_iud allreason_inj allreason_condom , plotlabels("total" "pill" "iud" "inj" "condom" ) eform xline(1) yla(, labsize(tiny)) msize(tiny) legend(r(1) size(vsmall)) xla(, labsize(tiny)) drop(_cons *parity_new *v190 *urban *marital_status *limit *prevuser_switch) omitted baselevels groups(?.region2 = "{bf:Region}" )
    Click image for larger version

Name:	image_24771.png
Views:	1
Size:	184.8 KB
ID:	1637296








    Does anyone know a work around for this?


    Thank you!
    Last edited by Dana Sarnak; 19 Nov 2021, 19:56.

  • #2
    omitted baselevels groups(?.region2 = "{bf:Region}" )
    By including the option -baselevels-, you are asking for the reference categories to be included. Delete it or specify -nobaselevels-. coefplot is from SSC (FAQ Advice #12).

    Comment


    • #3
      Wow! That worked! I could have sworn I tried it but I guess not! Thank you so much!!!


      Any idea how to edit the header text size?

      coefplot allreason_total allreason_pill allreason_iud allreason_inj allreason_condom , plotlabels("total" "pill" "iud" "inj" "condom" ) drop(_cons) eform xline(1) yla(, labsize(tiny)) msize(tiny) legend(r(1) size(vsmall)) xla(, labsize(tiny)) omitted groups(?.region2 = "{bf:Region}" ?.prevuser_switch="{bf:Use history}" ?.limit="{bf:Fertility desire}" ?.marital_status="{bf:Marital status}" ?.v190="{bf:Wealth}" ?.urban="{bf:Residence}" ?.parity_new={bf:Parity} ?.v106="{bf:Education}" ?.age10="{bf:Age}")
      Click image for larger version

Name:	image_24773.png
Views:	1
Size:	273.6 KB
ID:	1637305

      Comment


      • #4
        You want the option -labsize()-, but if there are too many labels, it may be preferable to have a horizontal orientation.

        Code:
        groups(?.region2 = "{bf:Region}", labsize(10pt))
        or

        Code:
        groups(?.region2 = "{bf:Region}", labsize(20pt) angle(horiz))

        Comment

        Working...
        X