\(\huge{First \ \ step :\ Create \ a \ data}\)
Simulation :
library("mvtnorm")
n <- 1000
mu <- c(3, -1)
Sigma <- matrix(c(2, 0.75, 0.75, 1),2,2)
set.seed(1999)
sample <- rmvnorm(n, mu, Sigma)
head(sample)
## [,1] [,2]
## [1,] 3.996589 -0.7992898
## [2,] 5.130865 0.7794584
## [3,] 3.351881 -0.4648458
## [4,] 1.860841 -2.2994811
## [5,] 1.795036 -0.2717545
## [6,] 3.161069 -0.4873233
It is about a Simulation random sample from the bivariate normal distribution.
\(\huge{Second \ \ step :\ null \ hypothesis \ with \ Q^2-test}\)
\(H_0 : \mathbb{A} \mu = a \ \ vs \ \ H_1 : \mathbb{A} \mu \neq a\)
a <- 0
A <- c(1,1)
Tvalue <- n * t(A %*% apply(sample, 2, mean) - a) %*% solve(A %*% Sigma %*% A) %*% (A %*% apply(sample, 2, mean) - a)
Tvalue
## [,1]
## [1,] 972.1673
qchisq(0.95,1)
## [1] 3.841459
p_value_1 <- dchisq(Tvalue,1)
p_value_1
## [,1]
## [1,] 1.008322e-213
We note from the p-value that we can reject the null hypothesis. The means of the vectors are significantly away from the zero value.
Indeed, the means are 3 and -1.
\(\huge{Third \ \ step :\ null \ hypothesis \ with \ F-test}\)
TTvalue <- (n - 1) * t(A %*% apply(sample, 2, mean) - a) %*% solve(A %*% cov(sample) %*% A) %*% (A %*% apply(sample, 2, mean) - a)
TTvalue
## [,1]
## [1,] 1018.088
qf(0.95,1,99)
## [1] 3.937117
p_value_2 <- df(TTvalue,1,99)
p_value_2
## [,1]
## [1,] 2.973799e-55
Same conclusion for the Fisher test