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
## Reference: https://lifelines.readthedocs.io/en/latest/fitters/univariate/WeibullFitter.html
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.