Test statystyczny dla dwóch rozkładów, w których znane jest tylko podsumowanie 5-cyfrowe

17

Mam dwa rozkłady, w których znane są tylko 5-liczbowe podsumowanie (minimum, 1 kwartyl, mediana, 3 kwartyl, maksimum) i wielkość próby. W odpowiedzi na pytanie tutaj nie wszystkie punkty danych są dostępne.

Czy istnieje jakiś nieparametryczny test statystyczny, który pozwala mi sprawdzić, czy podstawowe rozkłady tych dwóch są różne?

Dzięki!

bonifaz
źródło

Odpowiedzi:

9

Pod hipotezą zerową, że rozkłady są takie same i obie próbki są otrzymywane losowo i niezależnie od wspólnego rozkładu, możemy opracować rozmiary wszystkich testów 5×5 (deterministycznych), które można wykonać, porównując jedną literę z drugą. Niektóre z tych testów wydają się mieć wystarczającą moc do wykrywania różnic w rozkładach.


Analiza

Oryginalna definicja 5 literowego podsumowania każdej zamówionej partii liczb x1x2xn jest następująca [Tukey EDA 1977]:

  • Dla dowolnej liczby m=(i+(i+1))/2 w {(1+2)/2,(2+3)/2,,(n1+n)/2} zdefiniuj xm=(xi+xi+1)/2.

  • Niech i¯=n+1i .

  • Niech m=(n+1)/2 i h=(m+1)/2.

  • 5 -letter streszczenie to zestaw {X=x1,H=xh,M=xm,H+=xh¯,X+=xn}. Jego elementy są znane odpowiednio jako minimum, dolny zawias, środkowy, górny zawias i maksymalny .

Na przykład w zestawie danych (-3),1,1,2),3),5,5,5,7,13,21) , że może obliczyć, że n=12 , m=13/2) i h=7/2) , skąd

X-=-3),H.-=x7/2)=(x3)+x4)/2)=(1+2))/2)=3)/2),M.=x13/2)=(x6+x7)/2)=(5+5)/2)=5,H.+=x7/2)¯=x19/2)=(x9+x10)/2)=(5+7)/2)=6,X+=x12=21

Zawiasy są bliskie (ale zwykle nie dokładnie takie same jak) kwartyle. Jeśli stosuje się kwartyle zauważyć, że w ogóle zostaną one ważone arytmetyczne z dwóch statystyk rzędu a tym samym będzie mieścić się w jednym z przedziałów , gdzie i może być określona z n a algorytm obliczyć kwartyle. Na ogół, jeśli P jest w przedziale [ i , i + 1 ] , że będzie swobodnie zapisu x Q odnieść się do niektórych takich ważoną średnią x i i[xja,xja+1]janq[ja,ja+1]xqxja .xi+1

Z dwóch partii danych i ( r j , j = 1 , ... , m ) , istnieją dwa oddzielne zestawienia pięcioliterowego. Możemy przetestować hipotezę zerową, że oba są przypadkowymi próbkami o wspólnym rozkładzie F , porównując jeden z x- liter x q z jedną z y- liter y r . Na przykład możemy porównać górny zawias x(xi,i=1,,n)(yj,j=1,,m),Fxxqyyrxdo dolnego zawiasu , aby zobaczyć, czy x jest znacznie mniejsze niż y . Prowadzi to do jednoznacznego pytania: jak obliczyć tę szansę,yxy

PrF(xq<yr).

Dla frakcyjnej i R nie jest to możliwe bez znajomości F . Ponieważ jednak x qx q i y r y r , to a fortioriqrFxqxqyryr,

PrF(xq<yr)PrF(xq<yr).

We can thereby obtain universal (independent of F) upper bounds on the desired probabilities by computing the right hand probability, which compares individual order statistics. The general question in front of us is

Jaka jest szansa, że najwyższa z wartości n będzie mniejsza niż r- ta najwyższa z wartości m pobranych ze wspólnego rozkładu?qthnrthm

Nawet to nie ma uniwersalnej odpowiedzi, chyba że wykluczymy możliwość, że prawdopodobieństwo jest zbyt mocno skoncentrowane na poszczególnych wartościach: innymi słowy, musimy założyć, że więzi nie są możliwe. Oznacza to, że musi być rozkładem ciągłym. Chociaż jest to założenie, jest słabe i nieparametryczne.F


