modelinvert module
Created on Thu Sep 21 12:41:10 2017
@author: IBH
Class to handle general target/instrument problems.
Number of targets should be equal to number of instruments
An instrument can comprice of severeral variables instruments are inputtet as a list of instruments
- class modelinvert.targets_instruments(databank, targets, instruments, model, defaultimpuls=0.01, defaultconv=0.01, delay=0, nonlin=False, silent=True, maxiter=30, solveopt={}, varimpulse=False, progressbar=True)[source]
Bases:
objectClass to handle general target/instrument problems. Where the response is delayed specify this with delay.
Number of targets should be equal to number of instruments
An instrument can comprice of severeral variables
Instruments are inputtet as a list of instruments
To calculate the jacobian each instrument variable has a impuls, which is used as delta when evaluating the jacobi matrix:
[ 'QO_J','TG'] Simple list each variable are shocked by the default impulse [ ('QO_J',0.5), 'TG'] Here QO_J is getting its own impuls (0.5) [ [('QO_J',0.5),('ORLOV',1.)] , ('TG',0.01)] here an impuls is given for each variable, and the first instrument consiste of two variables
Targets are list of variables
Convergence is achieved when all targets are within convergens distance from the target value
Convergencedistance can be set individual for a target variable by setting a value in <modelinstance>.targetconv
Targets and target values are provided by a dataframe.
- Parameters:
databank (TYPE) – values to run on .
targets (TYPE) – dataframe with a column for each target.
instruments (TYPE) – list of instruments .
model (TYPE) – the model to use .
defaultimpuls (TYPE, optional) – default delta . The default is 0.01.
defaultconv (TYPE, optional) – default convergence . The default is 0.01.
delay (TYPE, optional) – delay in effects . The default is 0.
nonlin (TYPE, optional) – if a number the number of iterations to trigger recalculation of jacobi. The default is False.
silent (TYPE, optional) – show iterations if false. The default is True.
maxiter (TYPE, optional) – max newton iteration. The default is 30.
solveopt (TYPE, optional) – options to bring to the solver. The default is {}.
varimpulse (TYPE, optional) – if True only update the current period, else update into the future. The default is False.
- Return type:
None.
- jacobi(per, delay=0)[source]
Calculates a jecobi matrix of derivatives based on the instruments and targets
returns a dataframe
- invjacobi(per, diag=False, delay=0)[source]
Calculates the inverted jacobi matrix
returns a dataframe
- targetseek(databank=None, shortfall=False, ti_damp=1.0, delay=0, **kwargs)[source]
Calculates the instruments as a function of targets
- __call__(*args, **kwargs)[source]
Uses
targetseek