init_model_space_params: Initialize model space matrix

View source: R/model_space.R

init_model_space_paramsR Documentation

Initialize model space matrix

Description

This function builds a representation of the model space, by creating a dataframe where each column represents values of the parameters for a given model. Real value means that the parameter is included in the model. A parameter not present in the model is marked as NA.

Usage

init_model_space_params(df, timestamp_col, entity_col, dep_var_col, init_value)

Arguments

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

init_value

A function of one argument n returning n starting values (e.g. function(n) runif(n, 0.1, 1)). It generates the starting point for every parameter of every model and thus enables, e.g., grid or randomized multi-start experiments. A constant starting point is obtained with function(n) rep(0.5, n), or equivalently by passing the single number 0.5. Starting values must be non-zero, because zeros encode excluded parameters.

Details

Currently the set of features is assumed to be all columns which remain after excluding timestamp_col, entity_col and dep_var_col.

A power set of all possible exclusions of linear dependence on the given feature is created, i.e. if there are 4 features we end up with 2^4 possible models (for each model we independently decide whether to include or not a feature).

Value

matrix of model parameters

Examples

library(magrittr)

data_prepared <- badp::economic_growth[, 1:5] %>%
  badp::feature_standardization(
    excluded_cols = c(country, year, gdp)
  ) %>%
  badp::feature_standardization(
    group_by_col  = year,
    excluded_cols = country,
    scale         = FALSE
  )

init_model_space_params(data_prepared, year, country, gdp,
                        init_value = function(n) runif(n, 0.1, 1))

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