Rozwiązanie

Rozkład nie odgrywa żadnej roli w obliczeniach, ponieważ po ponownym wyrażeniu wszystkich wartości za pomocą transformacji prawdopodobieństwa F otrzymujemy nowe partieFF

X(F)=F(x1)F(x2)F(xn)

and

Y(F)=F(y1)F(y2)F(ym).

Moreover, this re-expression is monotonic and increasing: it preserves order and in so doing preserves the event xq<yr. Because F is continuous, these new batches are drawn from a Uniform[0,1] distribution. Under this distribution--and dropping the now superfluous "F" from the notation--we easily find that xq has a Beta(q,n+1q) = Beta(q,q¯) distribution:

Pr(xqx)=n!(nq)!(q1)!0xtq1(1t)nqdt.

Similarly the distribution of yr is Beta(r,m+1r). By performing the double integration over the region xq<yr we can obtain the desired probability,

Pr(xq<yr)=Γ(m+1)Γ(n+1)Γ(q+r)3F~2(q,qn,q+r; q+1,m+q+1; 1)Γ(r)Γ(nq+1)

Because all values n,m,q,r are integral, all the Γ values are really just factorials: Γ(k)=(k1)!=(k1)(k2)(2)(1) for integral k0. The little-known function 3F~2 is a regularized hypergeometric function. In this case it can be computed as a rather simple alternating sum of length nq+1, normalized by some factorials:

Γ(q+1)Γ(m+q+1) 3F~2(q,qn,q+r; q+1,m+q+1; 1)=i=0nq(1)i(nqi)q(q+r)(q+r+i1)(q+i)(1+m+q)(2+m+q)(i+m+q)=1(nq1)q(q+r)(1+q)(1+m+q)+(nq2)q(q+r)(1+q+r)(2+q)(1+m+q)(2+m+q).

This has reduced the calculation of the probability to nothing more complicated than addition, subtraction, multiplication, and division. The computational effort scales as O((nq)2). By exploiting the symmetry

Pr(xq<yr)=1Pr(yr<xq)

the new calculation scales as O((mr)2), allowing us to pick the easier of the two sums if we wish. This will rarely be necessary, though, because 5-letter summaries tend to be used only for small batches, rarely exceeding n,m300.


Application

Suppose the two batches have sizes n=8 and m=12. The relevant order statistics for x and y are 1,3,5,7,8 and 1,3,6,9,12, respectively. Here is a table of the chance that xq<yr with q indexing the rows and r indexing the columns:

q\r 1       3       6       9       12
1   0.4      0.807  0.9762  0.9987  1.
3   0.0491  0.2962  0.7404  0.9601  0.9993
5   0.0036  0.0521  0.325   0.7492  0.9856
7   0.0001  0.0032  0.0542  0.3065  0.8526
8   0.      0.0004  0.0102  0.1022  0.6

A simulation of 10,000 iid sample pairs from a standard Normal distribution gave results close to these.

To construct a one-sided test at size α, such as α=5%, to determine whether the x batch is significantly less than the y batch, look for values in this table close to or just under α. Good choices are at (q,r)=(3,1), where the chance is 0.0491, at (5,3) with a chance of 0.0521, and at (7,6) with a chance of 0.0542. Which one to use depends on your thoughts about the alternative hypothesis. For instance, the (3,1) test compares the lower hinge of x to the smallest value of y and finds a significant difference when that lower hinge is the smaller one. This test is sensitive to an extreme value of y; if there is some concern about outlying data, this might be a risky test to choose. On the other hand the test (7,6) compares the upper hinge of x to the median of y. This one is very robust to outlying values in the y batch and moderately robust to outliers in x. However, it compares middle values of x to middle values of y. Although this is probably a good comparison to make, it will not detect differences in the distributions that occur only in either tail.

Being able to compute these critical values analytically helps in selecting a test. Once one (or several) tests are identified, their power to detect changes is probably best evaluated through simulation. The power will depend heavily on how the distributions differ. To get a sense of whether these tests have any power at all, I conducted the (5,3) test with the yj drawn iid from a Normal(1,1) distribution: that is, its median was shifted by one standard deviation. In a simulation the test was significant 54.4% of the time: that is appreciable power for datasets this small.

