optimal_model_space: Finds MLE parameters for each model in the given model space

View source: R/model_space.R

optimal_model_spaceR Documentation

Finds MLE parameters for each model in the given model space

Description

Given a dataset and an initial value for parameters, initializes a model space with parameters equal to initial value for each model. Then for each model performs a numerical optimization and finds parameters which maximize the likelihood.

Usage

optimal_model_space(
  df,
  timestamp_col,
  entity_col,
  dep_var_col,
  init_value,
  exact_value = TRUE,
  run_parallel = FALSE,
  control = list(trace = 2, maxit = 10000, fnscale = -1, REPORT = 100, scale = 0.05)
)

Arguments

df

Data frame with data for the SEM analysis.

timestamp_col

The name of the column with time stamps

entity_col

Column with entities (e.g. countries)

dep_var_col

Column with the dependent variable

init_value

The value with which the model space will be initialized. This will be the starting point for the numerical optimization.

exact_value

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

run_parallel

If TRUE the optimization is run in parallel using the parApply function. If FALSE (default value) the base apply function is used. Note that using the parallel computing requires setting the default cluster. See README.

control

a list of control parameters for the optimization which are passed to optim. Default is list(trace = 2, maxit = 10000, fnscale = -1, REPORT = 100, scale = 0.05), but note that scale is used only for adjusting the parscale element added later in the function code.

Value

List of parameters describing analyzed models

Examples


library(magrittr)

data_prepared <- economic_growth[,1:7] %>%
   feature_standardization(timestamp_col = year, entity_col = country) %>%
   feature_standardization(timestamp_col = year, entity_col = country,
                           time_effects = TRUE, scale = FALSE)

model_space <- optimal_model_space(df = data_prepared, dep_var_col = gdp,
                                   timestamp_col = year, entity_col = country,
                                   init_value = 0.5)



bdsm documentation built on April 4, 2025, 1:06 a.m.