check_convergence: Check the convergence of ergmito estimates

View source: R/ergmito-checkers.R

check_supportR Documentation

Check the convergence of ergmito estimates

Description

This is an internal function used to check the convergence of the optim function.

Usage

check_support(target_stats, stats_statmat, threshold = 0.8, warn = TRUE)

check_convergence(optim_output, model, support, crit = 5)

Arguments

target_stats, stats_statmat

See ergmito_formulae.

threshold

Numeric scalar. Confidence range for flagging an observed statistic as potentially near the boundary.

warn

logical scalar.

optim_output

A list output from the stats::optim function.

model

An object of class ergmito_loglik.

support

As returned by check_support.

crit

Numeric scalar. Level at which a parameter estimate will be questioned.

Value

A list with the following components:

  • par Updated set of parameters

  • vcov Updated variance-covariance matrix

  • valid Vector of integers with the parameters that are marked as OK.

  • status Return code of the analysis. See details.

  • note A note describing the status.

Return codes

The function makes an analysis of the outcome of the model and makes the corresponding adjustments when required. In particular, we check:

  1. Whether the optimization algorithm converged or not

  2. If the obtained estimates maximize the function. If this is not the case, the function checks whether the MLE may not exist. This usually happens when the log-likelihood function can improve by making increments to parameters that are already tagged as large. If the ll improves, then the value is replaced with Inf (+- depending on the sign of the parameter).

  3. If the Hessian is semi-positive-definite, i.e. if it is invertible. If it is not, it usually means that the function did not converged, in which case we will use MASS::ginv instead.

The return codes are composed of two numbers, the first number gives information regarding of the parameter estimates, while the second number give information about the variance-covariance matrix.

Column 1:

  • 0: Converged and estimates at the max.

  • 1: It did not converged, but I see no issue in the max.

  • 2: One or more estimates went to +/-Inf

  • 3: All went to hell. All estimates went to +/-Inf

Column 2:

  • 0: Hessian is p.s.d.

  • 1: Hessian is not not p.s.d.

Possible codes and corresponding messages:

  • 00 All OK (no message).

  • 01 \Sexpr{ergmito:::map_convergence_message(01)}.

  • 10 \Sexpr{ergmito:::map_convergence_message(10)}.

  • 11 \Sexpr{ergmito:::map_convergence_message(11)}.

  • 20 \Sexpr{ergmito:::map_convergence_message(20)}.

  • 21 \Sexpr{ergmito:::map_convergence_message(21)}.

  • 30 \Sexpr{ergmito:::map_convergence_message(30)}.


ergmito documentation built on July 9, 2023, 7:09 p.m.