Jessica Milligan
Jessica Milligan

Reputation: 43

What is the meaning of sol$convergence = 1 or 2 with solnp()?

I am using solnp() in R. I know the convergence output of 0 indicates successful convergence. But what is the difference between values of 1 or 2? I can't seem to find the answer in the R documentation. Thank you.

Upvotes: 1

Views: 211

Answers (1)

khoffmann
khoffmann

Reputation: 173

Digging in the source code of solnp() I found the following

if (get(".solnp_errors", envir = .solnpenv) == 1) {
    convergence = 2
    if (trace) 
        cat(paste("\nsolnp--> Solution not reliable....Problem Inverting Hessian.\n", 
            sep = ""))
}
else {
    if (.vnorm(c(tt[1], tt[2])) <= tol) {
        convergence = 0
        if (trace) 
            cat(paste("\nsolnp--> Completed in ", .solnp_iter, 
              " iterations\n", sep = ""))
    }
    else {
        convergence = 1
        if (trace) 
            cat(paste("\nsolnp--> Exiting after maximum number of iterations\n", 
              "Tolerance not achieved\n", sep = ""))
    }
}

This means that

  • congergence = 0: Success
  • convergence = 1: Maximum amount of iterations reached
  • convergence = 2: Solution not reliable due to problems inverting the Hessian

Upvotes: 1

Related Questions