0
$\begingroup$

The first "Applications" example given for the DistributionFitTest of the Wolfram Language & System Documentation Center is:

Analyze whether a dataset is drawn from a normal distribution:

data = {87, 91, 97 , 80, 71, 86, 72, 93, 83, 73, 76};

Perform a series of goodness-of-fit tests:

H = DistributionFitTest[data, d = NormalDistribution[82, 9],"HypothesisTestData"];

Why is "d" used instead of "Automatic" for the dist parameter to compare the data to a normal distribution? Does not the "Automatic" parameter do this (i.e., compare the data to a normal distribution)? The "Details & Options" section of the documentation states:

The dist can be any symbolic distribution with numeric and symbolic parameters or a dataset.

$\endgroup$
  • 2
    $\begingroup$ Automatic refers to "some unspecified normal distribution" but you can request a test for a specific normal distribution like you did with the mean and standard deviation of 82 and 9, respectively. Or you could specify the mean but allow for any standard deviation by putting in an unassigned symbol for the standard deviation. Try a few combinations from known distributions to see what you get. $\endgroup$ – JimB Feb 17 '16 at 6:47
  • 1
    $\begingroup$ The example should probably been phrased to say "test whether data was drawn from a normal distribution with known mean and standard deviation" $\endgroup$ – Andy Ross Feb 17 '16 at 12:38
  • $\begingroup$ @JimBaldwin thank you for the explanation. That makes sense. My next question would be what is the "unspecified normal distribution" used by the "Automatic" option? SAS gives the same output as this function when "Automatic" is specified. $\endgroup$ – Lucas Feb 17 '16 at 12:48
  • $\begingroup$ @AndyRoss I agree that extra language would make the example clearer, thank you. $\endgroup$ – Lucas Feb 17 '16 at 12:51
  • 1
    $\begingroup$ When automatic is given it estimates the best parameters from the data. You can confirm by extracting the "FittedDistribution" from the HypothesisTestData. Since the parameters are estimated the p-value is corrected to allow for the reduction in degrees of freedom. $\endgroup$ – Andy Ross Feb 17 '16 at 12:54
2
$\begingroup$

This is just an extended comment.

No software package documentation tells all that one might want to know. (Although additional clarity wouldn't hurt most package documentation.) Because of that one must experiment. Here is one of the things you might consider:

data = {87, 91, 97, 80, 71, 86, 72, 93, 83, 73, 76};
n = Length[data]

h0 = DistributionFitTest[data, Automatic, "FittedDistribution"]
(* NormalDistribution[82.63636363636364`,8.56284497404845`] *)

h1 = DistributionFitTest[data, NormalDistribution[μ, σ], "FittedDistribution"]
(* NormalDistribution[82.63636363636364`,8.56284497404845`] *)

h2 = N[DistributionFitTest[data, NormalDistribution[Mean[data], 
    StandardDeviation[data] ((n - 1)/n)^0.5], "FittedDistribution"]]
(* NormalDistribution[82.63636363636364`,8.56284497404845`] *)
$\endgroup$
  • $\begingroup$ This is helpful, thank you. Analyzing the hypotheses (i.e., h0, h1, h2) further, and using "HypothesisTestData" as the third parameter instead of "FittedDistribution", hx["TestDataTable", All], where x=1 to 3, the resulting statistics tables show it is equivalent to use "Automatic" or "NornalDistribution[mu, std]," but "NormalDistribution[Mean[data], StandardDeviation[data] ((n - 1)/n)^0.5]" gives different p-values. Is this as expected? Are you multiplying the std. dev by ((n - 1)/n)^0.5 to "normalize" it? If not, why? $\endgroup$ – Lucas Feb 17 '16 at 19:26
  • 1
    $\begingroup$ @AndyRoss addressed the issue above as to why the statistic is the same but the P-value differs. For h1 the data is used to determine which normal curve to compare with the P-value adjusted to account for selecting a normal curve that most closely matches the data. For h2 despite the values being set from the data, we are telling DistributionFitTest a specific normal distribution and it doesn't know that we estimated those values from the data so no adjustment for the P-value. $\endgroup$ – JimB Feb 17 '16 at 19:36
  • 1
    $\begingroup$ Multiplying the standard deviation by ((n-1)/n)^0.5 is done to match the value used when NormalDistribution[$\mu$,$\sigma$] is given. Essentially DistributionFitTest uses the maximum likelihood estimate of $\sigma$ and StandardDeviation calculates the unbiased estimate of $\sigma^2$. CrossValidated would be a better forum to deal with such differences. $\endgroup$ – JimB Feb 17 '16 at 19:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.