pyperfectforesight.sparse_jacobian#

pyperfectforesight.sparse_jacobian(X, params, all_syms, block_funcs, vars_dyn, dynamic_eqs, vars_exo=None, exog_path=None, endo_lags=None, exo_lags=None)[source]#

Build sparse Jacobian matrix using block structure

Parameters:#

Xndarray

State path (T x n_endo)

paramsdict

Parameter values

all_symslist

All symbols in the equations

block_funcsdict

Compiled Jacobian block functions

vars_dynlist

List of endogenous variable names

dynamic_eqslist

List of dynamic equations

vars_exolist, optional

List of exogenous variable names

exog_pathndarray, optional

Exogenous variable path (T x n_exo)

endo_lagslist of int, optional

Sorted list of integer lags that appear for endogenous variables. If None (or if exo_lags is also None), derived automatically from all_syms via _compute_lag_sets. Pass model_funcs[‘endo_lags’] to avoid rescanning all_syms on every Newton iteration. Jacobian blocks for out-of-range time indices are clamped to [0, T-1] and accumulated into the clamped column, consistent with residual() boundary handling.

exo_lagslist of int, optional

Sorted list of integer lags for exogenous variables. Same semantics as endo_lags.

Returns:#

sparse matrixSparse Jacobian in CSR format of shape (neq*(T-1), n*T)

where neq = len(dynamic_eqs).