Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: How to apply sktest to panel data?


From   Nick Cox <njcoxstata@gmail.com>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: How to apply sktest to panel data?
Date   Mon, 8 Apr 2013 15:22:27 +0100

There is no problem in principle about specifying -if- with -sktest-.
Here is a dopey example:

. sysuse auto , clear
(1978 Automobile Data)

. sktest mpg if foreign

                    Skewness/Kurtosis tests for Normality
                                                         ------- joint ------
    Variable |    Obs   Pr(Skewness)   Pr(Kurtosis)  adj chi2(2)    Prob>chi2
-------------+---------------------------------------------------------------
         mpg |     22       0.143          0.477         2.98         0.2250

You don't give your code or explain what "doesn't work" means,
contrary to request, so I can only guess that you made some syntax
error.

A bigger question is what are you going to do with the results and why
they are of interest.

1. Suppose some panels fall one side and other panels fall the other
side of your chosen threshold significance level? What then?

2. -sktest- tacitly assumes independence of observations. If this is
not valid for an -xt- problem, P-values are suspect, so decisions
based on them are shaky.

3. Normality (Gaussianity) of the marginal distribution of the
response is not a requirement for much. In practice, marked skewness
for example might on various grounds fit better with (e.g.) fitting on
a log scale, but that's a rather different story. (As you have returns
as your response, that is unlikely to be possible.)

4. 26 is a rather small sample size to estimate skewness and kurtosis.

The short answer to your question is "use a loop" and the mechanics of
what you are seeking are covered are an FAQ

FAQ     . . . . . . . . . . Making foreach go through all values of a variable
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N. J. Cox
        8/05    Is there a way to tell Stata to try all values of a
                particular variable in a foreach statement without
                specifying them?

http://www.stata.com/support/faqs/data-management/try-all-values-with-foreach/

Nick
njcoxstata@gmail.com

On 8 April 2013 15:06, LI Mengjia <amy.limengjia@connect.polyu.hk> wrote:

> I want to run skewness and kurtosis normality test on my panel data in the following way:
>
> (1)For each Fund, and for each Year, use the Return from Week1 to Week26 to run the sktest and also get the value of skewness and kurtosis.
>
> (2)For each Fund, use all its Return to run the sktest and also get the value of skewness and kurtosis.
>
> The 1st column is Fund, in which each cell is the code of one fund. The 2nd column is Year, from 2005-2010. The 3rd column is Week, from Week1-Week26. The last column is Return.
>
> I tried "if" to restrain the sktest to each fund code but it didn't work. And I have 299 funds that I wish to finish the tests in one go instead of running each fund for 299 times.
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index