lbelzile / TruncatedNormal

Simulation from truncated Gaussian and Student vectors, high dimensional CDF via exponential tilting
https://lbelzile.github.io/TruncatedNormal/
8 stars 4 forks source link

Question about the ptmvnorm funciton #5

Closed resuly closed 4 years ago

resuly commented 4 years ago

Thanks for this useful package. I'm very new to this area and the R language. I was trying to calculate the CDF like this:

lb <- c(0, 0)
ub <- c(740.0, 76.2)
mu <- c(344.31293403, 62.6937066)
sigma <- matrix(c(36407.0005966, -1167.50805662, -1167.50805662, 290.76915744), 2, 2)

x = c(100, 50)
ptmvnorm(x, mu=mu, sigma=sigma, lb=lb, ub=ub, log=FALSE, type="q")

The input x is between low bound and up bound, but I still get this error:

Solution to exponential tilting problem using Powell's dogleg method does not lie in convex set l < Lx < u. Aborting
lbelzile commented 4 years ago

The solution to the (unconstrained) problem is not valid because it does not satisfy the constrain. The package currently does not handle the case in which Powell’s (1970) dogleg method must be replaced by a convex solver. See https://doi.org/10.1111/rssb.12162 (Table 3) for details. I will try to have a look to see if this can be done as soon as possible (and thank you for the example).

lbelzile commented 4 years ago

In the case of your specific problem, the solution does solve the inequality constraint (but the check included a component which is degenerate). The new code on Github now handles case where the optimization problem has a solution that doesn't satisfy the inequality constraints for the truncated normal case.