biogeme.latent_variables.structural_equation module

Structural equations for latent variables.

This module defines StructuralEquation, a lightweight specification of latent-variable structural equations. A structural equation consists of:

  • a latent variable name,

  • a set of explanatory variables entering the deterministic part,

  • a stochastic error term built from simulation draws, scaled by a strictly positive parameter (sigma).

The deterministic part is a linear-in-parameters expression built with one coefficient per explanatory variable.

The full structural equation returned by StructuralEquation.expression() creates a DistributedParameter whose child is the sum of the deterministic component and a random term sigma * Draws(draw_type=...).

Michel Bierlaire Tue Dec 23 2025, 16:00:07

class biogeme.latent_variables.structural_equation.StructuralEquation(name, explanatory_variables, sigma_factory=None)[source]

Bases: object

Specification of a latent-variable structural equation.

The structural equation defines the deterministic part as a linear utility over the explanatory variables and adds a stochastic term based on draws.

Parameters:
  • name (str) – Name of the latent variable.

  • explanatory_variables (Iterable[str]) – Iterable of variable names entering the deterministic part.

  • sigma_factory (SigmaFactory | None) – Factory creating a strictly positive scale parameter (sigma) used to scale the draw-based stochastic term. Required unless an explicit scale_parameter is provided to expression().

explanatory_variables: Iterable[str]
expression(*, draw_type, scale_parameter=None)[source]

Construct the full structural equation including the stochastic term.

If scale_parameter is not provided, the method uses sigma_factory to create a strictly positive sigma parameter named with prefix.

The returned expression is a DistributedParameter with child expression:

deterministic + scale_parameter * Draws(draw_type=draw_type).

Parameters:
  • draw_type (str) – Draw type identifier used by Draws.

  • scale_parameter (Expression | None) – Optional scale parameter (sigma). If None, it is created through sigma_factory.

Return type:

Expression

Returns:

Expression representing the full structural equation.

Raises:

ValueError – If scale_parameter is None and sigma_factory is undefined.

get_expression_deterministic_part()[source]

Construct the deterministic part of the structural equation.

A coefficient Beta is created for each explanatory variable and assembled into a LinearUtility.

Return type:

Expression

Returns:

A linear expression representing the deterministic component.

name: str
property prefix: str

Prefix used to namespace parameters belonging to this structural equation.

sigma_factory: SigmaFactory | None = None