robustlq

Filename: robustlq.py

Authors: Chase Coleman, Spencer Lyon, Thomas Sargent, John Stachurski

Solves robust LQ control problems.

class quantecon.robustlq.RBLQ(Q, R, A, B, C, beta, theta)[source]

Bases: object

Provides methods for analysing infinite horizon robust LQ control problems of the form

\[\min_{u_t} \sum_t \beta^t {x_t' R x_t + u_t' Q u_t }\]

subject to

\[x_{t+1} = A x_t + B u_t + C w_{t+1}\]

and with model misspecification parameter theta.

Parameters:

Q : array_like(float, ndim=2)

The cost(payoff) matrix for the controls. See above for more. Q should be k x k and symmetric and positive definite

R : array_like(float, ndim=2)

The cost(payoff) matrix for the state. See above for more. R should be n x n and symmetric and non-negative definite

A : array_like(float, ndim=2)

The matrix that corresponds with the state in the state space system. A should be n x n

B : array_like(float, ndim=2)

The matrix that corresponds with the control in the state space system. B should be n x k

C : array_like(float, ndim=2)

The matrix that corresponds with the random process in the state space system. C should be n x j

beta : scalar(float)

The discount factor in the robust control problem

theta : scalar(float)

The robustness factor in the robust control problem

Attributes

Q, R, A, B, C, beta, theta (see Parameters)
k, n, j (scalar(int)) The dimensions of the matrices

Methods

F_to_K(F) Compute agent 2’s best cost-minimizing response K, given F.
K_to_F(K) Compute agent 1’s best value-maximizing response F, given K.
b_operator(P) The B operator, mapping P into
compute_deterministic_entropy(F, K, x0) Given K and F, compute the value of deterministic entropy, which
d_operator(P) The D operator, mapping P into
evaluate_F(F) Given a fixed policy F, with the interpretation \(u = -F x\), this
robust_rule() This method solves the robust control problem by tricking it
robust_rule_simple([P_init, max_iter, tol]) A simple algorithm for computing the robust policy F and the corresponding value function P, based around straightforward iteration with the robust Bellman operator.
F_to_K(F)[source]

Compute agent 2’s best cost-minimizing response K, given F.

Parameters:

F : array_like(float, ndim=2)

A k x n array

Returns:

K : array_like(float, ndim=2)

Agent’s best cost minimizing response for a given F

P : array_like(float, ndim=2)

The value function for a given F

K_to_F(K)[source]

Compute agent 1’s best value-maximizing response F, given K.

Parameters:

K : array_like(float, ndim=2)

A j x n array

Returns:

F : array_like(float, ndim=2)

The policy function for a given K

P : array_like(float, ndim=2)

The value function for a given K

b_operator(P)[source]

The B operator, mapping P into

\[B(P) := R - \beta^2 A'PB(Q + \beta B'PB)^{-1}B'PA + \beta A'PA\]

and also returning

\[F := (Q + \beta B'PB)^{-1} \beta B'PA\]
Parameters:

P : array_like(float, ndim=2)

A matrix that should be n x n

Returns:

F : array_like(float, ndim=2)

The F matrix as defined above

new_p : array_like(float, ndim=2)

The matrix P after applying the B operator

compute_deterministic_entropy(F, K, x0)[source]

Given K and F, compute the value of deterministic entropy, which is

\[\sum_t \beta^t x_t' K'K x_t`\]

with

\[x_{t+1} = (A - BF + CK) x_t\]
Parameters:

F : array_like(float, ndim=2)

The policy function, a k x n array

K : array_like(float, ndim=2)

The worst case matrix, a j x n array

x0 : array_like(float, ndim=1)

The initial condition for state

Returns:

e : scalar(int)

The deterministic entropy

d_operator(P)[source]

The D operator, mapping P into

\[D(P) := P + PC(\theta I - C'PC)^{-1} C'P.\]
Parameters:

P : array_like(float, ndim=2)

A matrix that should be n x n

Returns:

dP : array_like(float, ndim=2)

The matrix P after applying the D operator

evaluate_F(F)[source]

Given a fixed policy F, with the interpretation \(u = -F x\), this function computes the matrix \(P_F\) and constant \(d_F\) associated with discounted cost \(J_F(x) = x' P_F x + d_F\)

Parameters:

F : array_like(float, ndim=2)

The policy function, a k x n array

Returns:

P_F : array_like(float, ndim=2)

Matrix for discounted cost

d_F : scalar(float)

Constant for discounted cost

K_F : array_like(float, ndim=2)

Worst case policy

O_F : array_like(float, ndim=2)

Matrix for discounted entropy

o_F : scalar(float)

Constant for discounted entropy

robust_rule()[source]

This method solves the robust control problem by tricking it into a stacked LQ problem, as described in chapter 2 of Hansen- Sargent’s text “Robustness.” The optimal control with observed state is

\[u_t = - F x_t\]

And the value function is \(-x'Px\)

Returns:

F : array_like(float, ndim=2)

The optimal control matrix from above

P : array_like(float, ndim=2)

The positive semi-definite matrix defining the value function

K : array_like(float, ndim=2)

the worst-case shock matrix K, where \(w_{t+1} = K x_t\) is the worst case shock

robust_rule_simple(P_init=None, max_iter=80, tol=1e-08)[source]

A simple algorithm for computing the robust policy F and the corresponding value function P, based around straightforward iteration with the robust Bellman operator. This function is easier to understand but one or two orders of magnitude slower than self.robust_rule(). For more information see the docstring of that method.

Parameters:

P_init : array_like(float, ndim=2), optional(default=None)

The initial guess for the value function matrix. It will be a matrix of zeros if no guess is given

max_iter : scalar(int), optional(default=80)

The maximum number of iterations that are allowed

tol : scalar(float), optional(default=1e-8)

The tolerance for convergence

Returns:

F : array_like(float, ndim=2)

The optimal control matrix from above

P : array_like(float, ndim=2)

The positive semi-definite matrix defining the value function

K : array_like(float, ndim=2)

the worst-case shock matrix K, where \(w_{t+1} = K x_t\) is the worst case shock