Announcement

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

  • -coefplot - using this for odds ratios

    Dear all,
    I'm trying to create a FOREST PLOT with odds' ratios . Dataset available below

    I'm sure I'll be called out for this, perhaps a silly question, however would just like to reassure myself.

    Question 1. As my dependent variable is binary 0 or 1. -logit- will of course omit the OR of the baselevel and present the OR of the value = 1.
    Therefore one can not present the OR of both baselevel and value 1. Correct? And if this is not correct, can you let me know how to obtain the OR of both 0 and 1. ?
    The reason I ask because: https://repec.sowi.unibe.ch/stata/co...g-started.html presents the following forest plot but for - REGRESS-

    Code:
     regress price mpg trunk length turn if foreign==0
    Click image for larger version

Name:	Screenshot 2023-10-17 at 22.54.37.png
Views:	1
Size:	216.8 KB
ID:	1730628



    Now of course, if the above is not possible with logit + OR (-if function can not be used) this is the code I was using

    Code:
    //outcome 1
    logit rep78 i.foreign trunk, or
    coefplot, nolabel drop(_cons) keep(1:*.foreign) omitted baselevels //keep - to keep only OR for foreign from the model and therefore dropping trunk; baselevels omitted  
    
    //outcome 2
    However stata returns the following error:
    coefplot, nolabel drop(_cons) keep(1:*.foreign) omitted baselevels
    (.: no coefficients found, all dropped, or none kept)
    (nothing to plot)


    Question 2: Why is this happening?
    I would then like to combine Outcome 2 with Outcome 1 - again on the same OR forest plot, but only keeping foreign from the model.

    Please let me know your thoughts.


    Dataset:

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str18 make int(price mpg rep78) float headroom int(trunk weight length turn displacement) float gear_ratio byte foreign
    "AMC Concord" 4099 22 1 2.5 11 2930 186 40 121 3.58 0
    "AMC Pacer" 4749 17 1 3 11 3350 173 40 258 2.53 0
    "AMC Spirit" 3799 22 0 3 12 2640 168 35 121 3.08 0
    "Buick Century" 4816 20 1 4.5 16 3250 196 40 196 2.93 0
    "Buick Electra" 7827 15 0 4 20 4080 222 43 350 2.41 0
    "Buick LeSabre" 5788 18 1 4 21 3670 218 43 231 2.73 0
    "Buick Opel" 4453 26 0 3 10 2230 170 34 304 2.87 0
    "Buick Regal" 5189 20 1 2 16 3280 200 42 196 2.93 0
    "Buick Riviera" 10372 16 1 3.5 17 3880 207 43 231 2.93 0
    "Buick Skylark" 4082 19 1 3.5 13 3400 200 42 231 3.08 0
    "Cad. Deville" 11385 14 1 4 20 4330 221 44 425 2.28 0
    "Cad. Eldorado" 14500 14 2 3.5 16 3900 204 43 350 2.19 0
    "Cad. Seville" 15906 21 1 3 13 4290 204 45 350 2.24 0
    "Chev. Chevette" 3299 29 1 2.5 9 2110 163 34 231 2.93 0
    "Chev. Impala" 5705 16 0 4 20 3690 212 43 250 2.56 0
    "Chev. Malibu" 4504 22 1 3.5 17 3180 193 31 200 2.73 0
    "Chev. Monte Carlo" 5104 22 2 2 16 3220 200 41 200 2.73 0
    "Chev. Monza" 3667 24 2 2 7 2750 179 40 151 2.73 0
    "Chev. Nova" 3955 19 1 3.5 13 3430 197 43 250 2.56 0
    "Dodge Colt" 3984 30 1 2 8 2120 163 35 98 3.54 0
    end
    label values foreign origin
    label def origin 0 "Domestic", modify
    Last edited by Tara Boyle; 17 Oct 2023, 16:01.

  • #2
    Hi can anyone help with this ? Is the dataset wrong ?
    or is it the code im using ?

    Comment


    • #3
      Unless I am not understanding the question, rep78 is a five level variable and not a binary outcome variable for logit to work. The dependent variable immediately follows the logistic command and in the unaltered auto dataset, foreign might be the only binary dependent worth 'logit-ting'. You might be able to remap rep78 to suit your question for logistic regression if needed.

      Code:
      sysuse auto,clear
      logit rep78 foreign trunk
      Error

      Code:
      outcome does not vary; remember:
                                        0 = negative outcome,
              all other nonmissing values = positive outcome
      r(2000);

      Comment

      Working...
      X