# How to perform a distribution fit test to censored data

With following code I will get an error:

data = Flatten[{595, 1431, 4347, 5554, 6279, 6887, Table[{7100, \[Infinity]}, {10}]}, 1];
e = EventData[data];
DistributionFitTest[e, WeibullDistribution[a, b]]


a and b are the unknown parameter of the Weibull distribution.

Providing with estimated parameter will not help (again the same error message):

d = EstimatedDistribution[e, WeibullDistribution[a, b], ParameterEstimator -> {"MaximumLikelihood", Method -> "NMaximize"}]
DistributionFitTest[data, d]

• Hi, welcome to Mathematica.SE, please consider taking the tour so you learn the basics of the site. Once you gain enough reputation by making good questions you will be able to vote up and down both questions and answers. When you see good ones, please vote them up by clicking the grey triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. As you receive help, try to give it too, by answering questions in your area of expertise. Nov 4, 2014 at 11:43
• Can you please explain the format of your data? Clearly that is not accepted by EventData. The solution probably goes in the lines of FindDistributionParameters[cdata, CensoredDistribution[{leftCensor, rightCensor}, WeibullDistribution[a, b]] Nov 4, 2014 at 11:49
• Does DistrubutionFitTest accept data with Head == EventData? Nov 4, 2014 at 13:07
• To my knowledge DistributionFitTest does not work with EventData. Nov 4, 2014 at 14:18

@rhermans gave you the answer in a comment.

data = Flatten[{595, 1431, 4347, 5554, 6279, 6887, Table[7100, {10}]},
1];

wcd = CensoredDistribution[{leftCensor, rightCensor}, WeibullDistribution[a, b]];
FindDistributionParameters[data, wcd]
(* {leftCensor -> 595.,rightCensor -> 7100.,a -> 1.1017281600526971,b -> 14712.282885780418} *)
DistributionFitTest[data, wcd, "PearsonChiSquare"]
(* 0.05125258285736953 *)


If leftCensor is known to be zero, then you could use

wcd = CensoredDistribution[{0, rightCensor}, WeibullDistribution[a, b]];
FindDistributionParameters[data, wcd]
(* {rightCensor -> 7100.,a -> 1.3102715493177497,b -> 12977.89931682844} *)
DistributionFitTest[data, wcd, "PearsonChiSquare"]
(* 0.17573433564422514 *)


While for this particular distribution DistributionFitTest chooses PearsonChiSquare, one should make this explicit or at least determine which test was used. If you choose some of the other tests, you'll likely see a warning that the P-value is bogus due to the fact that you've had to estimate some of the parameters.

And, finally, if you only have 7 unique values, the best you can do when the P-value is large is to say "Well, maybe there aren't any gross departures observed."