Crosstab by using the same input for both arguments
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Rahul
el 16 de Ag. de 2024
Editada: Rahul
el 16 de Ag. de 2024
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.
Respuestas (2)
dpb
el 17 de Ag. de 2024
Editada: dpb
el 17 de Ag. de 2024
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
el 25 de Ag. de 2024
Editada: Sim
el 25 de Ag. de 2024
2 comentarios
dpb
el 25 de Ag. de 2024
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.
Ver también
Categorías
Más información sobre Hypothesis Tests en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!