A chi square test on truncated normal distribution? Result interpretation

2 views (last 30 days)
Hi everyone,
I have some data which looks to be a truncated normal distribution. So I want to do a chi square test to see if that's true.
I found that chi2gof allows me to use a custom cdf, so I prepared the following codes:
m = 10000;
mu = 65;
sigma = 20;
x = normrnd(mu,sigma,m,1);
%remove data above and below truncation points
b = 110;
x(x >= b) = [];
a = 30;
x(x < a) = [];
First I fit data into a truncated normal distribution, as posted before. http://www.mathworks.com/matlabcentral/newsreader/view_thread/100921
pdf_truncnorm = @(x,mu,sigma) normpdf(x,mu,sigma) ./ (normcdf(b,mu,sigma)-normcdf(a,mu,sigma));
start = [mean(x),std(x)]
[paramEsts,paramCIs] = mle(x, 'pdf',pdf_truncnorm, 'start',start, 'lower',[-Inf 0])
Now I perform the chi square test:
cdf_truncnorm = @(x,mu,sigma) ( normcdf(x,mu,sigma)- normcdf(a,mu, sigma) )./ (normcdf(b,mu,sigma)-normcdf(a,mu, sigma))
[h,p] = chi2gof(x,'cdf',{cdf_truncnorm,paramEsts(1),paramEsts(2)})
*Is this the right way to do it? *
One other thing that gets me curious is the confidence interval from mle. It is pretty tight:
paramEsts =
65.1106 19.9608
paramCIs =
64.6396 19.5126
65.5816 20.4089
But the p-value from chi-square test is actually low:
h =
0
p =
0.2361
Is there a necessary relation between confidence interval form MLE and p-value from chi2gof? Actually I found that if I fit a uniform data into normal distribution using MLE, the confidence interval is not wide either. How should that be interpreted? Thanks a lot!
Rui

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!