StateSpaceEcon Reference

    Public Interface

    Steady state solver

    StateSpaceEcon.SteadyStateSolverModule
    SteadyStateSolver

    A module that is part of StateSpaceEcon package. Contains methods for finding a steady state solution of a model.

    StateSpaceEcon.SteadyStateSolver.check_sstateMethod
    check_sstate(model; <options>)

    Run a diagnostic test to determine if the steady state solution stored within the given model object is indeed a solution of the steady state system of equations.

    Return the number of steady state equations that are violated by the current steady state solution. If verbose=true, also display diagnostic information in the form of listing all bad equations and their residuals.

    Options

    Standard options (default values from model.options)

    • verbose
    • tol - an equation is considered satisfied if its residual, in absolute value, is smaller than this number.
    StateSpaceEcon.SteadyStateSolver.clear_sstate!Method
    clear_sstate!(model; lvl=0.1, slp=0.0, <options>)

    Set the steady state values to the provided defaults and presolve.

    Arguments

    • model - the model instance
    • lvl, slp - the initial guess for the level and the slope. Each could be a number or a vector of length equal to the number of variable in the model. Variables include regular and exogenous variables, but not shocks (shocks are assumed to be 0 in steady state).

    Options

    Standard options (default values are taken from model.options)

    • verbose
    StateSpaceEcon.SteadyStateSolver.diagnose_sstateMethod
    diagnose_sstate([point,] model)

    Run diagnostics on the steady state of the given model. If point is not given, then we check the steady state solution stored inside the given model.

    Return a tuple of "bad" equations and "bad" variables.

    The set of "bad" equations is one that is inconsistent, i.e. there is no solution. This might happen if the system is overdetermined.

    The set of "bad" variables contains variables that cannot be solved uniquely. This might happen if the system is underdetermined. In this case, try adding steady state constraints until you get a unique solution. See @steadystate in ModelBaseEcon.

    Internal function

    The output from this function may be difficult to read.<br> Call check_sstate instead.

    StateSpaceEcon.SteadyStateSolver.initial_sstate!Method
    initial_sstate!(model, init; <options>)

    Set the steady state values from the given vector and presolve.

    Call this function to specify initial guesses for the iterative steady state solver. If the value of a steady state variable is known, it is better to use @steadystate to add that as a steady state constraint.

    Arguments

    • model - the model.
    • init - a vector of length equal to twice the number of variables in the model. The level and slope values are staggered, i.e., the level and slope of variable j are in init[2j-1] and init[2j].

    Options

    Standard options (default values are taken from model.options)

    • verbose
    StateSpaceEcon.SteadyStateSolver.sssolve!Method
    sssolve!(model; <options>)

    Solve the steady state problem for the given model.

    Options

    Standard options (default values are taken from model.options)

    • verbose
    • tol, maxiter - control the stopping criteria of the solver

    Specific options

    • presolve::Bool - whether or not to use a presolve pass. Default is true.
    • method::Symbol - choose the solution algorithm. Valid options are :nr for Newton-Raphson, :lm for Levenberg-Marquardt, and :auto. The :auto method starts with the LM algorithm and automatically switches to NR when it starts to converge. Default is :nr.

    Stacked-Time Solver

    StateSpaceEcon.StackedTimeSolverModule
    StackedTimeSolver

    A module that is part of StateSpaceEcon package. Contains methods for solving the dynamic system of equations for the model and running simulations.

    StateSpaceEcon.StackedTimeSolver.dictoverlayFunction
    dictoverlay(d1, d2)

    Merge two dictionaries. Common key where the values are TSeries of the same frequency are overlayed. Otherwise, a common key takes the value of the last Dict containing it.

    Deprecation Note

    This function will be removed. Use TimeSeriesEcon.overlay instead. An important difference is that TimeSeriesEcon.overlay keeps the values from the first argument where the key appears, while dictoverlay keeps it from the last.

    StateSpaceEcon.StackedTimeSolver.seriesoverlayFunction
    seriesoverlay(ts1, ts2)

    Return a new TSeries over the full range of both arguments. The overlapping part contains values from the last argument.

    Deprecation Note

    This function will be removed in the future. Use TimeSeriesEcon.overlay instead. Note the important difference that in TimeSeriesEcon.overlay the values in the overlay come from the first series where the value exists, as opposed to seriesoverlay where it was from the last one.

    See also: dictoverlay

    StateSpaceEcon.StackedTimeSolver.setfcFunction
    setfc(model, fc)

    Return a vector of final conditions for all variables in the model. The final conditions of all variables are set to fc, except shocks and exogenous, which are always fcnone. Use setfc! to update the final condition of individual variable.

    Plans

    StateSpaceEcon.PlansModule
    Plans

    Module part of StateSpaceEcon. This module implements the Plan data structure, which is used in simulations. The plan object contains information about the range of the simulation and which variables and shocks are exogenous or endogenous at each period of the range.

    Constructors

    Modify the plan

    StateSpaceEcon.Plans.PlanType
    Plan{T <: MIT}

    A data structure representing the simulation plan. It holds information about the time range of the simulation and which variables/shocks are exogenous at each period.

    StateSpaceEcon.Plans.PlanMethod
    Plan(model, range)

    Create a default simulation plan for the given model over the given range. The range of the plan is augmented to include periods before and after the given range, over which initial and final conditions will be applied.

    Instead of a range, one could also pass in a single moment in time (MIT) instance, in which case it is interpreted as a range of length 1.

    StateSpaceEcon.Plans.autoexogenize!Method

    autoexogenize!(plan, model, date)

    Modify the given plan according to the "autoexogenize" protocol defined in the given model. All variables in the autoexogenization list become endogenous and their corresponding shocks become exogenous over the given date or range. date can be a moment in time (same frequency as the given plan), a range, an iterable, or a container.

    StateSpaceEcon.Plans.compare_plansFunction
    compare_plans(left, right; options)
    compare_plans(file, left, right; options)

    Display a comparison of two plans, or save it in a text file.

    Options

    • alphabetical=false - set to true to sort the variables. By default variables will be listed in the same order as in the left plan.
    • exog_mark="X" - a short string (ideally 1 character) to mark exogenous values.
    • endo_mark="~" - a short string (ideally 1 character) to mark endogenous values.
    • missing_mark="." - a short string (ideally 1 character) to display when a variable is missing from one of the plans.
    • delim=" " - delimiter. Use ","` to make it a CSV file.
    • pagelines=0 - Set to a positive integer to enable pagination. Number is interpreted as the number of lines to repeat the header line (the one with the ranges).
    StateSpaceEcon.Plans.endo_exog!Method
    endo_exog!(plan, endo_vars, exog_vars, date)

    Modify the given plan so that the given variables listed in exog_vars will be exogenous and the variables listed in endo_vars will be endogenous on the given dates. exog_vars and endo_vars can each be a Symbol or a String or a Vector of such. date can be a moment in time (same type as the plan), or a range or an iterable or a container.

    StateSpaceEcon.Plans.endogenize!Method
    endogenize!(plan, vars, date)

    Modify the given plan so that the given variables will be endogenous on the given dates. vars can be a Symbol or a String or a Vector of such. date can be a moment in time (same type as the plan), or a range or an iterable or a container.

    StateSpaceEcon.Plans.exog_endo!Method
    exog_endo!(plan, exog_vars, endo_vars, date)

    Modify the given plan so that the given variables listed in exog_vars will be exogenous and the variables listed in endo_vars will be endogenous on the given dates. exog_vars and endo_vars can each be a Symbol or a String or a Vector of such. date can be a moment in time (same type as the plan), or a range or an iterable or a container.

    StateSpaceEcon.Plans.exogenize!Method
    exogenize!(plan, vars, date)

    Modify the given plan so that the given variables will be exogenous on the given dates. vars can be a Symbol or a String or a Vector of such. date can be a moment in time (same type as the plan), or a range or an iterable or a container.

    StateSpaceEcon.Plans.exportplanFunction
    exportplan(plan; options)
    exportplan(file, plan; options)

    Display the plan or save it in a text file.

    Options

    • alphabetical=false - set to true to sort the variables. By default variables will be listed in the same order as in the model.
    • exog_mark="X" - a short string (ideally 1 character) to mark exogenous values.
    • endo_mark="-" - a short string (ideally 1 character) to mark endogenous values.
    • delim=" " - delimiter. Use ","` to make it a CSV file.

    See also importplan

    StateSpaceEcon.Plans.plansumMethod
    plansum(model, plan)

    Return the total number of exogenous variables in the simulation plan. Periods over which initial and final conditions are imposed are not counted in this sum.

    StateSpaceEcon.Plans.setexog!Method
    setexog!(plan, t, vinds)

    Modify the plan at time t such that vinds are exogenous and the rest are endogenous.

    Various

    StateSpaceEcon.SimDataType
    SimData

    Data structure containing the time series data for a simulation.

    It is a collection of TSeries of the same frequency and containing data for the same range. When used for simulation, the range must include the initial conditions, the simulation range and the final conditions, although it could extend beyond that. It must contain time series for all variables and shocks in the model, in the same order as in the model object.

    StateSpaceEcon.array2dataFunction
    array2data(matrix, model, plan; copy=false)
    array2data(matrix, vars, range; copy=false)

    Convert a plain matrix with simulation data to a SimData.

    StateSpaceEcon.array2dictFunction
    dict2array, array2dict
    dict2data, data2dict

    Deprecated. Use the workspace instead of dict.

    StateSpaceEcon.array2workspaceFunction
    array2workspace(matrix, model, plan; copy=false)
    array2workspace(matrix, vars, range; copy=false)

    Convert a plain matrix with simulation data to a Workspace.

    StateSpaceEcon.data2arrayFunction
    data2array(data; copy=false)
    data2array(data, model, plan; copy=false)
    data2array(data, vars, range; copy=false)

    Convert a SimData to a matrix.

    StateSpaceEcon.data2dictFunction
    dict2array, array2dict
    dict2data, data2dict

    Deprecated. Use the workspace instead of dict.

    StateSpaceEcon.dict2arrayFunction
    dict2array, array2dict
    dict2data, data2dict

    Deprecated. Use the workspace instead of dict.

    StateSpaceEcon.dict2dataFunction
    dict2array, array2dict
    dict2data, data2dict

    Deprecated. Use the workspace instead of dict.

    StateSpaceEcon.printmatrixMethod
    printmatrix(mat [, Val(F), colnames])

    Display a matrix in full while controlling the formatting of each value and optionally showing the column names.

    • Val(F) - display each number in the given format F. The format is in the form of a decimal point number where the whole part indicates the total width and the fractional part indicates the number of digits printed after the decimal point. Default is Val(12.7)
    • colnames - a list of names to display in the first row. The names are displayed as given, possibly with padding to match the width given in the Val argument. If any names are longer than that, they will not be truncated and so the display will not be aligned properly. Sorry about that!
    StateSpaceEcon.shockdecompFunction
    shockdecomp(model, plan, exog_data; control, solver, [options])

    Compute the shock decomposition for the given model, plan, exogenous (shocks) data and control solution.

    If the control option is not specified we use the steady state solution stored in the model instance. The algorithm assumes that control is a solution to the dynamic model for the given plan range and final condition. We verify the residual and issue a warning, but do not enforce this. See steadystatedata.

    As part of the algorithm we run a simulation with the given plan, data and solver. See simulate for additional options that control the simulation.

    Note that unlike simulate, here we require exogdata and control to be MVTSeries, i.e. plain Array or Workspace are not allowed.

    The returned value is a Workspace with three things in it: c contains a copy of control, s contains the simulated solution for the given plan and exogdata and sd contains the shock decomposition data. The data in sd is organized as a Workspace containing an MVTSeries for each variable,

    StateSpaceEcon.simulateFunction
    simulate(model, plan, data; <options>)

    Run a simulation for the given model, simulation plan and exogenous data.

    Arguments

    * `model` - the [`Model`](@ref ModelBaseEcon.Model) instance to simulate.
    * `plan` - the [`Plan`](@ref) for the simulation.
    * `data` - a 2D `Array` containing the exogenous data. This includes the
        initial and final conditions.

    Options as keyword arguments

    * `fctype::`[`FinalCondition`](@ref) - set the desired final condition type
        for the simulation. The default value is [`fcgiven`](@ref). Other possible
        values include [`fclevel`](@ref), [`fcslope`](@ref) and
        [`fcnatural`](@ref).
    * `initial_guess::AbstractMatrix{Float64}` - a 2D `Array` containing the
        initial guess for the solution. This is used to start the Newton-Raphson
        algorithm. The default value is an empty array (`zeros(0,0)`), in which case
        we use the exogenous data for the initial condition. You can use the steady
        state solution using [`steadystatearray`](@ref).
    * `deviation::Bool` - set to `true` if the `data` is given in deviations from
        the steady state. In this case the simulation result is also returned as a
        deviation from the steady state. Default value is `false`.
    * `anticipate::Bool` - set to `false` to instruct the solver that all shocks
        are unanticipated by the agents. Default value is `true`.
    * `verbose::Bool` - control whether or not to print progress information.
        Default value is taken from `model.options`.
    * `tol::Float64` - set the desired accuracy. Default value is taken from
        `model.options`.
    * `maxiter::Int` - algorithm fails if the desired accuracy is not reached
        within this maximum number of iterations. Default value is taken from
        `model.options`.
    * `linesearch::Bool` - When `true` the Newton-Raphson is modified to include a
        search along the descent direction for a sufficient decrease in f. It will
        do this at each iteration. Default is `false`.
    StateSpaceEcon.solve!Function
    solve!(m::Model; [solver::Symbol])

    Solve the given model and update its m.solverdata according to the specified solver. The solver is specified as a Symbol. The default is solve=:stackedtime.

    StateSpaceEcon.steadystatearrayFunction
    steadystatearray(model, plan; [ref=firstdate(plan) + m.maxlag])

    Create a Matrix{Float64} of the proper dimension for a simulation with the given model with the given plan. It is initialized to the steady state.

    In the case of steady state solution that is not stationary (i.e., non-zero slope) use the ref option to specify the period in which the steady state level is given. The default for ref is the first simulation period.

    This function returns a Matrix. We recommend using zerodata, which returns SimData. See also zeroworkspace

    Deprecation Note

    zeroarray(model, range) will be removed in future versions. Always create a simulation Plan explicitly.

    StateSpaceEcon.steadystatedataFunction
    steadystatedata(model, plan; [ref=firstdate(plan) + m.maxlag))

    Create a SimData for a simulation with the given model and plan. Columns correspond to the model variables and shocks in the correct order. Data is initialized with the steady state.

    In the case of steady state solution that is not stationary (i.e., non-zero slope) use the ref option to specify the period in which the steady state level is given. The default for ref is the first simulation period.

    See also zeroarray and zeroworkspace

    StateSpaceEcon.steadystateworkspaceMethod
    steadystateworkspace(model, plan; [ref=firstdate(plan) + m.maxlag))

    Create a Workspace containing a TSeries for each variable/shock in the given model. They are initialized to the steady state solution.

    In the case of steady state solution that is not stationary (i.e., non-zero slope) use the ref option to specify the period in which the steady state level is given. The default for ref is the first simulation period.

    We recommend using steadystatedata. See also steadystatearray.

    StateSpaceEcon.stoch_simulateFunction
    stoch_simulate(model, plan, baseline, shocks; control, ...)

    Run multiple simulations with the given shocks centered about the given control (steady state by default).

    The baseline should span the plan range and must be given in levels ( i.e., option deviation=true is not implemented)

    The shocks can be given as a collection of random realizations, where each realization could be an MVTSeries or a Workspace. Only the shocks should be provided.

    All shock names must be exogenous in the given plan over the range of the given data. The data in control is taken as anticipated and the stochastic realizations are taken as unanticipated and the same plan is used for both components.

    Currently only the case of solver=stackedtime is implemented.

    StateSpaceEcon.zeroarrayFunction
    zeroarray(model, plan)

    Create a Matrix{Float64} of the proper dimension for a simulation with the given model with the given plan. It is initialized to 0.

    This function returns a Matrix. We recommend using zerodata, which returns SimData. See also zeroworkspace

    Deprecation Note

    zeroarray(model, range) will be removed in future versions. Always create a simulation Plan explicitly.

    StateSpaceEcon.zerodataFunction
    zerodata(model, plan)

    Create a SimData for a simulation with the given model and plan. Columns correspond to the model variables and shocks in the correct order. Data is initialized with 0.

    See also zeroarray and zeroworkspace

    Internals

    Steady state solver

    StateSpaceEcon.SteadyStateSolver.LMDataType

    LMData

    A data structure that holds the necessary buffers and internal data for performing a step of the Levenberg–Marquardt algorithm

    Warning

    Internal use. Do not call directly

    StateSpaceEcon.SteadyStateSolver.LMDataMethod
    LMData(model)
    LMData(model, sd::SolverData)

    Make an instance of the LMData for the given model. If solver data is not also given, then it is used, instead of creating a default SolverData for the model.

    StateSpaceEcon.SteadyStateSolver.NRDataType
    NRData

    A data structure that holds the necessary buffers and internal data for performing a step of the Newton-Raphson algorithm

    Internal use. Do not call directly.

    StateSpaceEcon.SteadyStateSolver.SolverDataType
    SolverData

    A data structure used during the solution of the steady state problem. It contains some current state information and some buffers.

    Warning

    This is an internal data structure. Do not use directly.

    Why is this necessary?

    The solution of the steady state problem is done in steps:

    1. The user sets the initial guess. This can be done with either initial_sstate! or clear_sstate!
    2. Pre-solve step. In this step we look for equations that have only one unknown and attempt to solve it. If successful, the unknown is marked as "solved" and is not an unknown anymore, also the equation is marked as "solved" and is not considered anymore. The process repeats for as long as it keeps solving.
    3. Solve step. This is where we solve the non-linear system composed of the remaining equations for the remaining variables.

    This data structure keeps track of which unknowns and equations are solved and which remain to be solved. It also holds an indexing map that translates the indexes of the variables and equations we solve for to their original indexes in the full steady state system.

    Fields

    • point - a buffer for the current solution values. Some of these may be presolved, which are kept fixed while solving the system, while the rest are updated during solver iterations. The length equals the total number of steady state variables.
    • resid - a buffer for the current residual vector. The entries corresponding to presolved equations would normally be all zeros, while the ones corresponding to "active" equations would be updated during solver iterations. Lentgh equals the total number of steady state equations.
    • solve_var - a Boolean vector, same size as point. Value of true means that the unknown is "active", while false indicates that it has been pre-solved.
    • solve_eqn - a Boolean vector, same size as resid. Value of true means that the equation is "active", while false indicates that it has been pre-solved.
    • vars_index - an Integer vector, same length as point. Entries corresponding to pre-solved variables hold zeros. Entries for active vars are numbered sequentially from 1 to nvars
    • eqns_index - an Integer vector, same length as resid. Presolved equations have a zero here, while active equations are numbered sequentially from 1 to neqns.
    StateSpaceEcon.SteadyStateSolver.SolverDataMethod
    SolverData(model, presolve=Val(false); <options>)

    Construct a SolverData instance from all variables and equations in the model, ignoring anything pre-solved.

    Options

    • verbose::Bool - if not specified it's taken from the model options.
    • tol::Float64 - desired tolerance when checking the residual of presolved equation.
    • presolve::Bool - if false, any pre-solved information is ignored and the solver data is set up to solve all equations for all variables.
    StateSpaceEcon.SteadyStateSolver.bisect!Method
    bisect!(F, x, i, dF; <options>)

    Solve the equation F(x) = 0 for x[i] keeping the other values of x fixed. The input value of x[i] is used as the initial guess and it is updated in place. Other entries of x are not accessed at all. Return true upon success, or false otherwise.

    Arguments

    • F - A function that must accept a single argument x, which is an array, and must return the value of F (numeric scalar).
    • x - An array.
    • i - The index identifying the dimension in which we're solving the problem.
    • dF - A numeric value. This must equal the partial derivative of F with respect to x[i] at the input value of x[i]. This value is used to construct the initial interval in which the bisection method will be applied.

    Options

    • maxiter = 500 - maximum number of iterations. The default is large (500) because this method sometimes converges slowly.
    • tol = 1e-8 - desired tolerance of the solution.
    Warning

    This is an internal function used by the steady state solver. In the future it might be removed or modified.

    StateSpaceEcon.SteadyStateSolver.first_step_lm!Method
    first_step_nr!(x, dx, resid, J, lm::LMData; verbose=false)

    Make the first step of a Levenberg–Marquardt algorithm. Involves determining the initial trust region. The lm structure and the dx vector would be updated. Vectors x, resid and the matrix J are read-only inputs.

    Warning

    Internal function, do not call directly.

    StateSpaceEcon.SteadyStateSolver.global_SS_R!Method
    global_SS_R!(R, point, equations)

    Compute the residual vector of the given set of equations at the given point. The equations argument can be a container whose eltype is SteadyStateEquations. The residual R is updated in place.

    StateSpaceEcon.SteadyStateSolver.global_SS_RJMethod
    R, J = global_SS_RJ(point, sd::SolverData)

    When applied to a solver data, computes the residual and Jacobian of the active set of equations with respect to the active set of variables.

    StateSpaceEcon.SteadyStateSolver.global_SS_RJMethod
    R, J = global_SS_RJ(point, equations)

    Compute the residual vector R and the Jacobian matrix of the given set of equations at the given point. The equations argument can be a container whose eltype is SteadyStateEquations.

    StateSpaceEcon.SteadyStateSolver.newton1!Method
    newton1!(F, x, i; <options>)

    Solve the equation F(x) = 0 for x[i] keeping the other values of x fixed. The input value of x[i] is used as the initial guess and it is updated in place. Other entries of x are not accessed at all. Return true upon success, or false otherwise.

    Function F

    The function F must accept a single argument x, which is an array, and must return a tuple of two things: the value of F (numeric scalar) and the gradient of F (an array of the same shape as x). Only the i-th index of the gradient array is used.

    Options

    • maxiter = 5 - maximum number of iterations. The default is small (5) because the Newton method either converges very fast or doesn't converge at all.
    • tol = 1e-8 - desired tolerance of the solution.

    Notes

    The tol value is used for a stopping criterion and also for diagnosing problems.

    Warning

    This is an internal function used by the steady state solver. In the future it might be removed or modified.

    StateSpaceEcon.SteadyStateSolver.presolve_sstate!Function
    presolve_sstate!(model; <options>)
    presolve_sstate!(model, mask, values; <options>)

    Solve for the steady state variables that are decoupled from the system, or can be solved by forward substitution.

    This is called automatically by the steady state solver before running its main loop.

    Arguments

    • model - the Model instance
    • mask - a vector of Bool. Defaults to model.sstate.mask
    • values - a vector of numbers. Defaults to model.sstate.values Caller must specify either both mask and values or neither of them. mask[i] equals true if and only if the i-th steady state value has alredy been solved for.

    mask and values are both input and output data to the algorithm. Any values that are successfully pre-solved are updated in place, and their mask entries are set to true.

    Options

    • verbose - true or false, whether or not to print diagnostic messages.
    • tol - accuracy of the 1d solver.
    StateSpaceEcon.SteadyStateSolver.step_lm!Method
    step_nr!(x, dx, resid, J, lm::LMData; verbose=false)

    Attempt a Levenberg–Marquardt step. The lm structure and the dx vector would be updated. Vectors x, resid and the matrix J are read-only inputs.

    Warning

    Internal function, do not call directly.

    StateSpaceEcon.SteadyStateSolver.step_nr!Method
    step_nr!(x, dx, resid, J, nr::NRData; verbose=false)

    Attempt a Newton-Raphson step. The nr structure and the dx vector would be updated accordingly. Vectors x, resid and the matrix J are read-only inputs.

    Warning

    Internal function, do not call directly.

    Stacked-Time Solver

    StateSpaceEcon.StackedTimeSolver.assign_fc!Function
    assign_fc!(x::Vector, exog::Vector, vind::Int, sd::StackedTimeSolverData, fc::FinalCondition)

    Applying the final condition fc for variable with index vind. Exogenous data is provided in exog and stacked time solver data in sd. This function updates the solution vector x in place and returns x.

    Warning

    Internal function not part of the public interface.

    StateSpaceEcon.StackedTimeSolver.assign_final_condition!Method
    assign_final_condition!(x::Matrix, exog::Matrix, sd::StackedTimeSolver)

    Assign the final conditions into x. The final condition types for the different variables of the model are stored in the the solver data sd. exog is used for fcgiven.

    Warning

    Internal function not part of the public interface.

    StateSpaceEcon.StackedTimeSolver.make_BIMethod
    make_BI(J, II)

    Prepares the BI array for the solver data. Called from the constructor of StackedTimeSolverData.

    Warning

    Internal function not part of the public interface.

    StateSpaceEcon.StackedTimeSolver.shockdecompMethod
    shockdecomp(model, plan, exog_data; control, fctype, [options])

    Compute the shock decomposition for the given model, plan, exogenous (shocks) data and control solution.

    If control option is not specified we use the steady state solution stored in the model instance. The algorithm assumes that control is a solution to the dynamic model for the given plan range and final condition. We verify the residual and issue a warning, but do not enforce this. See steadystatedata.

    As part of the algorithm we run a simulation with the given plan, exog_data and fctype. See simulate for other options.

    Note

    For now only the case of anticipate=true works. Shock decomp with unanticipated shocks is coming soon.

    StateSpaceEcon.StackedTimeSolver.sim_nr!Function
    sim_nr!(x, sd, maxiter, tol, verbose [, linesearch])

    Solve the simulation problem.

    • x - the array of data for the simulation. All initial, final and exogenous conditions are already in place.
    • sd::AbstractSolverData - the solver data constructed for the simulation problem.
    • maxiter - maximum number of iterations.
    • tol - desired accuracy.
    • verbose - whether or not to print progress information.
    • linesearch::Bool - When true the Newton-Raphson is modified to include a search along the descent direction for a sufficient decrease in f. It will do this at each iteration. Default is false.
    StateSpaceEcon.StackedTimeSolver.stackedtime_R!Method
    stackedtime_R!(R::Vector, point::Array, exog::Array, sd::StackedTimeSolverData)

    Compute the residual of the stacked time system at the given point. R is updated in place and returned.

    StateSpaceEcon.StackedTimeSolver.update_plan!Method
    update_plan!(sd::StackedTimeSolverData, model, plan; changed=false)

    Update the stacked time solver data to reflect the new plan. The new plan must have the same range as the original plan, otherwise the solver data cannot be updated in place.

    By default the data structure is updated only if an actual change in the plan is detected. Setting the changed flag to true forces the update even if the plan seems unchanged. This is necessary only in rare circumstances.

    Warning

    Internal function not part of the public interface.

    StateSpaceEcon.StackedTimeSolver.var_CiScFunction
    var_CiSc(sd::StackedTimeSolverData, var::ModelVariable, fc::FinalCondition)

    Return data related to the correction of the Jacobian matrix needed for the given final condition for the given variable.

    Warning

    Internal function not part of the public interface.

    Plans

    StateSpaceEcon.Plans.setplanvalue!Method
    setplanvalue!(plan, value, vars, range)
    setplanvalue!(plan, value, vars, date)
    setplanvalue!(plan, value, vars, dates)

    Modify the status of the given variable(s) on the given date(s). If value is true then variables become exogenous, otherwise they become endogenous.

    Various