# Logic to caluclate shape and scale parameter in survival analysis

I have the below dataset:

## Import libraries
import pandas as pd
from lifelines import WeibullFitter

#Create dataset
data = {'cycle':     [1, 2, 3,],
'breakdown': [1, 0, 1,],
}

#Convert to dataframe
df = pd.DataFrame(data)
print("df = \n", df)


Now, for a Weibull distribution function, the baseline hazard function is represented as: The scale (λ) and shape parameters (ρ) are calculated in Python as such:

## Instantiate WeibullFitter class
wbf = WeibullFitter()

## Fit the estimator to data wrt to ['cycle'] and ['breakdown']
wbf.fit(df['cycle'], df['breakdown'])

## WeibullFitter summary
print("\n wbf.summary = \n",wbf.summary)

## WeibullFitter model parameters for all ids of train_df
ρ = wbf.rho_           ## Shape parameter
λ = wbf.lambda_        ## Scale parameter
print("\n Shape parameter = ρ = ",ρ)
print(" Scale parameter = λ = ",λ)


Can somebody please let me know the logic of how to calculate the ρ and λ values, irrespective of whether the codes are written in Python or R?

Since this is a small dataset, I wish to perform hand calculations and understand the logic.

• This is a standard maximum-likelihood fit of a parametric model. Is your question about maximum likelihood per se, or about the specifics of application to a Weibull model?
– EdM
Jun 13 at 13:44
• Thanks a lot @EdM for your feedback...Coming to think of it, I would like to understand the application of maximum likelihood on a Weibull model to estimate scale (λ) and shape parameters (ρ). Could you please share some documentation/video links ? Jun 13 at 13:47