title: How to plot the hazard function from survival data?
body: <p><strong>Goal</strong></p>
  
  <p>I am trying to plot the hazard function of survival data in R.</p>
  
  <p><strong>Attempt</strong></p>
  
  <p>I am using the NCCTG lung cancer dataset in the <code>survival</code> package in R.</p>
  
  <p>In my understanding the hazard function has the following form:</p>
  
  <pre><code>h(t) = h0(t) * e^(b1 * x1 + ... + bn * xn)
  </code></pre>
  
  <p>The values for x1, ..., xn are independent variables derived from the data self and with the following code, I am able to obtain the values for coefficients b1, ..., bn.  </p>
  
  <pre><code># Sample code
  library(survival)
  
  lung$status &lt;- lung$status - 1
  coxph_mdl &lt;- coxph( Surv(time, status ) ~ age, data = lung )
  summary(coxph_mdl)
  </code></pre>
  
  <p><strong>Question</strong></p>
  
  <p>How do I plot the hazard function of a cohort of patients with survival data in R?</p>