Announcement

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

  • Graph probability from logistic regression with linear splines

    Hello,

    I am trying to graph Probability of contraceptive use( everused ) against the years of female education divided into four splines. Moreover, I want the probability to look as in the screenshots where it is linear and it has 4 knots from a spline specification. I want the probability of contraceptive use to be calculated using a a logit model where we allow education (within each spline) to vary but hold the rest of the variables at their mean.

    So far I have tried the following logit regression:

    mkspline edu1 5 edu2 8 edu3 12 edu4 = education
    logit everused age age2 edu1 edu2 edu3 edu4 urban low_caste middle_caste high_caste hindu muslim christian poorer middle richer richest, robust

    I have the three following questions:
    1) How do I predict the probability of everused, only allowing education to vary and holding the other variables at their mean?
    2) How do I show this in a graph like the one attached?
    3) Can the slope be interpreted as the change in probability from one extra year within each spline?
    Attached Files

  • #2
    Signe,

    One preliminary thought: Assuming your units of observation are individuals, you appear to have manually created some dummy variables and a squared term. The latter will definitely cause issues with margins (if you use margins). The former could have caused issues with the regression if there was no base category. It would be better to use syntax like this:

    Code:
    logit everused c.age##c.age i.edu urban i.caste i.religion i.ses, robust
    I am not familiar with splines at all, so hopefully someone has a better recommendation. Splines and margins (which you can plot) do not work very well together, but there are a few posts if you search. Here's one.
    Be aware that it can be very hard to answer a question without sample data. You can use the dataex command for this. Type help dataex at the command line.

    When presenting code or results, please use the code delimiters format them. Use the # button on the formatting toolbar, between the " (double quote) and <> buttons.

    Comment


    • #3
      To expand on Ng's useful comments, you may want to develop an indicator and use it to generate the changes in parameters using factor variable notation. Then you can more easily use margins and marginsplot. If you do that, then
      1) How do I predict the probability of everused, only allowing education to vary
      - is simple with at() option in margins
      2) How do I show this in a graph like the one attached?
      - marginsplot after margins may do this, although it might be tricky
      3) Can the slope be interpreted as the change in probability from one extra year within each spline?
      - I think so. Again, with margins you can put in the values for years and look at change in probabilities.

      Comment

      Working...
      X