derrynknife / SurPyval

A Python package for survival analysis. The most flexible survival analysis package available. SurPyval can work with arbitrary combinations of observed, censored, and truncated data. SurPyval can also fit distributions with 'offsets' with ease, for example the three parameter Weibull distribution.
https://surpyval.readthedocs.io/en/latest/index.html
MIT License
48 stars 5 forks source link

Mixture Models #40

Open subha000git opened 8 months ago

subha000git commented 8 months ago

Hi, I find this python package very helpful for analyzing weibull data. However, I found the documentation on "Mixture models" could be more elaborate. I was using the following example:

import surpyval as surv import numpy as np from matplotlib import pyplot as plt

x = [1, 2, 3, 4, 5, 6, 6, 7, 8, 10, 13, 15, 16, 17 ,17, 18, 19] x_ = np.linspace(np.min(x), np.max(x))

model = surv.Weibull.fit(x) wmm = surv.MixtureModel(x=x, dist=surv.Weibull, m=2)

model.plot(plotbounds=False) plt.plot(x, wmm.ff(x_))

However, (1)I could not understand what is the percentage of data (or which data points) being assigned to first weibull distribution and what is the percentage of the data assigned to the 2nd one? The wmm.params gives me the paramers, but it does not give corresponding fraction of data from which it calculated. How do we get the individual weibull data for each distribution? It seems the code currently just splits the entire data set into 2 equal arrays for weibull fitting. (2) How do we get the statistics of the fitting for each weibull (Goodness of fit)? How do we know if it is a good fit or bad fit?