# Hypothesis testing, type I and II error

A sample $$X_1, X_2, X_3, X_4$$ comes from a normal distribution $$N(m, 2^2)$$. To verify $$H_0: m=4$$ against $$H_1: m = 1$$ one uses a test with a critical region: $$K = \{4X_1 − 2X_2 − 2X_3 + X_4 < −2\}$$. Compute the probability of type I and type II error.

Ok, so type I error is the probability of rejecting null while it is true, so I need to obtain $$\mathbb P_{m=4}(T(\mathbb X)\in K)$$. So I guess my test statistics $$T$$ is just a mean, so $$T=\frac{X_1+X_2+X_3+X_4}{4}$$, or maybe I am completely wrong?

I will assume the data are independent. Let $$T(\mathbf{X}) = \mathbf{X}^T\beta$$ where $$\mathbf{X} = [X_1,X_2,X_3,X_4]^T$$ and $$\beta = [4, -2, -2, 1]^T$$.

Note that

$$\mathbb{E}(T(\mathbf{X}) \vert H_0) = 4$$

and $$\operatorname{Var}(T(\mathbf{X})\vert H_0) = 100$$

using properties of the expectation operator and the variance operator (namely that the expectation operator is a linear operator, that $$\operatorname{Var}(aX) = a^2 \operatorname{Var}(X)$$, and that the covariance between random variables is 0 if they are independent).

Since $$X_i$$ are iid normal, then $$T(\mathbf{X}) \sim \mathcal{N}(4, 10^2)$$.

The probability we reject the null hypothesis when it is true is thus

$$P(T(\mathbf{X})<-2) = .274$$

Some simulation verifies this is the case

set.seed(0)
nreps = 100000

# represent T(X) as an inner product.
b = c(4, -2, -2, 1)

#data under the null
# rows are samples.  Rerun the experiment nreps times.
x = matrix(rnorm(nreps*4, 4, 2), nrow=nreps)

# Compute the test statistic
test_stats = x%*%b

mean(-test_stats>2)
>>>0.27195 # Close enough


The type II error is failing to reject the null when the alternative is the case. You can use similar logic as I have to construct that probability.

• Amazing. Thank you a lot!
– amal
May 26, 2021 at 7:41