Crosstab by using the same input for both arguments
4 ビュー (過去 30 日間)
古いコメントを表示
If I run one of the examples of crosstab, I get the same result as indicated in the crosstab webpage:
rng default; % for reproducibility
x1 = unidrnd(3,50,1);
x2 = unidrnd(3,50,1);
[table,chi2,p] = crosstab(x1,x2)
However, if I use the same input for both arguments of crosstab, I get a p-value basically equal to zero:
rng default; % for reproducibility
x1 = unidrnd(3,50,1);
x2 = unidrnd(3,50,1);
[table,chi2,p] = crosstab(x1,x1)
Shouldn't I get a p-value higher if I use the same input for both arguments of crosstab? (I was thinking about a p-value close to 1 actually)
4 件のコメント
Rahul
2024 年 8 月 16 日
編集済み: Rahul
2024 年 8 月 16 日
Hey,
By 'association of the two categorical variables' (or column vector data), I meant that one group's values affect the other variable's values, which in our case, holds true, since one variable's value is equal to other at every row. This means that our initial null hypothesis, which states that the groups are unrelated, doesnt seem to hold. This is clearly evident with the high output value of resultant 'X^2' statistic value:
chi2 = 100
which exceeds the standard critical value of 9.488 for df (degree of freedom) = (3 - 1)*(3 - 1) = 1 and alpha = 0.05 (say). (You can look up this critical value in chi-squared right probability table).
This confirms that our data doesn't support null hypothesis and hence, p-value should be lesser than alpha (= 0.05), or close to 0.
回答 (2 件)
dpb
2024 年 8 月 17 日
編集済み: dpb
2024 年 8 月 17 日
Your statements above were written under the null hypothesis that "both KSTEST2() and CROSSTAB() test that two datasets are indendent samples". However, that hypothesis is incorrect; one (crosstab) tests for independence whereas the other (kstest2) tests for being samples from the same distribution.
Ergo the two are testing alternate hypotheses of each other. p-values do have the same interpretation, but only against the specific null hypothesis under which the given test statistic is derived.
Sim
2024 年 8 月 25 日
編集済み: Sim
2024 年 8 月 25 日
2 件のコメント
dpb
2024 年 8 月 25 日
You can always suggest an enhancement.
The Statistics module in MATLAB has seemingly "just growed" rather than there being an attempt to reproduce some known package capabilities with a uniform interace and output.
It's a hard nut to crack w/ MATLAB in conventional MATLAB syntax; it would be theoretically, at least, possible to build a complete app in MATLAB code that provides yet another statistics package, but my contention is if one is doing heavy statistical computing, the better route is to use one of the many available packages which are available and have all the features; particularly the output formatting that is the difficult issue with MATLAB.
参考
カテゴリ
Help Center および File Exchange で Hypothesis Tests についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!