Skip to contents

This function creates a formula for the tie_effects argument in the remstats package based on a list of parameters and their corresponding values. It translates parameter names into valid remstats effect terms and combines them into a formula.

Usage

generate_formula(parameters)

Arguments

parameters

A named list of parameters and their assigned values. Parameter names must follow a specific naming convention to be recognized as valid remstats effects. For example, endogenous names could inertia or psABBA. Exogenous statistics need to have the respective statistic name from remstats::tie_effects(endogenous = FALSE) followed by _[variable], e.g. send_z1. Unrecognized names will be ignored.

Value

A formula object of class "formula", suitable for the tie_effects argument in the remstats::remstats function. The formula specifies the effects in the tie-oriented model for which statistics are computed.

Details

The generate_formula() function translates parameter names into effect terms using specific prefixes or direct matches. The following naming conventions are supported:

  • Prefixes: Certain prefixes indicate exogenous effects:

    • difference_: Generates a difference('%s', scaling = 'std') term.

    • same_: Generates a same('%s') term.

    • send_: Generates a send('%s', scaling = 'std') term.

    • receive_: Generates a receive('%s', scaling = 'std') term.

    • Additional prefixes like tie_, average_, minimum_, maximum_, and event_ are also supported.

  • Specific Terms: Endogenous effects are recognized directly by their names, such as:

    • "inertia", "indegreeSender", "reciprocity", "sp", etc.

    • These names map to their respective terms in remstats.

  • Standardization: All effects that support the scaling argument are automatically standardized by default (i.e., scaling = 'std' is applied). This ensures that the effects are computed consistently within the model.

Any parameter names that do not match a prefix or specific term will be ignored.

The formula always includes an intercept (1) by default.

See also

remstats::remstats() for computing statistics based on the generated formula.

Examples

# Define parameters
parameters <- list(
  baseline = -5,
  send_z1 = 0.5,
  difference_z2 = 0.2,
  inertia = 0.3,
  receive_z1 = 0,
  unknown_param = 1  # This will be ignored
)

# Generate formula
formula <- generate_formula(parameters)
print(formula)
#> ~1 + send("z1", scaling = "std") + difference("z2", scaling = "std") + 
#>     inertia(scaling = "std") + receive("z1", scaling = "std")
#> <environment: 0x55b52ff18638>
# Output:
# ~ 1 + send('z1', scaling = 'std') +
#   difference('z2', scaling = 'std') +
#   inertia(scaling = 'std') +
#   receive('z1', scaling = 'std')

# Use the formula in remstats
# remstats::remstats(reh, tie_effects = formula, attr_actors = covar)