Announcement

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

  • Baseline hazard function for Piecewise constant model

    I need to plot baseline hazard functions for a piecewise constant model. The problem I find is that the hazard needs to be constant in each interval, and then have discrete changes between intervals, which I am not able to achieve.

    The code I am using is the following:

    streg e1 e2 e3 e4 log_trabalhadores innovator1 exporter1 i. ano i.region, dist(exp) nolog vce(cluster NPC_FIC) nocons

    mat b = e(b)
    mat list b
    scalar n = colsof(b) - 1
    scalar list n
    mat b =b[1,2...n]
    mat score xb = b

    ge h=exp(_b[e1]) if age==1
    replace h=exp(_b[e2]) if (age>1 & age<=4)
    replace h=exp(_b[e3]) if (age>=5 & age<=6)
    replace h=exp(_b[e4]) if age>=7



    twoway(connect h age, sort )

    However, when I do obtain the graph, the "jumps" in between the 4 different periods I have defined are not discrete. How can I make it so that they are? Am I doing something fundamentally wrong?

  • #2
    Basically, I want to obtain something such as this:

    But am obtaining the following:

    Click image for larger version

Name:	graph 1.2.png
Views:	1
Size:	4.8 KB
ID:	1522342

    Comment


    • #3
      I have to admit that I don't know what you're looking for. However, taking a guess, check out the following:

      Code:
      twoway connect h age, sort connect(stairstep)
      twoway connect h age, sort connect(stepstair)
      Also, please use CODE delimiters in future to report exactly what you typed into Stata and exactly what you got back. Please read the Forum FAQ about why this is important.

      My guess that if you had really typed
      Code:
      twoway(connect h age, sort )
      Stata would have returned an error.

      Comment

      Working...
      X