SSB Model Solver
ModelSolver is a class that defines, block analyses and solves dynamic and algebraic models numerically.
See documentation for detailed information about theory and implementation of the class.
Opprettet av: Magnus Kvåle Helliesen mkh@ssb.no
Features
ModelSolver is a Python class. It defines, analyses and solves dynamic algebraic model with lots of equations.
The package is imported using
import model_solver as ms
Usage is
model = ms.ModelSolver(equations, endogenous)
where equations are equations and endogenous are endogenous variables, both stored as strings in lists.
Built with
ModelSolver uses the following packages
Example of use
Let equations = ['x+y = 1', 'x-y = 2'] and endogenous = ['x', 'y'], then the model class is instatiatied by
model = ms.ModelSolver(equations, endogenous)
When instatiatied, the class reads in the equations, analyzes them for any lags, before it block analyzes it to find the smallest model blocks that must be solved simultaneously. Note that ModelSolver is not case sensitive, such that 'x' and 'X' are the same, both in equations, lists and dataframe (below).
When the class is finished instatiating, the user can call the following methods:
solution = model.solve(dataframe)wheredataframeis a Pandas dataframe containing initial values for the endogenous variables and values for the exogenous variables.solutionis a dataframe with same dimensions asdataframecontaining the solutions for the endogenous variables.model.switch_endo_vars(old_endo_var, new_endo_var)switches the endogenous variablesold_endo_varfornew_endo_var.model.describe()writes out information about the model: the number of blocks, the size of the blocks etc.model.find_endo_var('var')returns the block number in whichvaris solved for.model.show_block(block_number)returns information about the block: endogenous variables, predetermined variables and equations.model.show_blocks()returns information about all blocks.model.trace_to_exog_vars(block_nunber)traces back to the exogenous variables that may affect the block.model.trace_to_exog_vals(block_nunber, period_index)traces back to the exogenous variable values for the period.model.draw_blockwise_graph(variable, maximum_ancestor_generations, maximum_decendants_generations)wherevariableis a variable of interest, andmaximum_ancestor_generationsandmaximum_decendants_generationsare non-negative integers that governs the number of generations before and after the variable to be graphed. The output is a HTML-file with a relational graph.model.sensitivity(block_nunber, period_index[, method='std', exog_subset=None])analyses the sensitivity of the endogenous variable in the block with respect to the exogenous variabels that determine the solution for the period.
Installation
You can install SSB Model Solver via pip from PyPI:
pip install ssb-model-solver
Usage
Please see the Reference Guide for details.
Contributing
Contributions are very welcome. To learn more, see the Contributor Guide.
License
Distributed under the terms of the MIT license, SSB Model Solver is free and open source software.
Issues
If you encounter any problems, please file an issue along with a detailed description.
Credits
This project was generated from Statistics Norway's SSB PyPI Template.
Metadata
Release files for ssb-model-solver 1.4.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ssb_model_solver-1.4.6.tar.gz | 22.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ssb_model_solver-1.4.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 41.0 kB
Release files / ssb_model_solver-1.4.6.tar.gz
| Download URL | ssb_model_solver-1.4.6.tar.gz |
|---|---|
| Size | 22.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1e9293dc3095fb9185c76e44bb2cf8e392d3767bba078ea9ea2839492bec1c05
|
|
BLAKE2b-256 checksum How to use checksums |
9d281b40efd9510c14bbc93ea44947cfad17af648933072e54b1802b8ee488d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 18, 2026.
Transparency logRelease files / ssb_model_solver-1.4.6-py3-none-any.whl
| Download URL | ssb_model_solver-1.4.6-py3-none-any.whl |
|---|---|
| Size | 19.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
10de5137fda0c38a1ebe5d003a5bba1bedb5bd7003df9406d3ec5b288b497f40
|
|
BLAKE2b-256 checksum How to use checksums |
c89f0be0dc48b77718b79a021abb6c0fc47a4a1148df51c4158df3079a8b2145
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 18, 2026.
Transparency log