Individual assignment V

Consider we have got a random sample from the bivariate normal distribution \(\mathcal{N}_2\left( \begin{pmatrix} \mu_1 \\ \mu_2 \end{pmatrix}, \Sigma = \begin{pmatrix} \sigma^2_1 & \sigma_{1,2} \\ \sigma_{2,1} & \sigma^2_2 \end{pmatrix} \right)\). We would like to perform two different tests on the null hypothesis \[H_0: 2\mu_1 - \mu_2 = 0\] against the alternative hypothesis \[H_1: 2\mu_1 - \mu_2 \neq 0\]. Later, it will be convenient for us to write the null hypothesis in the way \[H_0: A\boldsymbol{\mu} = 0,\] where \(A = (2,-1)\) and \(\boldsymbol{\mu} = \begin{pmatrix} \mu_1 \\ \mu_2 \end{pmatrix}.\) We will try to evaluate the empirical probability of the first type error and the power of these two tests. These two tests differ according to whether the variance matrix is known or unknown. First, let us find out the prob. of error 1. We will proceed in this way:

We will generate 100 random samples (to perform each test 100times) from a given bivariate normal distribution satisfying the null hypothesis, let us say \(\mathbf{X}_1, \ldots, \mathbf{X}_n \sim \mathcal{N}_2 \left(\begin{pmatrix} 1 \\ 2 \end{pmatrix}, \begin{pmatrix} 1 & 0.5 \\ 0.5 & 2 \end{pmatrix}\right).\) For the first test we will always use the knowledge of the variance matrix and for the second one we will pretend we do not know the variance matrix.

In case of the first test, the test statistic is of a form \[ T_n = n(A\boldsymbol{\overline{X}}_n - 0)^T(A\Sigma A^T)^{-1}(A\boldsymbol{\overline{X}}_n - 0)\] which, under the null hypothesis, has \(\chi^2_1\) distribution. We reject the null hypothesis for \(T_n > \chi^2_1(1-\alpha)\).

For the second test, the statistic looks as follows: \[\tilde{T}_n = (n-1)(A\boldsymbol{\overline{X}}_n - 0)^T (ASA^T)^{-1}(A\boldsymbol{\overline{X}}_n - 0)\] which, under the null hypothesis, has \(T^2_{1,n-1}\) distribution. Thus we reject if \(\tilde{T}_n > F_{1,n-1}(1-\alpha)\).

size = c(30,50,100,200,500,1000)
size
## [1]   30   50  100  200  500 1000
p1 ##empirical prob. of type I error of the 1st test
## [1] 0.054 0.052 0.056 0.058 0.048 0.056
p2 ##empirical prob. of type I error of the 2nd test
## [1] 0.050 0.046 0.060 0.060 0.048 0.056

We can see that in both cases, the empirical probs. of type I error are very close to the significance level 0.05, even for small sample sizes. We can also visualize it:

For measuring the power of these two tests, we consider different alternatives: \[2\mu_1 - \mu_2 = a\] where for \(a\) we take 0.05, 0.1 and 0.5 and we measure the power of both tests against each alternative for different sample sizes. Here we present tables with the results, the first table concerns the first test and the second table the second test

##      [,1]   [,2]    [,3]    [,4]    [,5]    [,6]    [,7]   
## [1,] "a"    "30"    "50"    "100"   "200"   "500"   "1000" 
## [2,] "0.05" "0.05"  "0.068" "0.066" "0.066" "0.094" "0.136"
## [3,] "0.1"  "0.062" "0.076" "0.094" "0.136" "0.186" "0.366"
## [4,] "0.5"  "0.286" "0.452" "0.7"   "0.924" "1"     "1"
##      [,1]   [,2]    [,3]    [,4]    [,5]    [,6]    [,7]   
## [1,] "a"    "30"    "50"    "100"   "200"   "500"   "1000" 
## [2,] "0.05" "0.054" "0.058" "0.06"  "0.066" "0.096" "0.138"
## [3,] "0.1"  "0.062" "0.074" "0.08"  "0.134" "0.192" "0.35" 
## [4,] "0.5"  "0.258" "0.4"   "0.696" "0.926" "1"     "1"

We can see that the results are very similar and it seems that even if the null and alternative hypothesis almost do not differ (a=0.05), the power is increasing with the increasing sample size, for both tests. When the difference between the null and alternative hypothesis is more distinct, the power of both tests is much higher, especially for larger sample sizes.

Let us visualise it as well: