I am trying to compute the log likelihood ratio test in R, but am having some difficulties.
For some reason I keep getting a negative log likelihood value which isn't possible I do not know the reason.
This is the data I am using.
Here is the code so far:
I am trying to test the null hypothesis that the mean is not equal to (1,1,1) The reason I multiply the covariance matrix by (n4-1)/n4 is that I need to divide the covariance by n, not n-1, and the cov function divides the matrix by n-1.
data <- read.csv('dat1.csv')
data <- data[, 2:4]
datamat <- as.matrix(data, nrow=25, ncol=3)
mu0_4 <- c(1,1,1)
n4 <- dim(datamat)[1]
xbar4 <- colMeans(datamat)
hs4 <- cov(datamat - xbar4)*(n4-1)/n4
det_hs4 <- det(hs4)
det_hs4
hs04 <- cov(datamat - mu0_4)*(n4-1)/n4
det_hs04 <- det(hs04)
det_hs04
LRS <- (det_hs4/det_hs04)^(n4/2)
l_lrs <- -2*log(LRS)
l_lrs
I am unsure of the reason I am getting a negative value, but if someone could please give me some advice that would be much appreciated.
Thank you for reading