What is the right way of computing baseline hazard rate What is the right way of computing baseline hazard rate?
To my understanding hazard rate at time t is simply #events / #AtRisk
url <- "http://socserv.mcmaster.ca/jfox/Books/Companion/data/Rossi.txt"
Rossi <- read.table(url, header=TRUE)
mod.allison <- coxph(Surv(week, arrest) ~+ fin + age + race + wexp + mar + paro + prio,+ data=Rossi)
sf=survfit(mod.allison)

hazard rate $ h(t) = ( H(t+1)-H(t) ) / dt $ where $H(t)$ is cum hazard, dt is 1 so just 
plot(diff(c(0,sf$cumhaz)))

Now lets compute hazard rate using basic definition i.e #events/#AtRisk.
lines(sf$n.event/sf$n.risk)

Result:

Numbers are close but definitely different.
 A: Your way is not right. The notion of creating a "baseline hazard" means that there are other groups with different hazards. If those hazards are proportional, then the Cox Partial Likelihood is the efficient estimator of the hazard ratios when the baseline hazard is unknown. The baseline hazard function is post estimated using the residuals which has accounted for groups with different hazard functions... provided that the model is correct.
The computation of the baseline hazard is effectively similar to density estimation via Kernal based estimators. Using the Schoenfeld residuals one can estimate cloglog of the baseline hazard function and apply the appropriate transformations to obtain a very inefficient estimate of the baseline hazard function. This routine is provided in most statistical software.
Unless the hazard function is strongly believed to vary in very unpredictable ways over time, you do MUCH better by resorting to using a parametric survival model. For most inference, you can use exponential models with smoothing splines for the hazard function. It gives you results very similar to Cox models and the estimation is much more efficient.
A: You can just use this Cox function 'basehaz' in survival package for computing baseline hazard rate. 
Like below: 
Rossi <- read.table(url, header=TRUE)

mod.allison <- coxph(Surv(week, arrest) ~  fin + age + race + wexp + mar + paro + prio, 
                     data=Rossi)

BaseHazRate<-basehaz(mod.allison) 
# This function computes automaticly the baseline hazard for each patient. 

