Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
208 views
in Technique[技术] by (71.8m points)

r - Multiple Chi-squared tests

I am trying to show there is a difference between the survival rates of different classes in the Titanic data in r. I am using the chi-squared via prop.test but the result I get makes no sense. There is a clear greater survival of the first class compared to the others.

ship=data.frame(Titanic)
byclass = xtabs(Freq ~ Class + Survived, data = ship)


i_will_survive = as.vector(byclass[c(1:4),2])
total = as.vector(byclass[c(1:4),1]) + as.vector(byclass[c(1:4),2])
survival_rate = i_will_survive/total
> prop.test( survival_rate, total )

    4-sample test for equality of proportions without continuity correction

data:  survival_rate out of total
X-squared = 1.285, df = 3, p-value = 0.7327
alternative hypothesis: two.sided
sample estimates:
      prop 1       prop 2       prop 3       prop 4 
0.0019218935 0.0014527547 0.0003571171 0.0002706757 

Warning message:
In prop.test(survival_rate, total) :
  Chi-squared approximation may be incorrect

What does this error message mean?

I think I need to run this again but do it so that I compare crew vs first class, then third vs first then second vs first then crew vs second and so on. With 4! total out puts then I could display the chi squared values as a heat map with a Bonferroni corrected alpha value of 0.05/(4!). Is my reasoning sound or have I over complicated things?

question from:https://stackoverflow.com/questions/65865981/multiple-chi-squared-tests

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...