non_nested_optimization_wrapper: Helper-function - finds parameters minimizing log-likelihood...

View source: R/model_space.R

non_nested_optimization_wrapperR Documentation

Helper-function - finds parameters minimizing log-likelihood function for the non-nested version of the SEM setup, using BFGS method

Description

Helper-function - finds parameters minimizing log-likelihood function for the non-nested version of the SEM setup, using BFGS method

Usage

non_nested_optimization_wrapper(
  params,
  df,
  timestamp_col,
  entity_col,
  dep_var_col,
  exact_value,
  init_value,
  max_init_attempts,
  n_all_regressors,
  n_timestamps,
  control,
  max_restarts,
  restart_tol,
  max_reoptimizations
)

Arguments

params

Vector of the initial parameters

df

Data frame with data for the SEM analysis.

timestamp_col

Column which determines time periods. For now only natural numbers can be used as timestamps

entity_col

Column which determines entities (e.g. countries, people)

dep_var_col

Column with dependent variable

exact_value

Whether the exact value of the likelihood should be computed (TRUE) or just the proportional part (FALSE). Check sem_likelihood for details.

init_value

The generator function the starting point in params was drawn from, or a single number standing for the corresponding constant generator. It is used to redraw the starting point if the likelihood turns out to be undefined at the drawn point. See optim_model_space.

max_init_attempts

Maximum number of starting points drawn from init_value for this model. See optim_model_space.

n_all_regressors

Integer. Total number of potential regressors in the full (maximal) model space. Used to compute the full parameter dimension (for \phi and \psi) so that parameters corresponding to excluded regressors can be padded with NA in the non-nested setup.

n_timestamps

Integer. Number of time periods in the panel (i.e. the number of distinct values in timestamp_col). Used to determine the required number of \phi and \psi parameters for the current model and for the full model.

control

a list of control parameters for the optimization which are passed to optim. Default is list(trace = 0, maxit = 10000, fnscale = -1, REPORT = 100, scale = 0.05).

max_restarts

Maximum number of times the BFGS optimization is restarted from its previous solution for a single model. A restart resets the internal curvature approximation of BFGS, which often makes further progress on ill-conditioned likelihood ridges where a single run stalls. Default is 5.

restart_tol

Log-likelihood improvement between restarts below which the optimization is considered converged. Improvements of this size are immaterial for posterior model probabilities. Default is 1e-3.

max_reoptimizations

Maximum number of times this model is re-optimized from a fresh starting point when its solution turns out to be one no standard errors can be computed from. See optim_model_space.

Value

List (or matrix) of parameters describing analyzed models.


badp documentation built on Aug. 20, 2026, 9:08 a.m.