# Calculating the Cox Hazard Rate

I want to write a code that calculates the Cox Proportional Hazard rate:

$h(t|x_it,e_i)=e^{x_it \beta + \lambda(t) + e_i}$

where $\lambda_t$ is a spline in slopes and $e_i$ is an unobserved term. My data includes age,status,health variables of people. I am pretty new in the topic so I wonder what is the best way to do this. Specifically, if I can use the data to calculate a survival function and start from there. I know there are packages in R and python for this but I need to do the coding from scratch.