Skip to content

Gibrat

Firms that grow by Gibrat's law of proportionate effect.

  • Class: GibratProcessSystem
  • Import: from skcomplex.systems.economics.finance import GibratProcessSystem
  • Field: economics/finance
  • Topics: multiplicative process, lognormal, agents
  • References:
    • Caiani et al. 2016
    • Thurner et al. 2018
    • Gibrat 1931

Use this system

The block imports the class and simulates the system with its default parameters and its tuned run settings.

from skcomplex.systems.economics.finance import GibratProcessSystem

trajectory = GibratProcessSystem().prepare().simulate()

Parameters

The model parameters take these defaults, and set_params changes them.

Parameter Default
n_firms 200
x 100.0
mu 1.02
sigma 0.05
solver 'auto'
backend 'auto'

Tags

The system with its default parameters has these capability tags, which solvers and analyses check.

Tag Values
Time discrete
Space none
Laws update
Randomness stochastic
Domains real
Structure variable membership

Class

The source of the class shows how it builds its components from its model parameters.

class GibratProcessSystem(BaseSystem):
    """Firms that grow by Gibrat's law of proportionate effect.

    The law makes their sizes lognormal. The system has the group `firms`, the mean size `mean_size`, and the largest
    size `max_size`.

    Args:
        n_firms:
            The number of firms.

        x:
            The initial size of every firm.

        mu:
            The mean of the growth factor.

        sigma:
            The standard deviation of the growth factor.

        label:
            The label of the system, which names it when it is nested in another one.

        solver:
            The solver of the problem, or `'auto'` for the one the system chooses.

        backend:
            The backend that evaluates the compiled functions, or `'auto'` for the one the system chooses.

    Examples:
        >>> from skcomplex.systems.economics.finance import GibratProcessSystem
        >>> GibratProcessSystem(10).prepare().system_.elements[0].size
        10
    """

    field = 'economics/finance'
    topics = ('multiplicative process', 'lognormal', 'agents')
    references = ('Caiani et al. 2016', 'Thurner et al. 2018', 'Gibrat 1931')
    until = 100
    observables = tuple(_get_size_observables())

    def __init__(
        self,
        n_firms: int = 200,
        *,
        x: float = 100.0,
        mu: float = 1.02,
        sigma: float = 0.05,
        label: str = 'system',
        solver: BaseSolver | str = 'auto',
        backend: BaseBackend | str = 'auto',
    ) -> None:
        super().__init__(label, solver=solver, backend=backend)
        self.n_firms = n_firms
        self.x = x
        self.mu = mu
        self.sigma = sigma

    def _prepare(self, context: Sequence[Observable] | None = None) -> None:
        """Set the system of the components built from the model parameters."""
        super()._prepare(context)
        firms = GibratFirmElement('firms', x=self.x, previous=self.x, mu=self.mu, sigma=self.sigma, size=self.n_firms)
        self.system_ = System(
            self.label,
            elements=[firms],
            interactions=[GibratGrowthInteraction('growth', target='firms')],
        )

Components

The system uses these element and interaction classes, each with its nearest class of the core.

Elements:

Interactions:

  • GibratGrowthInteraction, from Interaction
class GibratFirmElement(Element):
    """Firm whose size is multiplied every step by a normal growth factor.

    The factor is independent, `x = lambda x`.

    Args:
        label:
            The label of the agent or group.

        x:
            The initial size.

        previous:
            The size before the last step.

        mu:
            The mean of the growth factor.

        sigma:
            The standard deviation of the growth factor.

        size:
            The number of members, or `None` for one.

    Examples:
        >>> from skcomplex.systems.economics.finance import GibratFirmElement
        >>> GibratFirmElement('firms', mu=1.0, size=10).size
        10
    """

    draws = True

    def __init__(
        self,
        label: str,
        *,
        x: object = 100.0,
        previous: object = 100.0,
        mu: object = 1.02,
        sigma: Annotated[object, RealSet.closed_open(0, oo)] = 0.05,
        size: int | None = None,
    ) -> None:
        super().__init__(label, size=size)
        self.x = x
        self.previous = previous
        self.mu = mu
        self.sigma = sigma

class GibratGrowthInteraction(Interaction):
    """Growth of the sizes of firms by independent normal factors, `x = lambda x`.

    Every step every firm first keeps its size as `previous`, and then multiplies it by a factor drawn from a normal
    distribution of mean `mu` and deviation `sigma`, both values of the firm.

    Args:
        label:
            The label of the interaction.

        target:
            The firms, with their sizes `x` and `previous` and their `mu` and `sigma`.

    Examples:
        >>> from skcomplex.systems.economics.finance import GibratGrowthInteraction
        >>> GibratGrowthInteraction('growth').target
        'firms'
    """

    law_classes = (UpdateLaw,)
    draws = True

    def __init__(self, label: str, *, target: Role = 'firms') -> None:
        super().__init__(label)
        self.target = target

    def _prepare(self, context: SimpleNamespace) -> None:
        """Set the memory of the sizes and their growth as the rules of the system.

        Args:
            context:
                The namespace of the elements a binding of the roles names.
        """
        super()._prepare(context)
        self.laws_: list[BaseLaw] = [UpdateLaw(context, self._remember), UpdateLaw(context, self._grow)]

    def _remember(self, system: SystemView) -> None:
        """Keep the size of every firm as its previous size."""
        for firm in cast(list[GibratFirmView], system.get_agents('target')):
            firm.previous = firm.x

    def _grow(self, system: SystemView) -> None:
        """Multiply the size of every firm by a normal growth factor."""
        firms = cast(list[GibratFirmView], system.get_agents('target'))
        sizes = [firm.x * float(system.rng.normal(firm.mu, firm.sigma)) for firm in firms]
        for firm, size in zip(firms, sizes, strict=True):
            firm.x = size

Equations

The equations are those that symbolic returns for the system with its default parameters.