Is there a code for including a p-value to test for normality of variables?

Viewed 25

I'd like to include a statistic in my summary statistics table within Stata, with the summarize command. Is there any possibility or other convenient way to include p-values (of the normality test) of the variables included? Would be very helpful. I'm using Stata 17.

1 Answers

There are many tests for normality, and several are included in Stata. The Shapiro-Wilk test is a modern classic, and quite popular. The more recent Doornik-Hansen test has been calibrated over a wide range of situations. Here's a token example:

. sysuse auto, clear
(1978 automobile data)

. swilk mpg

                   Shapiro–Wilk W test for normal data

    Variable |        Obs       W           V         z       Prob>z
-------------+------------------------------------------------------
         mpg |         74    0.94821      3.335     2.627    0.00430

. mvtest normality mpg

Test for multivariate normality

    Doornik-Hansen                   chi2(2) =   12.366   Prob>chi2 =  0.0021

The P-value is typically returned as an r-class value, so read the documentation for each command, and try return list after running each.

Related