Sunday, 5 February 2017

normality test OF RESIDUAL in R

normality test OF RESIDUAL  in R

 in the nortest package 

shapiro.test(mod3$residuals)

Shapiro-Wilk normality test

data:  mod3$residuals
W = 0.95036, p-value = 0.04473

NORMAL Q-Q PLOTS

plot(mod3)
press enter 4 times to get 4 different graph

The code above generates data from a normal distribution (command “rnorm”), reshapes it into a series of columns, and runs what is called a normal quantile-quantile plot (QQ Plot, for short) on the first column.
Q-Q Plot (Normal)
Q-Q Plot (Normal)
The Q-Q plot tells us what proportion of the data set (in this case, the first column of variable x), compares with the expected proportion (theoretically) of the normal distribution model based on the sample’s mean and standard deviation. We’re able to do this, because of the normal distribution’s properties. The normal distribution is thicker around the mean, and thinner as you move away from it – specifically, around 68% of the points you can expect to see in normally distributed data will only be 1 standard deviation away from the mean. There are similar metrics for normally distributed data, for 2 and 3 standard deviations (95.4% and 99.7% respectively).
However, as you see, testing a large set of data (such as the 100 columns of data we have here) can quickly become tedious, if we’re using a graphical approach. Then there’s the fact that the graphical approach may not be a rigorous enough evaluation for most statistical analysis situations, where you want to compare multiple sets of data easily. Unsurprisingly, we therefore use test statistics, and normality tests, to assess the data’s normality.

1 comment:

  1. Graphical method
    par(mfrow=c(2,2)) # init 4 charts in 1 panel
    plot(lmMod)

    ReplyDelete