r:chi-square_test
chi square test
# read the data df <- read.csv("https://goo.gl/j6lRXD") # summarize data to table table(df$treatment, df$improvement) improved not-improved not-treated 26 29 treated 35 15
# Chi-sq test chi <- chisq.test(df$treatment, df$improvement, correct=FALSE) chi Pearson's Chi-squared test data: df$treatment and df$improvement X-squared = 5.5569, df = 1, p-value = 0.01841
> summary(chi) Length Class Mode statistic 1 -none- numeric parameter 1 -none- numeric p.value 1 -none- numeric method 1 -none- character data.name 1 -none- character observed 4 table numeric expected 4 -none- numeric residuals 4 table numeric stdres 4 table numeric >
round(chi$expected,2) df$improvement df$treatment improved not-improved not-treated 31.95 23.05 treated 29.05 20.95 round(chi$observed,2) df$improvement df$treatment improved not-improved not-treated 26 29 treated 35 15
Do chi-square test as explained in chi-square test explanation.
r/chi-square_test.txt · Last modified: 2019/09/18 08:01 by hkimscil