> Mytable1 <-xtabs (~ treatment+improved,data=arthritis)
> Mytable2 <-xtabs (~ improved+sex,data=arthritis)
> Mytable1
Improved
Treatment None Some Marked
Placebo 29 7 7
Treated 13 7 21
> Mytable2
Sexa
Improved Female Male
None 25 17
Some 12 2
Marked 22 6
> Chisq.test (MYTABLE1)
Pearson ' s chi-squared test
Data:mytable1
x-squared = 13.055, df = 2, P-value = 0.001463
> Chisq.test (mytable2)
Pearson ' s chi-squared test
Data:mytable2
x-squared = 4.8407, df = 2, P-value = 0.08889
Warning message:
In Chisq.test (mytable2): chi-squared approximate algorithm may not be allowed
In the results, the level of treatment and improvement that patients received seemed to have a relationship (P < 0.01). and patient sex
There is no relationship between the improvement situation (P > 0.05). The P-Value here indicates that the sample row variables and columns are extracted from the population
Quantity is the probability of mutual independence. Because the probability value is very small, so you reject the treatment type and the outcome of the treatment is independent of the original false
Set Because the probability is not small enough, there is not enough reason to explain that the results of treatment and sex are not independent.
The reason for the warning message is that one of the 6 cells in the table (male-to some extent) has a value less than 5,
This may cause the card-side approximation to be invalid.
R Language Note Independence test