I have to consider optimization problem in simulation study. An instance is given below:
library(mvtnorm)
library(alabama)
n = 200
q = 0.5
X <- matrix(0, nrow = n, ncol = 2)
X[,1:2] <- rmvnorm(n = n, mean = c(0,0), sigma = matrix(c(1,1,1,4),
ncol = 2))
x0 = matrix(c(X[1,1:2]), nrow = 1)
y0 = x0 - 0.5 * log(n) * (colMeans(X) - x0)
X = rbind(X, y0)
x01 = y0[1]
x02 = y0[2]
x1 = X[,1]
x2 = X[,2]
pInit = matrix(rep(1/(n + 1), n + 1), nrow = n + 1)
f1 <- function(p) mean(((n + 1) * p ) ^ q)
heq1 <- function(p)
c(sum(x1 * p) - x01, sum(x2 * p) - x02, sum(p) - 1)
sol <- alabama::auglag(pInit, fn = function(p) -f1(p), heq = heq1)
cat("The maximum objective value is:", -sol$value, '
')
This gives error:
Error in eigen(a$hessian, symmetric = TRUE, only.values = TRUE) :
infinite or missing values in 'x'
I am not sure how to point out and overcome this problem. If this occurs due to mis-specification of initial point, how one can specify it in simulation work so that the program can itself sets suitable initial point and gives the right solution? Otherwise, why this error occurs and how to get rid of it? Can someone please help. Thanks!
See Question&Answers more detail:os