Edges and Observed values of Chi2gof
Show older comments
I am trying to do a chi squared test on the means of this data which I have already sorted and is not the issue here. However, my observed values are just 4 ones even though I inputted the means I calculated. Does anyone know why this happens and how to solve it? Your help would be appreciated.
a=readmatrix("DIP Project- Population.xlsx");
population=a(:,1);
production=a(:,7);
gr1gen36=a(61:90,7);
gr1gen36(isnan(gr1gen36))=0;
gr1gen36;
m1=mean(gr1gen36);
gr2gen36=a(151:180,7);
gr2gen36(isnan(gr2gen36))=0;
gr2gen36;
m2=mean(gr2gen36);
gr3gen36=a(241:270,7);
gr3gen36(isnan(gr3gen36))=0;
m3=mean(gr3gen36);
gr4gen36=a(331:360,7);
gr4gen36(isnan(gr4gen36))=0;
gr4gen36;
m4=mean(gr4gen36);
gen36=[m1,m2,m3,m4];
expected=mean(gen36);
ex=[expected,expected,expected,expected];
[h,p,tbl]=chi2gof(gen36,'Expected',ex,'Alpha',0.05)
tbl =
chi2stat: 66.0168
df: 3
edges: [9.3667 13.5667 17.7667 21.9667 26.1667]
O: [1 1 1 1]
E: [18.4500 18.4500 18.4500 18.4500]
6 Comments
Nathan
on 26 Dec 2025
the cyclist
on 26 Dec 2025
Can you upload the data? You can use the paper clip icon in the INSERT section of the toolbar.
the cyclist
on 26 Dec 2025
Edited: the cyclist
on 26 Dec 2025
I'm not saying the data is the problem. I'm trying to save myself (and everyone else here) the trouble of creating a test dataset to explore your problem. Posting a self-contained piece of data and code that exhibits your problem is always the best way to get help here. Make it as easy as possible for someont to help you.
Edit: Are you saying that the input to chi2gof() is
gen36 = [9.3667 17.7667 21.9667 26.1667]
?
That was not clear to me from your explanation, but now maybe I think that's what you meant. If so, then I understand why the data of how you got to gen36 are not important.
Edit #2: I can't figure out an input to chi2gof() that replicates your result.
Nathan
on 26 Dec 2025
Accepted Answer
More Answers (0)
Categories
Find more on Analysis of Variance and Covariance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
