# Why do EstimatedDistribution and DistributionFitTest work this way

I am fitting some time-series data to both a stable distribution and a normal distribution in order to assess the goodness of fit of each. Along the way I encountered the following confusing result. Could someone explain why this happens?

data1 ={0.0779615, 0.10661, -0.10661, -0.0253178, -0.0392207, 0.0892311, \
0.115069, 0.231802, 0.19517, 0.0279739, -0.0901511, -0.0784716, \
-0.0631789, -0.0572607, -0.0825012, 0.195567, 0.0505117, 0.183754, \
0.365871, 0.45219, 0.210721, -0.0396115, 0.0260313, 0.021456, \
-0.0318827, 0.0274891, -0.0239223, -0.00786374, 0.0194273, -0.030735, \
-0.0706707, 0.0745345, -0.0557558, 0.11472, 0.00521248, -0.0694686, \
0.0305097, 0.195748, 0.0830934, 0.205548, 0.0840846, -0.208923, \
-0.112126, 0.0727309, 0.0298448, 0.274583, 0.181881, -0.0555489, \
-0.350074, 0.0276329, 0.0780266, 0.0703987, 0.0228365}

(* First use the distribution fit test and then extract the fitted distribution *)
h1 = DistributionFitTest[data1, Automatic, "HypothesisTestData"];
h1["FittedDistribution"]

NormalDistribution[0.0443194, 0.1352]

(* EstimatedDistribution produces the same result when called with symbolic params*)
d1 = EstimatedDistribution[data1, NormalDistribution[μ1, σ1]]

Out=NormalDistribution[0.0443194, 0.1352]

(* Use DistributionFitTest on the estimated distribution *)
h2 = DistributionFitTest[data1, d1, "HypothesisTestData"];
h2["FittedDistribution"]

Out= NormalDistribution[0.0443194, 0.1352]

(* Output the TestDataTable and observe very different results *)
Grid[{{h1["TestDataTable", All]}, {h2["TestDataTable", All]}}\[Transpose], Frame -> All]


Looking inside these objects shows only one difference, which is the symbolic parameters in h1 and numeric parameters in h2, but I'm not sure why this should be, since the evaluation of the symbolic parameters should produce the same numeric results.

-
You should find the answer to this in my response to this question. –  Andy Ross Jul 18 '14 at 3:15
In one case the parameters are estimated internally. The null distribution for the tests assume the parameters are known apriori and so a correction to the p-value must be applied to account for the estimation. If you provide a fitted distribution the test assumes known parameters and makes no correction. –  Andy Ross Apr 19 at 19:19
I recommend reading the following en.m.wikipedia.org/wiki/Lilliefors_test –  Andy Ross Apr 19 at 19:22
@AndyRoss thanks for your assistance. I have thought about this some more and it now makes sense. I was missing that the EstimatedDistribution function just returns a NormalDistribution object (as can be seen with FullForm). The HypothesisTestData object returned ("h1" above) contains a lot more information and MMA picks up on that to apply the correction you describe. MMA can't distinguish the "d1" object as I used it from an a priori NormalDistribution with non-symbolic parameters. The Lilliefors reference gives clarity on how the correction gets applied. –  mdc18550 Apr 20 at 3:40