Open RobinHankin opened 2 years ago
Tried it today:
suppressMessages(library("hyper2"))
samep.test(skating,c("hughes","kwan","slutskaya"))
#> Error in constrOptim(theta = startq, f = objective, grad = NULL, ui = UI, : initial value is not in the interior of the feasible region
Created on 2023-06-26 with reprex v2.0.2
Tried debugging samep.test()
with the following result, cut-and-pasted just before the error message given by
constrained_opt <- constrOptim(theta = startq, f = objective, grad = NULL, ui = UI, ci = CI, ...)
Browse[2]> dput(startq)
c(0.282091812545044, 8.29788065801177e-06, 0.0106041284117271,
0.0924820877512254, 0.000766645872519253, 1.52619565708673e-05,
0.000153632462222593, 1.47510996256045e-05, 0.000540730804395944,
0.00278626450583833, 5.61216837437437e-06, 0.000913980140539977,
9.99999332653507e-07, 0.0013611385930829, 0.000661050382393342,
0.000820213577549596, 0.00955008375713159, 0.0051423013299458,
2.05140413391927e-05, 0.02559701568729)
Browse[2]> UI %*% startq - CI
[,1]
[1,] 2.820908e-01
[2,] 7.297881e-06
[3,] 1.060313e-02
[4,] 9.248109e-02
[5,] 7.656459e-04
[6,] 1.426196e-05
[7,] 1.526325e-04
[8,] 1.375110e-05
[9,] 5.397308e-04
[10,] 2.785265e-03
[11,] 4.612168e-06
[12,] 9.129801e-04
[13,] -6.673465e-13
[14,] 1.360139e-03
[15,] 6.600504e-04
[16,] 8.192136e-04
[17,] 9.549084e-03
[18,] 5.141301e-03
[19,] 1.951404e-05
[20,] 2.559602e-02
[21,] 2.278852e-03
Browse[2]>
We see that element 13 is the problem, falling just outside the constraint, clearly caused by numerical accuracy problems:
startq[13]
is a tiny bit less than 1e-6
Look:
Above we see an absurdly low p-value, given that the three medallists (hughes, kwan, slutskaya) have very similar MLBT strengths at about 30%, 26% and 32% respectively. The problem is in the optimization of the likelihood for the null, in which the optimization has to respect the constraint
hughes = kwan = slutskaya
. One idea might be to furnishsamep.test()
with a starting point for the optimization which in this case would presumably be close to the result of the free optimization.