Announcement

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

  • Plot average probability of dependent variable against independent variable logistic regression

    Hello,

    I would like to create graphical plots of the average probability of my dichotomous dependent variable given values of my categorical or count independent variables. For example, if I have an independent count variable going from 0-4, I would like my y-axis to plot the probability of my dependent variable being 1 for each of the possible values (0, 1, 2, 3, 4) of my independent variable. Is this possible in Stata? Ideally, I would like to be able to make separate plots controlling for covariates in my logistic regression model as well as unadjusted plots.

    Please let me know if you need any more information!

    Thanks,
    alyssa

  • #2
    Its not clear whether you have already run your logit model or not. You are expected to show it if you have. However, try -marginsplot- after the logistic regression command. Something like this below where y is the dichotomous outcome and x has 4 values ranging from 0-4:

    Code:
    *******************Generate some data*******************
    clear
    set obs 1000
    set seed 1245
    gen y =int(runiform()+.5)
    so y
    gen x= int((4-0+1)*runiform()+0)
    **************************************
    logit y x //logit model
    margins, at(x=(0/4))
    marginsplot,
    See the help file for -margins- type in Stata -help margins- for further help with this command.
    Roman

    Comment


    • #3
      Hi Roman,

      Yes, I did already run my logit model. What you recommended was exactly what I was looking for.

      Thanks,
      Alyssa

      Comment

      Working...
      X