Much more can be said, but all of it is routine stuff about conducting two-sided tests, how to assess effects sizes, and so on. The principal point has been demonstrated: given the 5-letter summaries (and sizes) of two batches of data, it is possible to construct reasonably powerful non-parametric tests to detect differences in their underlying populations and in many cases we might even have several choices of test to select from. The theory developed here has a broader application to comparing two populations by means of a appropriately selected order statistics from their samples (not just those approximating the letter summaries).

These results have other useful applications. For instance, a boxplot is a graphical depiction of a 5-letter summary. Thus, along with knowledge of the sample size shown by a boxplot, we have available a number of simple tests (based on comparing parts of one box and whisker to another one) to assess the significance of visually apparent differences in those plots.

whuber
źródło
7

I'm pretty confident there isn't going to be one already in the literature, but if you seek a nonparametric test, it would have to be under the assumption of continuity of the underlying variable -- you could look at something like an ECDF-type statistic - say some equivalent to a Kolmogorov-Smirnov-type statistic or something akin to an Anderson-Darling statistic (though of course the distribution of the statistic will be very different in this case).

The distribution for small samples will depend on the precise definitions of the quantiles used in the five number summary.

Consider, for example, the default quartiles and extreme values in R (n=10):

> summary(x)[-4]
    Min.  1st Qu.   Median  3rd Qu.     Max. 
-2.33500 -0.26450  0.07787  0.33740  0.94770 

compared to those generated by its command for the five number summary:

> fivenum(x)
[1] -2.33458172 -0.34739104  0.07786866  0.38008143  0.94774213

Note that the upper and lower quartiles differ from the corresponding hinges in the fivenum command.

By contrast, at n=9 the two results are identical (when they all occur at observations)

(R comes with nine different definitions for quantiles.)

