How to perform two sets of independent sample rank and test in R language 2

Source: Internet
Author: User

If two data samples come from different groups and the samples do not affect each other, they are independent. Using the Mann-whitney-wilcoxon test, we can determine if the population distribution is the same without assuming that they follow the normal distribution.

Cases

In the Data frame column of the dataset Mtcars mpg, there are a variety of gasoline mileage data for 1974 American cars.

> Mtcars $ mpg
[1] 21.0 21.0 22.8 21.4 18.7 ...

Also, another data column in the Mtcars named AM indicates the transport type of the car model (0 = automatic, 1 = manual). In other words, it is the distinguishing factor of the transport type.

> Mtcars $ am
[1] 1 1 1 0 0 0 0 0 ...

In particular, the gasoline mileage data for manual and automatic transmissions is independent.

Problem

If there is no assumption that the data has a normal distribution, then determine if the gasoline mileage data for manual and automatic transmissions in Mtcars has the same data distribution. 05 significant level.

Solution

The 0 hypothesis is that the gasoline mileage data for manual and automatic transmissions is the same for the population. To verify this hypothesis, we use the Wilcox.test function to compare independent samples. Since the P-value proves to be 0.001817 and less than. 05 of the significant level, we reject the 0 hypothesis.

> wilcox.test(mpg~am,data = mtcars) 


Wilcoxon rank and test and continuity correction

Data: MPG AM AM
W = 42,p-value = 0.001871
Alternative hypothesis: True position offset not equal to 0

Warning message:
In Wilcox.test.default (x = C (21.4,18.7,18.1,14.3,24.4,22.8,:
The exact p-to-value relationship that cannot be calculated

Reply

At the significant level of. 05, we conclude that the gasoline mileage data for manual and automatic transmissions in the Mtcar are not the same group.

How to perform two sets of independent sample rank and test in R language 2

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.