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: ksmirnov


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: ksmirnov
Date   Tue, 21 Aug 2012 10:27:08 +0100

When you say the qnormal function, I presume you mean the -qnorm- command.

There is no one way to do it. With the normal distribution, most
people regard matching means and SDs to be the way to do it, but there
is a good case for fitting a more robust line. In the case of t with 8
d.f. (henceforth t(8))  the case is even stronger. By my calculation
t(8) has SD = sqrt(8/6) = sqrt(4/3), but you could use the IQR or any
other pair of quantiles. Similarly, although t(8) has mean, median and
any other measure of level all 0, it is open for discussion how the
data should be summarized. It may even be that 0 is a natural
reference for whatever your data are.

The straight lines come from manipulating

(observed y - level for y) / (expected x - level for x) = (spread for
y) / (spread for x)

where in practice level for x is always 0.

Example code:

 sysuse auto, clear
 egen rank = rank(mpg), unique
 su rank, meanonly
 gen expected = -invttail(8, (rank - 0.5) / `r(max)')
 su mpg, detail
 local mean = r(mean)
 local sd = r(sd)
 local median = r(p50)
 local iqr = r(p75) - r(p25)


 scatter mpg expected ///
|| function t_8 = `mean' + x * `sd' / sqrt(4/3), ra(exp) ///
|| function t_8_2 = `median' + x * `iqr' / (2 * invttail(8, 0.25)), ra(exp)


On Tue, Aug 21, 2012 at 9:41 AM, Guessab Houda
<houda.guessab@gre.generali.com> wrote:
> OK you are right. Then I will use the program you sent me.
>
> sysuse auto, clear
>>> egen rank = rank(mpg), unique
>>> su mpg, meanonly
>>> local N = r(N)
>>> gen tquantile = -invttail(8, (rank - 0.5) / `N')
>>> scatter mpg tquantile
>
> I just need to draw 45 degree reference line like the qnormal function does; can you help me with that?
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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