Class to define, block analyse and solve dynamic and algebraic models numerically
Project description
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 initialized by
model = ms.ModelSolver(equations, endogenous)
When initialized, the class reads in the equations, analyzes them for any lags, before it block analyzes it to find the smalles 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 initializing, 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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ssb_model_solver-1.4.0.tar.gz.
File metadata
- Download URL: ssb_model_solver-1.4.0.tar.gz
- Upload date:
- Size: 20.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85293e691d1af909db4c10b7df0b4cf6974114cb8ee9aceee3c7f029ddffff0d
|
|
| MD5 |
92180be90e84648c5678160d162331fc
|
|
| BLAKE2b-256 |
73f9f7d90cb45d012ecd81c13e325d17a3d874120d0d0683f8245fe411284ff8
|
Provenance
The following attestation bundles were made for ssb_model_solver-1.4.0.tar.gz:
Publisher:
release.yml on statisticsnorway/ssb-model-solver
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ssb_model_solver-1.4.0.tar.gz -
Subject digest:
85293e691d1af909db4c10b7df0b4cf6974114cb8ee9aceee3c7f029ddffff0d - Sigstore transparency entry: 171845651
- Sigstore integration time:
-
Permalink:
statisticsnorway/ssb-model-solver@cd3f25390f62418f5f8444171139ad4c4aaf1a64 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/statisticsnorway
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cd3f25390f62418f5f8444171139ad4c4aaf1a64 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ssb_model_solver-1.4.0-py3-none-any.whl.
File metadata
- Download URL: ssb_model_solver-1.4.0-py3-none-any.whl
- Upload date:
- Size: 18.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d898e7bfc3ee18dd9096f8a57d9750d072b2cdeaa6a44dcd6407ff83b314cd9
|
|
| MD5 |
315534d9f413f9c0f91e2d2f56bfa6f8
|
|
| BLAKE2b-256 |
3886871c543faa7ac85d8aba6120819efccfb3bc8732723ac6b3cafd9aa65a42
|
Provenance
The following attestation bundles were made for ssb_model_solver-1.4.0-py3-none-any.whl:
Publisher:
release.yml on statisticsnorway/ssb-model-solver
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ssb_model_solver-1.4.0-py3-none-any.whl -
Subject digest:
5d898e7bfc3ee18dd9096f8a57d9750d072b2cdeaa6a44dcd6407ff83b314cd9 - Sigstore transparency entry: 171845652
- Sigstore integration time:
-
Permalink:
statisticsnorway/ssb-model-solver@cd3f25390f62418f5f8444171139ad4c4aaf1a64 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/statisticsnorway
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cd3f25390f62418f5f8444171139ad4c4aaf1a64 -
Trigger Event:
push
-
Statement type: