Test of normality of R language

Source: Internet
Author: User

The normality of the data is the basis of many statistical methods, so the normality test is also necessary, the following describes the use of R to test the normality of several methods
1.shaprio-wilk Inspection
The comparison between sample data and normal distribution is significantly different, using the Shapiro.test () function, in the form of shapiro.test (data), which requires data to be in vector format.

2.kolmogorov-smirnov Inspection
The test is used to compare two distributions, or to compare a sample to a known distribution, using the Ks.test () function, in the form of ks.test (x, y ...), where X. is the vector to be tested, Y is a vector in contrast to X, or for a distribution sensation, such as Qmorm (), The format is also required for vector format.

3.QQ figure
Also known as the division-scale graph, if the two distributions are the same, the resulting data points will fall on a straight line, using the Qqplot () function to achieve a comparison of two distributions or vectors, such as Qqplot (Rpois (50,5), Rnorm (50,5,1)), Qqplot ( DATA2,DATA1).
Here we need to add a line to make it easy for us to judge that using the Abline () function can be done, but the function needs to specify the slope and intercept of the line, so we need to do some calculations such as:

> Qqp<-qqplot (Data2,rnorm (50,5,2))
> Abline (LM (qqp$x~qqp$y))
First, when using Qqplot (), the returned result contains the X and Y values, which we named Qqp so that the LM () function is then used to extract the two values to fit the linear model to get the slope and intercept as the parameters of the Abline.

In addition, there is a qqnorm () function specifically for comparison with the normal distribution, and there is a special qqline () function to do the comparison straight line.

Test of normality of R language

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.