The case for all three quartiles occurring at observations (when n=4k+1, I believe, possibly under more cases under some definitions of them) might actually be doable algebraically and should be nonparametric, but the general case (across many definitions) may not be so doable, and may not be nonparametric (consider the case where you're averaging observations to produce quantiles in at least one of the samples ... in that case the probabilities of different arrangements of sample quantiles may no longer be unaffected by the distribution of the data).

Once a fixed definition is chosen, simulation would seem to be the way to proceed.

Because it will be nonparametric at a subset of possible values of n, the fact that it's no longer distribution free for other values may not be such a big concern; one might say nearly distribution free at intermediate sample sizes, at least if n's are not too small.


Let's look at some cases that should be distribution free, and consider some small sample sizes. Say a KS-type statistic applied directly to the five number summary itself, for sample sizes where the five number summary values will be individual order statistics.

Note that this doesn't really 'emulate' the K-S test exactly, since the jumps in the tail are too large compared to the KS, for example. On the other hand, it's not easy to assert that the jumps at the summary values should be for all the values between them. Different sets of weights/jumps will have different type-I error characteristics and different power characteristics and I am not sure what is best to choose (choosing slightly different from equal values could help get a finer set of significance levels, though). My purpose, then is simply to show that the general approach may be feasible, not to recommend any specific procedure. An arbitrary set of weights to each value in the summary will still give a nonparametric test, as long as they're not taken with reference to the data.

Anyway, here goes:


Finding the null distribution/critical values via simulation

At n=5 and 5 in the two samples, we needn't do anything special - that's a straight KS test.

At n=9 and 9, we can do uniform simulation:

 ks9.9 <- replicate(10000,ks.test(fivenum(runif(9)),fivenum(runif(9)))$statistic)
 plot(table(ks9.9)/10000,type="h"); abline(h=0,col=8)

enter image description here

  # Here's the empirical cdf:
 cumsum(table(ks9.9)/10000)
   0.2    0.4    0.6    0.8 
0.3730 0.9092 0.9966 1.0000 

so at n1=n2=9, you can get roughly α=0.1 (Dcrit=0.6), and roughly α=0.005 (Dcrit=0.8). (We shouldn't expect nice alpha steps. When the n's are moderately large we should expect not to have anything but very big or very tiny choices for α).

n1=9,n2=13 has a nice near-5% significance level (D=0.6)

n1=n2=13 has a nice near-2.5% significance level (D=0.6)

At sample sizes near these, this approach should be feasible, but if both ns are much above 21 (α0.2 and α0.001), this won't work well at all.

--

A very fast 'by inspection' test

We see a rejection rule of D0.6 coming up often in the cases we looked at. What sample arrangements lead to that? I think the following two cases:

(i) When the whole of one sample is on one side of the other group's median.

(ii) When the boxes (the range covered by the quartiles) don't overlap.

So there's a nice super-simple nonparametric rejection rule for you -- but it usually won't be at a 'nice' significance level unless the sample sizes aren't too far from 9-13.


Getting a finer set of possible α levels

Anyway, producing tables for similar cases should be relatively straightforward. At medium to large n, this test will only have very small possible α levels (or very large) and won't be of practical use except for cases where the difference is obvious).

Interestingly, one approach to increasing the achievable α levels would be to set the jumps in the 'fivenum' cdf according to a Golomb-ruler. If the cdf values were 0,111,411,911 and 1, for example, then the difference between any pair of cdf-values would be different from any other pair. It might be worth seeing if that has much effect on power (my guess: probably not a lot).

Compared to these K-S like tests, I'd expect something more like an Anderson-Darling to be more powerful, but the question is how to weight for this five-number summary case. I imagine that can be tackled, but I'm not sure the extent to which it's worth it.


Power

Let's see how it goes on picking up a difference at n1=9,n2=13. This is a power curve for normal data, and the effect, del, is in number of standard deviations the second sample is shifted up:

enter image description here

This seems like quite a plausible power curve. So it seems to work okay at least at these small sample sizes.


What about robust, rather than nonparametric?

If nonparametric tests aren't so crucial, but robust-tests are instead okay, we could instead look at some more direct comparison of the three quartile values in the summary, such as an interval for the median based off the IQR and the sample size (based off some nominal distribution around which robustness is desired, such as the normal -- this is the reasoning behind notched box plots, for example). This should tend to work much better at large sample sizes than the nonparametric test which will suffer from lack of appropriate significance levels.

Glen_b -Reinstate Monica
źródło
1
Very nice! I wonder off-hand if given the summary statistics you could actually calculate the maximum or minimum possible D statistic for the KS test. For example, you can draw the CDFs based on the summary statistics, and then there will by p-box windows for each sample CDF. Based on those two p-box windows you could calculate the maximum or minimum possible D statistic - and then look up the test statistic in usual tables.
Andy W
2

Nie rozumiem, jak mógłby być taki test, przynajmniej bez pewnych założeń.

Możesz mieć dwie różne dystrybucje, które mają to samo podsumowanie 5 liczb:

Oto trywialny przykład, w którym zmieniam tylko 2 liczby, ale wyraźnie więcej liczb można zmienić

set.seed(123)

#Create data
x <- rnorm(1000)

#Modify it without changing 5 number summary
x2 <- sort(x)
x2[100] <- x[100] - 1
x2[900] <- x[900] + 1

fivenum(x)
fivenum(x2)
Peter Flom - Przywróć Monikę
źródło
Ten przykład pokazuje jedynie ograniczenie mocy takiej procedury, ale poza tym nie wydaje się rzucać na nią zbyt wiele światła.
whuber
I think it means that, without some assumptions, the power of such a test would be inestimable. What could such a test look like?
Peter Flom - Przywróć Monikę
1
Obliczenia mocy zawsze będą wymagały założeń, nawet w przypadku testów nieparametrycznych. Spróbuj znaleźć krzywą mocy dla Kołmogorowa-Smirnowa bez większej liczby założeń niż potrzeba do przeprowadzenia samego testu.
Glen_b
2
Istnieje niewielka, skończona liczba testów, które można rozważyć: porównują wartości w jednym podsumowaniu z wartościami w innym. Jednym z nich byłoby (na przykład) porównanie górnego zawiasu jednego zestawu danych z dolnym zawiasem innego. W przypadku wystarczająco dużych liczebności próby oznaczałoby to znaczną różnicę w jednej populacji w porównaniu z inną. Jest to związane ze wspólnym prawdopodobieństwem, żeX>Y dla niezależnych zmiennych losowych X i Y. Chociaż nie masz dużej kontroli nad poziomem istotności, testy te mogą być dość skuteczne w stosunku do dużego zestawu alternatyw.
whuber
@ whuber Bez jakiejkolwiek miary błędu lub dokładności pomiarów? Czy to wynika z wielkości próby? Kwantyle, a nawet maksimum i min, są trudne do pracy w ten sposób.
Peter Flom - Przywróć Monikę