[R] Chi-square test: Specifying expected proportions for two way table

Bert Gunter bgunter@4567 @end|ng |rom gm@||@com
Sat Oct 16 18:12:35 CEST 2021


Perhaps I misunderstand, but ?chisq.test explicitly says:

"If x is a matrix with at least two rows and columns, it is taken as a
two-dimensional contingency table: the entries of x must be
non-negative integers. Otherwise, x and y must be vectors or factors
of the same length; cases with missing values are removed, the objects
are coerced to factors, and the contingency table is computed from
these. Then Pearson's chi-squared test is performed of the null
hypothesis that the joint distribution of the cell counts in a
2-dimensional contingency table is the product of the row and column
marginals."

Moreover, expected counts are one component of the returned result
(see the "value" section). Proportions can of course easily then be
obtained if so desired.


Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Sat, Oct 16, 2021 at 8:52 AM Miloš Žarković <milos.zarkovic using gmail.com> wrote:
>
> Hi,
>
> Is there a function where I can specify expected proportions for the
> two-way table to
> calculate the Chi-square test? chisq.test allows specifying only the
> one-way table.
> Otherwise, I will have to write the function, but I never trust myself not
> to make a mess
> programing.
>
> Thanks,
>
> Miloš
>
> Miloš Žarković
> Professor of Internal Medicine
> School of Medicine, University of Belgrade
> Clinic of Endocrinology, Clinical Centre of Serbia
> 11000 Belgrade
> PAK 112113
> Serbia
> Phone +381 11 3639 724
> email milos.zarkovic using med.bg.ac.rs
>         milos.zarkovic using gmail.com
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list