I would like to perform a chi^2 goodness of fit test in Matlab and have found the function h = chi2gof(x) to do almost what I want. The only issue is that I want to perform the fit about a proposed mean and not the mean that chi2gof automatically estimates from the data.
I am going to answer starting with the point that seems to generate confusion:
The only issue is that I want to perform the fit about a proposed mean and not the mean that chi2gof automatically estimates from the data.
1.- chi2gof
does not estimate a mean from data
chi2gof
estimates how likely is the supplied data to be the pdf that you tell chi2gof
it may be.
You supply the likely pdf therefore you supply the mean and other statistical moments that the data may or may not show.
2.- By default normal aka Gaussian
If you input just x
the data
h=chi2gof(x)
chi2gof
assumes it's a normal distribution with significance level p = 0.05
If the data is generated as normal with mean=100
and sigma=1
then chi2gof
solves
is x
normal with significance level aka p=0.05 ?
To change the significance level
h=chi2gof(x,'Alpha',.01)
The default significance level by default is 0.05 .
There has been some initiative to change such 0.05 default value down to 0.005 but it backfired, the experts casting further doubt on being able at all to pontificate around a bare threshold, details in article Moving to a world beyond p<0.05, authors: R.L.Wasserstein,A.L.Schirm, N.A.Lazar Mar20th 2019 American Statistician .
3.- Alpha
IS NOT mean(x)
Alpha
is a threshold for significance level p
.
Alpha=0.01
means the probability of errors or false positives being 1 in 100 samples, on average.
4.- To change the reference distribution in chi2gof use field CDF
First define the specific distribution with the particular mean you are aiming at, for instance
pd = fitdist(x,'Weibull');
and then use pd in chi2gof
h = chi2gof(x,'CDF',pd)
The complete chi2gof
help file is available online here