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

Functions ExpoWeibull, LogLogistic, and LogNormal fail to compute confidence bounds #32

Closed lisandrojim closed 1 year ago

lisandrojim commented 1 year ago

When using the functions ExpoWeibull, LogLogistic, LogNormal with Maximum Likelihood Estimation. The method fails to compute confidence intervals. See the example below.

from surpyval import ExpoWeibull, LogLogistic, LogNormal
for _ in ['ExpoWeibull','LogLogistic','LogNormal']:
    if _ == 'ExpoWeibull':
        x = eval(_+'.random(100,1,1,1)')
    else:
        x = eval(_+'.random(100,1,1)')
    model = ExpoWeibull.fit(x)
    print(model.cb(0))

It outputs for all three cases that the confidence bound:

[[nan nan]]

derrynknife commented 1 year ago

The confidence bound is undefined at 0.

Use:

from surpyval import ExpoWeibull, LogLogistic, LogNormal
for _ in ['ExpoWeibull','LogLogistic','LogNormal']:
    if _ == 'ExpoWeibull':
        x = eval(_+'.random(100,1,1,1)')
    else:
        x = eval(_+'.random(100,1,1)')
    model = ExpoWeibull.fit(x)
    print(model.cb(1))

This gave me defined (non nan) answers.