I wrote a code for the LL of my unrestricted model and my restricted model and optimized this codes with optim. My test is to check whether 2 standard deviations are the same. Now I want to check whether my constraint is true or not and I used the statistic w=(s1-s2)/sqrt(vars1_vars2-2cov(s1,s2) However, it is not working? What am I doing wrong?
Asked
Active
Viewed 99 times
1 Answers
0
I think I maybe see the mistake; you mixed up two sorts of tests. The following codes are for the Wald-test and the Likelihood ratio test, you should use them separately because the Likelihood ratio test uses a chisquare test statistic:
Wald:
var_estim <- solve(-optim$hessian)
vector <- cbind(0,1,0,-1,0)
s1-s2 <- t(vector) %*% optim$par
vars1vars2 <- t(vector) %*% var_estim %*% vector
Wald <- s1-s2/sqrt(vars1vars2)
p <- 2*(1-pnorm(abs(W)))
And for the Likelihood ratio test we use:
1-pchisq(2*(yourllunrestrictedmodel$value - yourllrestrictedmodel$value), df=1)