Hi
I have 2 groups in a variable called Diabetes and 4 groups in variable called Activity.
chisquare test given below results
> chisq.test(df$Diabetes,df$Activity)
Pearson's Chi-squared test
data: df$Diabetes and df$Activity
X-squared = 129.92, df = 3, p-value < 2.2e-16
Now i want to see the pair wise relation between each group, some thing like TukeyHSD for anova.
what test i can run here for post hoc after chisquare test.
Thank you
DavoWW
October 7, 2022, 6:27am
2
Hi @sai_matcha ,
Here are a couple of options using add-on packages:
library(chisq.posthoc.test)
# Example
M <- as.table(rbind(c(762, 327, 468), c(484, 239, 477)))
dimnames(M) <- list(gender = c("F", "M"),
party = c("Democrat","Independent", "Republican"))
M
#> party
#> gender Democrat Independent Republican
#> F 762 327 468
#> M 484 239 477
# Pass data matrix to chisq.posthoc.test function
chisq.posthoc.test(M)
#> Dimension Value Democrat Independent Republican
#> 1 F Residuals 4.502054 0.6994517 -5.315946
#> 2 F p values 0.000040 1.0000000 0.000001
#> 3 M Residuals -4.502054 -0.6994517 5.315946
#> 4 M p values 0.000040 1.0000000 0.000001
chisq.posthoc.test(M,method = "bonferroni")
#> Dimension Value Democrat Independent Republican
#> 1 F Residuals 4.502054 0.6994517 -5.315946
#> 2 F p values 0.000040 1.0000000 0.000001
#> 3 M Residuals -4.502054 -0.6994517 5.315946
#> 4 M p values 0.000040 1.0000000 0.000001
# Alternative package/function
library(RVAideMemoire)
#> *** Package RVAideMemoire v 0.9-81-2 ***
chisq.theo.multcomp(M, p.method = "bonferroni")
#>
#> Pairwise comparisons using chi-squared tests
#>
#> data: M and bonferroni
#>
#> observed.gender observed.party observed.Freq expected Chi Pr(>Chi)
#> F Democrat 762 459.5 238.9717 3.954e-53 ***
#> M Democrat 484 459.5 1.5676 1.000e+00
#> F Independent 327 459.5 45.8487 7.665e-11 ***
#> M Independent 239 459.5 126.9734 1.130e-28 ***
#> F Republican 468 459.5 0.1887 1.000e+00
#> M Republican 477 459.5 0.7998 1.000e+00
#>
#> P value adjustment method: bonferroni
Created on 2022-10-07 with reprex v2.0.2
Hope this helps.
1 Like
Thank you very muh @DavoWW . Can i ask you to help me to interpret the results from above .
P values in independent session shows 1 , i am not getting that value is between which two groups.
Thanks
system
Closed
November 18, 2022, 9:34am
4
This topic was automatically closed 42 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.