{ "cells": [ { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "## General test based on group invariance\n", "\n", "References:\n", "\n", "+ Romano, J.P., 1988. A bootstrap revival of some nonparametric distance tests, _J. Amer. Stat. Assoc., 83_, 698–708\n", "+ Romano, J.P., 1989. Bootstrap and randomization tests of some nonparametric hypotheses, _Ann. Stat., 17_, 141–159\n", "\n", "Data $X \\sim P$ takes values in $\\mathcal X$.\n", "\n", "$\\mathcal G$ is a finite group of transformations from $\\mathcal X$ to $\\mathcal X$.\n", "$\\# \\mathcal G = G$.\n", "\n", "Want to test null hypothesis $H_0: P \\in \\Omega_0$.\n", "\n", "Suppose $H_0$ implies that $P$ is invariant under $\\mathcal G$:\n", "$$\n", " \\forall g \\in \\mathcal{G}, \\;\\; X \\sim gX.\n", "$$\n", "\n", "The _orbit of $x$ (under $\\mathcal G$)_ is $\\{ gx : g \\in \\mathcal G \\}$.\n", "(Does the orbit of $x$ always contain $G$ points?)\n", "\n", "### Test statistic $T$\n", "\n", "Let $T: \\mathcal{X} \\rightarrow \\mathbb{R}$ be a test statistic.\n", "\n", "We want to test $H_0$ at significance level $\\alpha$.\n", "\n", "For each fixed $x$, let $T^{(k)}(x)$ be the $k$th smallest \n", "element of the multiset\n", "$$\n", " [ T(gx): g \\in \\mathcal G ].\n", "$$\n", "\n", "These are the $G$ (not necessarily distinct) values $T$ takes on the orbit of $x$.\n", "\n", "### Finding the rejection region\n", "\n", "Let\n", "$$\n", " r \\equiv G - \\lfloor \\alpha G \\rfloor.\n", "$$\n", "\n", "Define\n", "$$\n", " G^+(x) \\equiv \\# \\{ g \\in \\mathcal{G}: T(gx) > T^{(r)}(x) \\}\n", "$$\n", "and\n", "$$\n", " G^r(x) \\equiv \\# \\{ g \\in \\mathcal{G}: T(gx) = T^{(r)}(x) \\}\n", "$$\n", "\n", "Let\n", "$$\n", " a(x) \\equiv \\frac{\\alpha G - G^+(x)}{G^r(x)}.\n", "$$\n", "\n", "Define\n", "$$\n", " \\phi(x) \\equiv \n", " \\left \\{ \n", " \\begin{array}{ll}\n", " 1, & T(x) > T^{(r)}(x), \\cr\n", " a(x), & T(x) = T^{(r)}(x), \\cr\n", " 0, & T(x) < T^{(r)}(x)\n", " \\end{array}\n", " \\right .\n", "$$\n", "\n", "To test the hypothesis, generate $U \\sim U[0, 1]$ independent of $X$.\n", "\n", "Reject $H_0$ if $\\phi(x) \\ge U$. (Randomized test.)\n", "\n", "\n", "### Test has level $\\alpha$ unconditionally\n", "\n", "For each $x \\in \\mathcal{X}$,\n", "\n", "$$\n", " \\sum_{g \\in \\mathcal{G}} \\phi(gx) = G^+(x) + a(x) G^r(x) = \\alpha G.\n", "$$\n", "\n", "So if $X \\sim gX \\sim P$ for all $g \\in \\mathcal G$,\n", "$$\n", "\\alpha = \\mathbb{E}_P \\frac{1}{G}\\sum_{g \\in \\mathcal {G}} \\phi(gX) \n", "$$\n", "$$\n", " = \\frac{1}{G}\\sum_{g \\in \\mathcal{G}} \\mathbb{E}_P \\phi(X) \n", "$$\n", "$$\n", " = \\mathbb{E}_P \\phi(X).\n", "$$\n", "\n", "The unconditional chance of a Type I error is exactly $\\alpha$.\n", "\n", "\n", "### Tests for the mean of a symmetric distribution\n", "\n", "Data $X = (X_j )_{j=1}^N \\in \\mathcal{X} = \\mathbb{R}^n$.\n", "\n", "$\\{ X_j \\}$ iid $P$; $\\mathbb{E} X_j = \\mu$.\n", "\n", "Suppose $P$ is symmetric. Examples?\n", "\n", "\n", "### Reflection group\n", "\n", "Let $\\mathcal{G}_\\mu$ be the group of reflections of coordinates about $\\mu$.\n", "\n", "Let $x \\in \\mathbb{R}^n$.\n", "Each $g \\in \\mathcal{G}_\\mu$ is of the form\n", "\n", "$$\n", "g(x) = (\\mu + (-1)^{\\gamma_j}(x_j - \\mu))_{j=1}^n\n", "$$\n", "\n", "for some $\\gamma = (\\gamma_j)_{j=1}^n \\in \\{0, 1\\}^n$.\n", "\n", "Is $\\mathcal{G}_\\mu$ really a group?\n", "\n", "What's the identity element? \n", "What's the inverse of $g$? \n", "What $\\gamma$ corresponds to $g_1g_2$?\n", "\n", "What is $G$, the number of elements of $\\mathcal{G}_\\mu$?\n", "\n", "What is the orbit of a point $x$ under $\\mathcal{G}_\\mu$? \n", "Are there always $2^n$ distinct elements of the orbit?\n", "\n", "Test statistic:\n", "\n", "$$\n", " T(X) = | \\bar{X} - \\mu_0 | = \\left | \\frac{1}{n} \\sum_{j=1}^n X_j - \\mu_0 \\right |.\n", "$$\n", "\n", "If $\\mathbb{E} X_j = \\mu_0$, this is expected to be small---but how \n", "large a value would be surprising?\n", "\n", "\n", "If the expected value of $X_j$ is $\\mu$ and $P$ is symmetric (i.e., if $H_0$\n", "is true), \n", "the $2^n$ potential data\n", "\n", "$$\n", " \\{ gX : g \\in \\mathcal{G}_\\mu \\}\n", "$$\n", "\n", "in the orbit of $X$ under $\\mathcal{G}$ are equally likely.\n", "\n", "Hence, the values in the multiset\n", "\n", "$$\n", " [ T(gx) : g \\in \\mathcal{G}_\\mu ]\n", "$$\n", "\n", "are equally likely, conditional on the event that $X$ is in the orbit of $x$.\n", "\n", "### How to test $H_0$: $\\mu = \\mu_0$?\n", "\n", "We observe $X = x$.\n", "\n", "If fewer than $\\alpha G$ values in $[T(gx) : g \\in \\mathcal{G}_{\\mu_0}]$ are greater than \n", "or equal to\n", "$T(x)$, reject.\n", "If more than $\\alpha G$ values are greater than $T(x)$, don't reject.\n", "Otherwise, randomize.\n", "\n", "\n", "### If $n$ is big …\n", "\n", "How can we sample at random from the orbit?\n", "\n", "Toss fair coin $n$ times in sequence, independently.\n", "Take $\\gamma_j = 1$ if the $j$th toss gives heads; $\\gamma_j = 0$ if tails.\n", "\n", "Amounts to sampling with replacement from the orbit of $x$.\n", "\n", "### Other test statistics?\n", "\n", "Could use $t$-statistic, but calibrate critical value using the permutation distribution.\n", "\n", "Could use a measure of dispersion around the hypothesized mean (the\n", "true mean minimizes expected RMS difference, assuming variance is finite).\n", "\n", "What about counting the number of values that are above $\\mu_0$?\n", "\n", "Define \n", "$$\n", "T(x) \\equiv \\sum_{j=1}^n 1_{x \\ge \\mu_0}.\n", "$$\n", "\n", "### Sign test for the median\n", "\n", "We are assuming $P$ is symmetric, so the expected value and median are equal.\n", "\n", "To avoid unhelpful complexity, suppose $P$ is continuous.\n", "\n", "Then \n", "\n", "$$\n", "\\mathbb{P} \\{ X_j \\ge \\mu \\} = 1/2, \n", "$$\n", "\n", "$$\n", " \\{ 1_{X_j \\ge \\mu} \\}_{j=1}^n \\mbox{ are iid Bernoulli}(1/2),\n", "$$\n", "\n", "and \n", "\n", "$$\n", " T(X) \\sim \\mbox{Binomial}(n, 1/2).\n", "$$\n", "\n", "This leads to the sign test: Reject the hypothesis that the median is $\\mu_0$\n", "if $T(X)$ is too large or too small.\n", "Thresholds set to get level $\\alpha$ test, using the fact that $T(X)\\sim \\mbox{Binomial}(n, 1/2)$.\n", "\n", "\n", "### Is the sign test equivalent to the permutation test for the same test statistic?\n", "\n", "Suppose we are using the test statistic $T(x) = \\sum_{j=1}^n 1_{x \\ge \\mu_0}$.\n", "Do the permutation test and the sign test reject for the same values of $x \\in \\mathcal{X}$?\n", "\n", "Suppose no component of $x$ is equal to $\\mu_0$.\n", "According to the sign test, the chance that $T(x) = k$ is\n", "${{n}\\choose{k}} 2^{-n}$ if the null is true.\n", "\n", "What's the chance that $T(x) = k$ according to the permutation test?\n", "There are $G = 2^n$ points in the orbit of $x$ under $\\mathcal G$.\n", "If the null is true, all have equal probability $2^{-n}$.\n", "Of these points, ${{n}\\choose{k}}$ have $k$ components with positive deviations from $\\mu_0$.\n", "Hence, for the permutation test, the chance that $T(x) = k$ is also \n", "${{n} \\choose {k}} 2^{-n}$: The two tests are equivalent.\n", "\n", "\n", "### Abstract setting using VC classes\n", "\n", "The distribution $P \\in \\Omega$, where $\\Omega$ is a known collection of\n", "distributions on $\\mathcal{X}$.\n", "The null hypothesis is that $P \\in \\Omega_0 \\subset \\Omega$. We assume that\n", "$\\Omega_0$ can be characterized as a set of distributions that are invariant under\n", "a transformation on $\\Omega$: let $\\tau: \\Omega \\rightarrow \\Omega_0$; we assume\n", "that $\\tau(P) = P$ for all $P \\in \\Omega_0$.\n", "\n", "Let $\\mathcal{V}$ be a collection of subsets of a set $\\mathcal{X}$.\n", "For a finite set $D \\subset \\mathcal{X}$, let $\\Delta^\\mathcal{V}(D)$ be the number of distinct sets\n", "$\\{ V \\cap D: V \\in \\mathcal{V} \\}$.\n", "For positive integers $n$, let\n", "$$\n", " m^\\mathcal{V}(n) = \\max_{D \\subset \\mathcal{X}: \\#D = n } \\Delta^\\mathcal{V}(D).\n", "$$\n", "\n", "Let\n", "$$\n", " c(\\mathcal{V}) \\equiv \\inf \\{ n : m^\\mathcal{V}(n) < 2^n \\}.\n", "$$\n", "\n", "If $c(\\mathcal{V}) < \\infty$, $\\mathcal{V}$ is a Vapnik-Cervonenkis (V-C) class.\n", "That is, $\\mathcal{V}$ is a V-C class\n", "if the maximum number of distinct intersections of sets in $\\mathcal{V}$\n", "with sets containing $n$ points grows sub-exponentially with $n$.\n", "Intersections, finite unions, and Cartesian products of V-C classes are V-C classes.\n", "In $\\mathbb{R}^n$, the set of all ellipsoids, the set of all half-spaces, the set of all\n", "lower-left quadrants, and the set of all convex sets with at most $p$ extreme\n", "points are all V-C classes.\n", "\n", "An alternative, equivalent definition of a V-C class is based on the following definition:\n", "\n", "Suppose $\\mathcal{V}$ is a collection of subsets of a set $\\mathcal{X}$, and that $D$ is a finite subset of $\\mathcal{X}$.\n", "We say $D$ is _shattered_ by $\\mathcal{V}$ if every subset $d \\subset D$\n", "can be written $d = V \\cap D$ for some $V \\in \\mathcal{V}$.\n", "\n", "Suppose $D$ has $n$ elements.\n", "Because there are $2^n$ subsets of a set with $n$ elements, this is equivalent to saying\n", "that there are $2^n$ different subsets of the form $D \\cap V$ as $V$ ranges over $\\mathcal{V}$.\n", "\n", "A collection $\\mathcal{V}$ is a V-C class if for some finite integer $n$, there exists a set\n", "$D \\subset \\mathcal{X}$ with $n$ elements that is not shattered by $\\mathcal{V}$.\n", "\n", "__Example__. Half lines on $\\mathbb{R}$.\n", "Consider a set $D = \\{x_j\\}_{j=1}^n$ of points on the real line.\n", "Let $\\mathcal{V} = \\{ (-\\infty, y] : y \\in \\mathbb{R} \\}$.\n", "How many sets are there of the form $V \\cap D$, for $V \\in \\mathcal{V}$?\n", "Just $n+1$.\n", "Suppose the points are in increasing order, so that $x_1 < x_2 < \\cdots < x_n$.\n", "Then the possibilities for $V \\cap D$ are $\\{ \\}$,\n", "$\\{ x_1 \\}$, $\\{ x_1, x_2 \\}$, $\\ldots$, $\\{x_j \\}_{j=1}^n$.\n", "Thus $m^{\\mathcal{V}}(n) = n+1$, and $c(\\mathcal{V}) \\equiv \\inf \\{ n : m^\\mathcal{V}(n) < 2^n \\} = 2$\n", "(for $n=0$, we have $0+1 = 2^0$, and for $n=1$,\n", "we have $1+1 = 2^1$, but for $n=2$, we have $2+1 < 2^2$).\n", "\n", "__Example__. Closed intervals $\\{[y, z]$: $y < z\\}$ on $\\mathbb{R}$.\n", "For finite sets $D$ as discussed above,\n", "the possibilities for $V \\cap D$ include all sets of adjacent values, such as\n", "$\\{x_1\\}$, $\\{x_2\\}$, $\\{x_3\\}$, $\\{x_1, x_2\\}$, $\\{x_2, x_3\\}$, and $\\{x_1, x_2, x_3\\}$, but not,\n", "for example, $\\{ x_1, x_3 \\}$.\n", "Clearly, $m^{\\mathcal{V}}(2) = 4$ but $m^{\\mathcal{V}}(3) = 7$, so $c(\\mathcal{V}) = 3$.\n", "(The general rule is $m^{\\mathcal{V}}(n) = 1 + n + {n}\\choose{2}$. Why?)\n", "\n", "Suppose that $\\mathcal{V}$ and $\\mathcal{W}$ are V-C classes on a common set $\\mathcal{X}$.\n", "Then $\\mathcal{V} \\cup \\mathcal{W}$ is also a V-C class, as is $\\mathcal{V} \\cap \\mathcal{W}$." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let $\\mathcal{V}$ be a VC\n", "class of subsets of $\\mathcal{S}$.\n", "Define the pseudo-metric\n", "$$\n", "\\delta: \\Omega \\times \\Omega \\rightarrow \\mathbb{R}^+\n", "$$\n", "$$\n", "(P, Q) \\rightarrow \\sup_{V \\in \\mathcal{V}} | P(V) - Q(V) | .\n", "$$\n", "\n", "This is a generalization of the Kolmogorov-Smirnov distance for distributions on the\n", "line.\n", "In that case, the sets in $\\mathcal{V}$ are the half-lines $\\{(-\\infty, y] : y \\in \\mathbb{R}\\}$\n", "(which comprise a\n", "V-C class).\n", "\n", "Assume that $\\mathcal{V}$ and $\\tau$ have been selected such that\n", "$\\delta(P, \\tau P) = 0$ iff\n", "$P \\in \\Omega_0$.\n", "Romano proposes using the test statistic\n", "$$\n", " T_n = n^{1/2} \\delta(\\hat{P}_n, \\tau \\hat{P}_n ),\n", "$$\n", "where $\\hat{P}_n$ is the empirical measure of $\\{X_j \\}_{j=1}^n$.\n", "One rejects the hypothesis when $\\tau\\hat{P}_n$ is far from $\\hat{P}_n$; i.e.,\n", "when $T_n$ is sufficiently large.\n", "\n", "But how large?\n", "One way to obtain a critical value for the test is with the bootstrap:\n", "resample from $\\tau(\\hat{P}_n)$, tabulate the distribution of the distance\n", "between the empirical distribution of the bootstrap samples and $\\tau$ applied to them,\n", "use the $1-\\alpha$ quantile of that distribution as the critical value for an\n", "approximate level $\\alpha$ test.\n", "(We have to resample from $\\tau(\\hat{P}_n)$ rather than $\\hat{P}_n$ because the\n", "significance level is computed under the assumption that the null hypothesis is _true_.\n", "The null hypothesis is true for $\\tau(\\hat{P}_n)$ but not necessarily for $\\hat{P}_n$.)\n", "\n", "Suppose that there is a (known) group $\\mathcal{G}_n$ of transformations of the sample space\n", "$\\mathcal{S}_n$\n", "such that under the null hypothesis, $P$ is invariant under $\\mathcal{G}_n$.\n", "Then we can also construct a _randomization test_ of the hypothesis $H_0$.\n", "For simplicity, suppose that $\\mathcal{G}_n$ is finite, with $M_n$ elements\n", "$\\{ g_{nj} \\}_{j=1}^{M_n}$.\n", "Under the null hypothesis, conditional on $X = x$, the values $\\{ g_{nj}x \\}_{j=1}^{M_n}$\n", "are equally likely.\n", "(The _orbit_ of an point $x$ in a space $S$ acted on by a group $\\mathcal{G}$ is the set of\n", "all elements of $S$ that can be obtained by applying elements of $\\mathcal{G}$ to $x$.\n", "That is, it is the set $\\{ g(x): g \\in \\mathcal{G}\\}$.\n", "For example, consider points in the plane and the group of rotations about the\n", "origin.\n", "Then the orbit of a point $x$ is the circle with radius $\\|x\\|$.)\n", "\n", "Compute the test statistic for each $ g_{nj}x$ in the orbit of $x$.\n", "Reject the null hypothesis if the statistic for $x$ exceeds the $1-\\alpha$ quantile of\n", "the test statistic for the set of values obtained from the orbit;\n", "do not reject if it is less; reject with a given probability if the statistic equals\n", "the $1-\\alpha$ quantile, in such a way as to get a level $\\alpha$ test.\n", "This is a randomization test.\n", "Because the level of the randomization test is $\\alpha$, conditional on the data,\n", "integrating\n", "over the distribution of the data shows that it is $\\alpha$ unconditionally.\n", "\n", "### Examples of hypotheses and functions $\\tau$\n", "\n", "Examples Romano gives include testing for independence of the components of each $X_j$,\n", "testing for exchangeability of the components of each $X_j$, testing for spherical\n", "symmetry of the distribution of $X_j$, testing for homogeneity among the $X_j$, and\n", "testing for a change point.\n", "\n", "In the example of testing for independence, the mapping $\\tau$ takes the marginal\n", "distributions of the joint distribution, then constructs a joint distribution that\n", "is the product of the marginals. For distributions with independent components,\n", "this is the identity; otherwise, it maps a distribution into one with the same\n", "marginals, but whose components are independent.\n", "For testing for spherical symmetry, $\\tau$ maps a distribution into one with the same mass\n", "at every distance from the origin, but that is uniform on spherical shells.\n", "For testing for exchangability, Romano proposes looking at the largest difference between\n", "$P$ and a permutation of the coordinates of $P$, over all permutations of the coordinates.\n", "See his paper for more details.\n", "\n", "Romano shows that these tests are consistent against all alternatives, and that\n", "the critical values given by the bootstrap and by randomization are asymptotically\n", "equal with probability one. Because the randomization tests are exact level $\\alpha$\n", "tests, they might be preferred. Romano also briefly discusses how to implement the tests\n", "computationally.\n", "\n", "Let's consider the implementation in more detail, for two hypotheses:\n", "independence of the components of a $k$-variate distribution, and\n", "rotational invariance of a bivariate distribution.\n", "\n", "### Independence\n", "We observe $\\{X_j\\}_{j=1}^n$ iid $P$, where each $X_j = (X_{ij})_{i=1}^k$ takes values in $\\mathbb{R}^k$.\n", "Under the null hypothesis, $P$ is invariant under the mapping $\\tau$ that takes the $k$\n", "marginal distributions of $P$ and multiplies them together to give a probability on\n", "$\\mathbb{R}^k$ with independent components.\n", "Let $\\hat{P}_n$ be the empirical measure; let the V-C class $\\mathcal{V}$ be the set of\n", "lower left quadrants $\\{ Q(x) : x \\in \\mathbb{R}^k \\}$ where\n", "$$\n", " Q(x) \\equiv \\{ y \\in \\mathbb{R}^k : y_i \\le x_i, \\;\\; i = 1, \\ldots, k\\}.\n", "$$\n", "Then\n", "$$\n", " \\hat{P}_n(Q(x)) = \\frac{1}{n} \\# \\{ X_j : X_{ij} \\le x_i, \\;\\; i = 1, \\ldots, k \\},\n", "$$\n", "and\n", "$$\n", " \\tau \\hat{P}_n (Q(x)) = \\prod_{i=1}^k \\frac{1}{n} \\# \\{ X_j : X_{ij} \\le x_i \\}.\n", "$$\n", "The maximum difference in the probability of a lower left quadrant $Q(x)$ occurs when\n", "$x$ is one of the points of support of $\\tau \\hat{P}_n$:\n", "$$\n", "\\sup_{V \\in \\mathcal{V}} | \\hat{P}_n (V) - \\tau \\hat{P}_n(V) |\n", "= \\sup_{x \\in \\mathbb{R}^k} | \\hat{P}_n (Q(x)) - \\tau \\hat{P}_n(Q(x)) |\n", "$$\n", "$$\n", "= \\max_{x \\in \\mathbb{R}^k : x_i \\in \\{X_{ij}\\}_{j=1}^n, \\;\\; i = 1, \\ldots, k }\n", "| \\hat{P}_n (Q(x)) - \\tau \\hat{P}_n(Q(x)) |.\n", "$$\n", "\n", "To test the null hypothesis of independence, we would compute\n", "$$\n", " T(X) = \\max_{x \\in \\mathbb{R}^k : x_i \\in \\{X_{ij}\\}_{j=1}^n, \\;\\; i = 1, \\ldots, k }\n", " | \\hat{P}_n (Q(x)) - \\tau \\hat{P}_n(Q(x)) |\n", "$$\n", "from the data $X$, then repeatedly draw iid samples $X^*$ of size $n$ from $\\tau \\hat{P}_n$,\n", "computing\n", "$$\n", " T(X^*) = \\max_{x \\in \\mathbb{R}^k : x_i \\in \\{X_{ij}^*\\}_{j=1}^n, \\;\\; i = 1, \\ldots, k }\n", " | \\hat{P}_n^* (Q(x)) - \\tau \\hat{P}_n^*(Q(x)) |\n", "$$\n", "for each.\n", "We would reject the null hypothesis\n", "that the components of $P$ are independent (at approximate significance level $\\alpha$) if\n", "$T(X)$ exceeds the $1-\\alpha$ quantile of the simulated distribution of $T(X^*)$.\n", "\n", "### Rotational invariance in $\\mathbb{R}^2$\n", "\n", "We observe $\\{X_j\\}_{j=1}^n$ iid $P$, where each $X_j = (X_{1j}, X_{2j})$ takes values in $\\mathbb{R}^2$.\n", "\n", "For $y \\in \\mathbb{R}^2$, define $|y| \\equiv \\sqrt{y_1^2 + y_2^2}$ to be the distance from $y$ to\n", "the origin.\n", "\n", "Except at the origin, the mapping from Cartesian coordinates $(x_1, x_2)$ to polar coordinates\n", "$(r, \\theta)$ is one-to-one; identify\n", "the origin with the polar coordinates $(0, 0)$.\n", "Under the null hypothesis, $P$ is invariant under the mapping $\\tau$ that produces\n", "a distribution with the same marginal distribution of $|X|$ but that is uniform on\n", "$\\theta$ for each possible value of $|X|$.\n", "\n", "As before, let $\\hat{P}_n$ be the empirical measure; let the V-C class $\\mathcal{V}$ be the set of\n", "lower left quadrants $\\{ Q(x) : x \\in \\mathbb{R}^2 \\}$ where\n", "$$\n", " Q(x) \\equiv \\{ y \\in \\mathbb{R}^k : y_i \\le x_i, \\;\\; i = 1, 2\\}.\n", "$$\n", "\n", "Then\n", "$$\n", " \\hat{P}_n(Q(x)) = \\frac{1}{n} \\# \\{ X_j : X_{ij} \\le x_i, \\;\\; i = 1, 2 \\}.\n", "$$\n", "\n", "To proceed, we need to find the probability of lower left quadrants $Q(x)$ for the\n", "distribution $\\tau \\hat{P}_n$.\n", "Consider the contribution from each $X_j$ separately.\n", "Let $R_j = |X_j| = \\sqrt{X_{1j}^2 + X_{2j}^2}$.\n", "The contribution of $X_j$ to $\\tau \\hat{P}_n (Q(x))$ is $1/n$ times the fraction of\n", "the circle $\\{ y \\in \\mathbb{R}^2 : |y| = R_j\\}$ that is in the quadrant $Q(x)$.\n", "There are eight cases to consider:\n", "\n", "1. $x_1^2 + x_2^2 > R_j^2$, $x_1, \\; x_2 < 0$ or $x_1 < -R_j$ or $x_2 < -R_j$. \n", "The contribution is 0: the quadrant does not intersect the circle $|y| = R_j$.\n", "1. $x_1, x_2 > R_j$. \n", "The contribution is $1/n$: the quadrant contains the entire circle $|y| = R_j$.\n", "1. $x_1^2 + x_2^2 \\le R_j^2$. \n", "The quadrant includes an arc that is at most half the circle. \n", "Let the points at which the quadrant boundary intersects\n", "the circle be $(x_1', x_2)$ and $(x_1, x_2')$. Then $x_1'$ is the negative\n", "root of $x_1^{'2} = R_j^2 - x_2^2$ and $x_2'$ is the negative root\n", "of $x_2^{'2} = R_j^2 - x_1^2$.\n", "The fraction of the circle included in $Q(x)$ is\n", "$$\n", "\\frac{1}{\\pi} \\sin^{-1} \\frac{1}{\\sqrt{2}} \\left ( 1 + \\frac{x_1}{R_j} \\sqrt{1 - \\frac{x_2^2}{R_j^2}}\n", "+ \\frac{x_2}{R_j} \\sqrt{1 - \\frac{x_1^2}{R_j^2}} \\right )^{1/2}.\n", "$$\n", "1. $x_1^2 + x_2^2 > R_j^2$, $-R_j < x_1 \\le 0$, $x_2 \\ge 0$. \n", "The fraction of the circle within $Q(x)$ is\n", "$$\n", "q(x_1) \\equiv \\frac{1}{\\pi} \\sin^{-1} \\frac{1}{\\sqrt{2}} \\left ( 1 - \\frac{x_1^2}{R_j^2} \\right )^{1/2}.\n", "$$\n", "1. $x_1^2 + x_2^2 > R_j^2$, $0 \\le x_1 < R_j$, $x_2 \\ge R_j$. \n", "The fraction of the circle within $Q(x)$ is $1 - q(x_1)$.\n", "1. $x_1^2 + x_2^2 > R_j^2$, $x_1 \\ge 0$, $-R_j < x_2 < 0$. \n", "The fraction of the circle within $Q(x)$ is $q(x_2)$.\n", "1. $x_1^2 + x_2^2 > R_j^2$, $x_1 \\ge R_j$, $0 \\le x_2 < R_j$. \n", "The fraction of the circle within $Q(x)$ is $1-q(x_2)$.\n", "1. $x_1^2 + x_2^2 > R_j^2$, $0 \\le x_1 < R_j$, $0 \\le x_2 < R_j$. \n", "The fraction of the circle within $Q(x)$ is $1 - q(x_1) - q(x_2)$.\n", "\n", "At which points $x$ should we evaluate the discrepancy \n", "$ D(x) = |\\hat{P}_n(Q(x)) - \\tau \\hat{P}_n (Q(x))|$?\n", "\n", "Let $R = \\max_j R_j$. Then for $x_1, x_2 > R$, $D(x) = 0$.\n", "Similarly, for $x_1, x_2 < -R$, $D(x) = 0$.\n", "\n", "We might take $x$ on a fine grid in the square $[-R, R] \\times [-R, R]$, but this is wasteful.\n", "\n", "Some thought shows that the maximum discrepancy occurs when some datum is just included\n", "in $Q(x)$, which makes $\\hat{P}_n$ relatively large compared with $\\tau \\hat{P}_n$, or when\n", "some datum is just excluded from $Q(x)$,\n", "which makes $\\tau \\hat{P}_n$ relatively large compared with $\\hat{P}_n$.\n", "\n", "The possible points of maximum discrepancy are $x$ of the form $(X_{1j}-s\\epsilon, X_{2k}-s\\epsilon)$ with\n", "$1 \\le j, k \\le n$, $s \\in \\{0, 1\\}$, and $\\epsilon$ small, together with the points\n", "$(X_{1j}-s\\epsilon, R)$ and $(R, X_{2j}-s\\epsilon)$.\n", "\n", "This is a large ($2n^2 + 4n$) but finite number of points.\n", "Denote this set by $\\mathcal{X} (\\{X_j\\}, \\epsilon)$.\n", "\n", "To draw an iid sample of size $n$ from $\\tau \\hat{P}_n$, we draw $n$ values\n", "iid uniform on $\\{r_j\\}_{j=1}^n$ and draw $n$ iid $U[0, 2\\pi]$ random variables,\n", "and treat these as the polar coordinates $(r, \\theta)$ of $n$ points in $\\mathbb{R}^2$.\n", "\n", "To test the null hypothesis of rotational invariance, we would compute\n", "$$\n", " T(X) = \\max_{x \\in \\mathbb{R}^k : x \\in \\mathcal{X} (\\{X_j\\}, \\epsilon)}\n", " | \\hat{P}_n (Q(x)) - \\tau \\hat{P}_n(Q(x)) |\n", "$$\n", "from the data $X$, then repeatedly draw iid samples $\\{X_j^*\\}$ of size $n$ from $\\tau \\hat{P}_n$,\n", "computing\n", "$$\n", " T(X^*) = \\max_{x \\in \\mathbb{R}^k : x \\in \\mathcal{X} (\\{X_j^*\\}, \\epsilon) }\n", " | \\hat{P}_n^* (Q(x)) - \\tau \\hat{P}_n^*(Q(x)) |\n", "$$\n", "for each.\n", "\n", "We would reject the null hypothesis\n", "that $P$ is rotationally invariant (at approximate significance level $\\alpha$) if\n", "$T(X)$ exceeds the $1-\\alpha$ quantile of the simulated distribution of $T(X^*)$.\n", "\n", "Under the null hypothesis, the distribution of the data is invariant under the action\n", "of the rotation group. \n", "\n", "This is not a finite group, so we cannot exhaust the\n", "set of transformations on a computer. \n", "\n", "However, we might consider the subgroup of\n", "rotations by multiples of $2\\pi/M$ for some large integer $M$.\n", "We could get an alternative approximate level $\\alpha$ test of the hypothesis\n", "of rotational invariance by comparing $T(X)$ with the $1-\\alpha$ quantile of\n", "$T$ over all such rotations of the data—the orbit of the data under this finite\n", "subgroup." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Application: testing whether seismicity follows a spatially heterogeneous, temporally homogeneous Poisson Process\n", "\n", "Reference: Luen and Stark, 2012. http://onlinelibrary.wiley.com/doi/10.1111/j.1365-246X.2012.05400.x/pdf\n", "\n", "Poisson process: condition on number of events. Given the number of events, temporal distribution uniform, times exchangeable.\n", "\n", "What's the \"projection\" operation?\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.1" } }, "nbformat": 4, "nbformat_minor": 2 }