R Language Note Independence test

Source: Internet
Author: User

> 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.