Announcement

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

  • Expected Probability

    Hello guys,

    Could you please help me with my confusion?

    For the logit results,

    I want to calculate the expected probability of having at least one child for a white, nonHispanic woman in each age group, holding all other variables constant, and then for each level of education, holding all other variables constant.



    I used this code:


    logit LIVE_BIRTHS ESTINCOME SHAREARNINGS i.EDUCATION i.AGE i.MARITAL_STATUST i.RACE i.HISPANIC


    local b0 = _b[_cons]

    local b1 = _b[2.AGE]

    local b2 = _b[3.AGE]

    local b3 = _b[4.AGE]

    local b4 = _b[5.AGE]

    local b5 = _b[1.HISPANIC]

    generate xAGE_HISPANIC = `b0' + `b1'*1 i am not sure why b1 times 1 + _b[2.AGE]*2.AGE + _b[3.AGE]*3.AGE + _b[4.AGE]*4.AGE + _b[5.AGE ]*5.AGE + _b[1.HISPANIC]*1.HISPANIC

    generate prAGE = exp(xAGE_HISPANIC)/(1 + exp(xAGE_HISPANIC))


    local b0 = _b[_cons]

    local b1 = _b[2.EDUCATION]

    local b2 = _b[3.EDUCATION]

    local b3 = _b[4.EDUCATION]

    local b4 = _b[5.EDUCATION]

    local b5 = _b[1.HISPANIC]


    generate xEDUCATION_HISPANIC = `b0' + `b1'*1 + _b[2.EDUCATION]*2.EDUCATION + _b[3.EDUCATION]*3.EDUCATION + _b[4.EDUCATION]*4.EDUCATION + _b[5.EDUCATION ]*5.EDUCATION + _b[1.HISPANIC]*1.HISPANIC
    generate prEDUCATION_INCOME = exp(xEDUCATION_HISPANIC)/(1 + exp(xEDUCATION_HISPANIC))


  • #2
    Why just not use predict, e.g.

    Code:
    predict xAGE_HISPANIC
    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
      this is my result

      Click image for larger version

Name:	Screenshot 2022-08-30 121809.jpg
Views:	1
Size:	145.1 KB
ID:	1679946

      Comment


      • #4
        Weiwen Ng

        you asked me

        Why just not use predict.

        because I have many predict values I should find.

        Comment


        • #5
          Originally posted by Hm Saleh View Post
          Weiwen Ng

          you asked me

          Why just not use predict.

          because I have many predict values I should find.
          Please read the FAQ; we're asked not to post screenshots of results. The results are more readable in code delimiters, like I used for my suggested code.

          I see what you mean. I read too fast. You could actually get this using margins. Here's one explainer by Richard Williams. It should be something like

          Code:
          margins age, at(race = 1 hispanic = 0) atmeans
          for your first example.
          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


          • #6
            I tried to type help dataex but it doesn't work
            I got this massage
            Click image for larger version

Name:	Screenshot 2022-08-30 .jpg
Views:	1
Size:	14.3 KB
ID:	1679967

            Comment

            Working...
            X