user3437583
user3437583

Reputation: 21

Weibull Censored Data

I'm currently working with some lifetime data that corresponds to the Installation date and Failure date of units. The data is field data, so I do have a major number of suspensions (units that haven't presented a failure yet). I would like to make some Weibull analysis with this data using Scipy stats library (fitting the data to a weibull curve and obtaining the parameters of the distribution for instance). I'm quite new to Python and Scipy so I can't find a way to include the suspended data in any avaiable Weibull distribution (dweibull, exponweibull, minweibull, maxweibull). Is there a easy way to work with suspensions? I would not like to recriate the wheel, but I'm having difficulties in estimating the parameters of the Weibull from my data. Can anyone help me?

Thanks a lot!

Upvotes: 2

Views: 2203

Answers (2)

Derryn Knife
Derryn Knife

Reputation: 104

This is an old question but if anyone else sees this you can use the surpyval python package to fit with suspended data very easily.


import surpyval as surv

# Failures
f = [1, 4, 5, 7, 8, 10]

# suspended or right-censored points
s = [5, 6, 7]

# Convert 'fs' format to the 'xcn' format 
# x is the time/variable
# c is the censoring flag 0 = failed, 1 = right-censored
# n is the count

x, c, n = surv.fs_to_xcn(f=f, s=s)
# Fit model
surv.Weibull.fit(x, c, n)
Parametric SurPyval Model
=========================
Distribution        : Weibull
Fitted by           : MLE
Parameters          :
     alpha: 7.738077941578669
      beta: 2.263120966029975

Upvotes: 0

Josef
Josef

Reputation: 22897

If I understand correctly, then this requires estimation with censored data.

None of the scipy.stats.distribution will directly estimate this case. You need to combine the likelihood function of the non-censored and the likelihood function of the censored observations.

You can use the pdf and the cdf, or better sf, of the scipy.stats.distributions for the two parts. Then, you could just use scipy optimize to minimize the negative log-likelihood, or try the GenericLikelihoodModel in statsmodels if you are also interested in the uncertainty of the parameter estimates.

Upvotes: 1

Related Questions