Chap 7 - Exercise 3
Purpose
> library(mnormt) > set.seed(1977) > sample.mean <- c(1, 2) > sample.cov <- matrix(c(1, 0.5, 0.5, 1), nrow = 2) > n <- 1000 > x <- rmnorm(n, mean = sample.mean, varcov = sample.cov) > A <- matrix(c(2, -1), nrow = 1) > sim.cov <- var(x) > sim.mean <- colMeans(x) > teststat.known.sig <- n * (A %*% sim.mean - 0.2) * solve(A %*% + sample.cov %*% t(A)) * t((A %*% sim.mean - 0.2)) > teststat.unknown.sig <- (n - 1) * (A %*% sim.mean - 0.2) * solve(A %*% + sim.cov %*% t(A)) * t((A %*% sim.mean - 0.2)) |
Known Sig
> teststat.known.sig [,1] [1,] 18.56751 > qchisq(0.95, 1) [1] 3.841459 |
Unknown Sig
> teststat.unknown.sig [,1] [1,] 18.05155 > qf(0.95, 1, (n - 1)) [1] 3.850784 |
As Both Statistics lie outside the critical area, reject the null that Am = 0.2