Conversation
|
|
||
| import numpy as np | ||
| from sympy import Matrix | ||
| from pylab import array |
There was a problem hiding this comment.
is this simply importing a numpy array?
|
| def compute_steadystate(self, nnc=2): #nnc is the position of the constant in the state vector | ||
| """ Find non-stochastic steady-state of the economy """ | ||
| zx = Matrix(np.eye(self.A0.shape[0])-self.A0) | ||
| self.zz = zx.nullspace() |
There was a problem hiding this comment.
Can this be replaced with quantecon.nullspace? Then the import of Matrix from sympy would be removed.
There was a problem hiding this comment.
@oyamad I am in favour of this. Can you let me know what I need to change?
There was a problem hiding this comment.
self.zz = qe.nullspace(A0)?
There was a problem hiding this comment.
@mmcky What I had in mind is
zx = np.eye(self.A0.shape[0]) - self.A0
self.zz = qe.nullspace(zx)Maybe the following is better?
zx = -self.A0
zx[np.diag_indices_from(zx)] += 1
self.zz = qe.nullspace(zx)
self.zz /= self.zz[nnc]But please check whether this gives the same shape of self.zz as the original code.
There was a problem hiding this comment.
thanks @oyamad. I will make the update and then confirm.
| lq = LQ(self.Q, self.R, self.A, self.B, | ||
| self.C, N=self.W, beta=self.beta) | ||
|
|
||
| self.P, self.F, self.d = lq.stationary_values() |
There was a problem hiding this comment.
@thomassargent30 this will default to using doubling as the method for computing. Should we allow the pass through of the method of computation to be doubling and qz?
… solutions verified by matlab programs
…the same ... need to investigate
|
@oyamad the |
|
@mmcky Do you have an example that yields such a difference? |
|
Given the input matrix source = np.array([[ 0.1 , 0. , -0.5 , -0.1 , 0. ],
[ 0. , 0.05, 0. , 0. , 0. ],
[ 0. , 0. , 0. , 0. , 0. ],
[ 0. , 0. , 0. , 0.2 , 0. ],
[ 0. , 0. , 0. , 0. , 0.5 ]])using null space method from the Matrix object in Simps from sympy import Matrix
Matrix(source).nullspace()yields [Matrix([
[5.0],
[ 0],
[ 1],
[ 0],
[ 0]])]while null space method in quantecon from quantecon import nullspace
nullspace(source)yields array([[ 9.80580676e-01],
[-2.77555756e-17],
[ 1.96116135e-01],
[ 1.38777878e-17],
[ 0.00000000e+00]]) |
|
What is the problem exactly? zz = qe.nullspace(source)
nnc = 2
zz /= zz[nnc]
zzarray([[ 5.00000000e+00],
[-1.41526222e-16],
[ 1.00000000e+00],
[ 7.07631108e-17],
[ 0.00000000e+00]]) |
|
ah thanks @oyamad I didn't divide by the constant. I will update the |
|
@oyamad are you seeing |
|
thanks @oyamad for picking up my error. This has now been migrated to using the quantecon method and testing has been updating on a known problem. |
This PR adds
DLEobject for solving dynamic linear economic problems by converting to LQ problem. This code has been contributed by Sebastian Graves.Adjustments required for inclusion in
QuantEcon.py:update docstring to conform to style guide. Need to document
Parametersin similar fashion to https://github.com/QuantEcon/QuantEcon.py/blob/master/quantecon/robustlq.pyreview inclusion of
pylab. I would prefer to use the core librariesnumpy,matplotlibandscipyadd tests