Arithmetic Brownian Motion

Bases: ABCStochasticProcess

A class for Arithmetic Brownian Motion

The stochastic equation is:

    dS_t = \mu * dt + \sigma * dB_t

where B_t is the Brownian motion and S_t is the process at time t.

Example:

>>> abm = ArithmeticBrownianMotion(mu=0., sigma=0.5)
>>> paths = abm.simulate(
>>>     initial_value=0.5,
>>>     n_steps=52,
>>>     delta=1/52,
>>>     n_simulations=100
>>> )

Example:

>>> data = pd.read_csv('path/to/data.csv')
>>> abm = ArithmeticBrownianMotion()
>>> res = abm.calibrate(data)

Initialize the class

Parameters:
  • mu (float | None, default: None ) –

    drift coefficient

  • sigma (float | None, default: None ) –

    diffusion coefficient

  • rng (Generator | int | None, default: None ) –

    The random state for generating simulations and bootstrap samples

bounds: BaseModel property

Return the model bounds

is_calibrated: bool property

Return a flag to indicate whereas parameters are not null

parameters: dict property

Return the model parameters

__repr__() -> str

Override the REPL output

__str__() -> str

Override the print output

calibrate(observations: pd.DataFrame, delta: float = 1, method: str = 'mle', n_boot_resamples: int = 1000, n_jobs: int = 2, n_trials: int = 8, starting_value: dict | None = None) -> CalibrationResult

Calibrate the parameters of the stochastic process using various estimation methods.

This method calibrates the parameters of the stochastic process based on the provided observations and specified calibration settings. The calibration can be performed using different methods, including Maximum Likelihood Estimation (MLE), parametric bootstrap, or non-parametric bootstrap.

For numerical estimation of MLE see:

• López-Pérez, Alejandra, Manuel Febrero-Bande, and Wencesalo González-Manteiga. "Parametric Estimation of Diffusion Processes: A Review and Comparative Study." Mathematics 9.8 (2021): 859.

For parametric bootstrap:

• Tang, Cheng Yong, and Song Xi Chen. "Parameter estimation and bias correction for diffusion processes." Journal of Econometrics 149.1 (2009): 65-81.

For non-parametric bootstrap

• Hall, Peter. "Resampling a coverage pattern." Stochastic processes and their applications 20.2 (1985): 231-246.

• Bühlmann, Peter. "Bootstraps for time series." Statistical science (2002): 52-72.

The optimal length is selected according to:

• Buhlmann, Peter. "Blockwise bootstrapped empirical process for stationary sequences." The Annals of Statistics (1994): 995-1012.

Parameters:
  • observations (DataFrame) –

    A DataFrame containing observations of the stochastic process. The column represents a path or realization of the process, and each row represents a separate time step. The DataFrame should have dimensions (n_observations, ), where n_observations is the number of observations per path.

  • delta (float, default: 1 ) –

    The sampling interval between consecutive observations

  • method (str, default: 'mle' ) –

    The calibration method to use. Choices are 'mle' for Maximum Likelihood Estimation, 'parametric_bootstrap' for parametric bootstrap, and 'non_parametric_bootstrap' for non-parametric bootstrap

  • n_boot_resamples (int, default: 1000 ) –

    The number of bootstrap resamples to perform during calibration

  • n_jobs (int, default: 2 ) –

    The number of parallel jobs to use during calibration

  • starting_value (dict | None, default: None ) –

    initial value used in the numerical calibration procedue, if not provided a random guess is performed

  • n_trials (int, default: 8 ) –

    number of numerical trials in the numerical mle

Returns:
  • CalibrationResult

    An object that stores the results of the calibration procedure, including the calibrated parameters, observations used for calibration, calibration method, number of bootstrap resamples, number of parallel jobs, and bootstrap results.

copy() -> Self

Create a deep-copy of the object

Returns:
  • Self

    A deep-copy of the stochastic processes class

log_likelihood(observations: pd.DataFrame, delta: float = 1.0) -> float

Calculate the log-likelihood function for the stochastic process.

This method computes the log-likelihood function of the stochastic process based on the provided observations and sampling interval, using the parameters stored as attributes within the object.

Parameters:
  • observations (DataFrame) –

    A DataFrame containing observations of the stochastic process. The column represents a path or realization of the process, and each row represents a separate time step. The DataFrame should have dimensions (n_observations, ), where n_observations is the number of observations per path.

  • delta (float, default: 1.0 ) –

    The sampling interval between consecutive observations

Returns:
  • float

    The value of the log-likelihood function computed for the given observations

simulate(initial_value: float | tuple, n_steps: int, delta: float = 1.0, n_simulations: int = 1, method: str = 'exact') -> pd.DataFrame

Simulate paths of the stochastic process.

This method generates simulated paths of a generic stochastic process based on the provided parameters.

Parameters:
  • initial_value (float | tuple) –

    The initial value or starting point for the simulation, if required also the initial volatility

  • n_steps (int) –

    The number of steps or observations to simulate, excluding the initial value

  • delta (float, default: 1.0 ) –

    The sampling interval between consecutive observations

  • n_simulations (int, default: 1 ) –

    The number of paths to simulate

  • method (str, default: 'exact' ) –

    The number of paths to simulate

Returns:
  • DataFrame

    A DataFrame containing simulated paths of the stochastic process. Each row represents time step, and each column represents a separate simulation path. The first row corresponds to the initial value, and subsequent rows correspond to subsequent observations. The DataFrame has shape (n_steps + 1, n_simulations)