nested_std_dev_from_params: Helper function - wraps single execution of the...

View source: R/model_space.R

nested_std_dev_from_paramsR Documentation

Helper function - wraps single execution of the log-likelihood & deviation parameters calculations. Used for nested version of SEM likelihood.

Description

Helper function - wraps single execution of the log-likelihood & deviation parameters calculations. Used for nested version of SEM likelihood.

Usage

nested_std_dev_from_params(
  params,
  data,
  df,
  timestamp_col,
  entity_col,
  dep_var_col,
  n_entities,
  n_periods
)

Arguments

params

A matrix (with named rows) with each column corresponding to a model. Each row specifies model parameters. Compare with optim_model_space_params

data

List of the SEM setup matrices, shared along different models

df

Data frame with data for the SEM analysis.

timestamp_col

The name of the column with timestamps

entity_col

Column with entities (e.g. countries)

dep_var_col

Column with the dependent variable

n_entities

Number of entities - passed to save calc. time

n_periods

Number of periods - passed to save calc. time

Value

Matrix with columns describing likelihood and standard deviations for each model. The first row is the likelihood for the model (computed using the parameters in the provided model space). The second row is the marginal likelihood approximation used to weight the models, namely exp((loglik - (k/2) * log(N * T)) / N); note that it is not a BIC. Then there are rows with standard deviations for each parameter, followed by rows with robust standard deviations. The last three rows hold tr(H^-1 J), where H is the observed information and J the outer product of the entity-level scores, the dimension of the parameter vector, and the numerical rank of J. These are the ingredients of the magnitude adjustment for misspecified likelihoods, whose rate is rank(J) / tr(H^-1 J); see score_rank for why J is typically rank deficient, and bma for why no weighting option is built on it.


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