Which matrix is near singular?
Moderators: EViews Gareth, EViews Moderator
-
freedomplaza
- Posts: 13
- Joined: Tue May 31, 2016 7:48 am
Which matrix is near singular?
I have a basic question. I am trying to estimate a system of nonlinear equations. The equations are actually Euler equations of the type E[M*R]-1=0, where M is the stochastic discount factor, which is itself a nonlinear function of the parameters that I would like to estimate.
Suppose that I am using a vector of "ones" as my instrument. Equivalently, I am trying to estimate the unconditional Euler equation restrictions. Then shouldn't the OLS, 2SLS, and GMM with identity weighting matrix deliver the exact same point estimates?
I am asking this question, because I can obtain estimates in Eviews for the OLS case, but I receive a "Near Singular Matrix" error when I try to implement a 2SLS or GMM. Exactly which matrix is singular? Ultimately, I would like to estimate the system using the optimal GMM weighting matrix, but the fact that I cannot get past a 2SLS/GMM with identity matrix makes me think that there is a much more basic issue that needs to be addressed.
Thanks in advance for your help.
Suppose that I am using a vector of "ones" as my instrument. Equivalently, I am trying to estimate the unconditional Euler equation restrictions. Then shouldn't the OLS, 2SLS, and GMM with identity weighting matrix deliver the exact same point estimates?
I am asking this question, because I can obtain estimates in Eviews for the OLS case, but I receive a "Near Singular Matrix" error when I try to implement a 2SLS or GMM. Exactly which matrix is singular? Ultimately, I would like to estimate the system using the optimal GMM weighting matrix, but the fact that I cannot get past a 2SLS/GMM with identity matrix makes me think that there is a much more basic issue that needs to be addressed.
Thanks in advance for your help.
-
startz
- Non-normality and collinearity are NOT problems!
- Posts: 3797
- Joined: Wed Sep 17, 2008 2:25 pm
Re: Which matrix is near singular?
Don't you need at least as many instruments as parameters?
-
freedomplaza
- Posts: 13
- Joined: Tue May 31, 2016 7:48 am
Re: Which matrix is near singular?
I think you need at least as many moments conditions as parameters. With 2 Euler equations, I can estimate up to 2 parameters.
-
startz
- Non-normality and collinearity are NOT problems!
- Posts: 3797
- Joined: Wed Sep 17, 2008 2:25 pm
Re: Which matrix is near singular?
True. That's effectively what OLS does. But with the instrumental methods I think the moment conditions are perfectly collinear if you don't have enough instruments. As a check, you might try a linear case.I think you need at least as many moments conditions as parameters. With 2 Euler equations, I can estimate up to 2 parameters.
-
freedomplaza
- Posts: 13
- Joined: Tue May 31, 2016 7:48 am
Re: Which matrix is near singular?
Do you know what are the objective functions in the 2 stages of the 2SLS? I could not find any documentation about this in a GMM context other than for the case in which the set of moments restrictions is linear. Is there a way of forcing Eviews to look for the minimum of the GMM objective function (when using the identity matrix as the weighting matrix) numerically as opposed to using the 2SLS estimate (whose reliability I am unsure about)?
-
startz
- Non-normality and collinearity are NOT problems!
- Posts: 3797
- Joined: Wed Sep 17, 2008 2:25 pm
Re: Which matrix is near singular?
2sls minimizes the moments Z'e, where e is the residuals and Z are the instruments. I don't think they actually do it in two stages. Not sure about the rest.
-
freedomplaza
- Posts: 13
- Joined: Tue May 31, 2016 7:48 am
Re: Which matrix is near singular?
That's exactly my point: if Z is a vector of ones, then this should yield exactly the same results as simple OLS. I am afraid that there is a bug in the software.
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Which matrix is near singular?
You're going to have to give a much more concrete example of what you're doing, including the workfile etc...
-
freedomplaza
- Posts: 13
- Joined: Tue May 31, 2016 7:48 am
Re: Which matrix is near singular?
I am attaching my workfile. The system that I am trying to estimate via GMM (let's say with identity weighting matrix to simplify things) is in "model1". The system contains two moment conditions (both ending with an "=0" and separated by a blank line) and two coefficients, c(1) and c(2), that I would like to estimate. I want to estimate the unconditional moment restrictions, which is why my instrument only consists of a constant. OLS works fine, but 2SLS or, equivalently, GMM with identity weighting matrix yield a "near singular matrix" error.
If you replace all the occurrences of c(1) in the system with actual numbers and estimate only c(2) using 2SLS (or GMM with I weighting matrix), everything goes through normally. From this exercise, you can actually obtain that the global minimum of the GMM objective function with identity weighting matrix occurs for c(1)=1.35 and c(2)=9.975, in which case the objective function is equal to 2874.608.
However, if I try to estimate c(1) and c(2) jointly via GMM, I get the "near singular matrix" error message and, when I check the vector of estimated coefficients in "c" (which presumably hasn't converged), I see extremely large values (i.e. nowhere close to the 1.35 and 9.975 reported above).
I can provide more details on the "economics" behind the equations in the system, if needed.
What do you think?
If you replace all the occurrences of c(1) in the system with actual numbers and estimate only c(2) using 2SLS (or GMM with I weighting matrix), everything goes through normally. From this exercise, you can actually obtain that the global minimum of the GMM objective function with identity weighting matrix occurs for c(1)=1.35 and c(2)=9.975, in which case the objective function is equal to 2874.608.
However, if I try to estimate c(1) and c(2) jointly via GMM, I get the "near singular matrix" error message and, when I check the vector of estimated coefficients in "c" (which presumably hasn't converged), I see extremely large values (i.e. nowhere close to the 1.35 and 9.975 reported above).
I can provide more details on the "economics" behind the equations in the system, if needed.
What do you think?
- Attachments
-
- eviews_debug.wf1
- (20.63 KiB) Downloaded 322 times
-
startz
- Non-normality and collinearity are NOT problems!
- Posts: 3797
- Joined: Wed Sep 17, 2008 2:25 pm
Re: Which matrix is near singular?
FIML also works. That suggests, but doesn't prove, that there is something funky with the 2sls estimation. I suspect it comes from one of the coefficients being driven to infinity.
-
freedomplaza
- Posts: 13
- Joined: Tue May 31, 2016 7:48 am
Re: Which matrix is near singular?
I have tried doing this in Matlab and everything works perfectly. I think it is a bug with Eviews. It gets stuck in an incorrect initial estimation of the coefficients using 2SLS (however defined), which drives the coefficients to infinity, blowing up the variance-covariance matrix. It is very disappointing that Eviews cannot handle a relatively straightforward GMM estimation.
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: Which matrix is near singular?
I'm curious as to what you estimated in Matlab as (unless I am misunderstanding something or having a brain freeze -- which is certainly possible), I don't see the two as equivalent. I don't think there's a bug in EViews, but I think it's an issue of interpretation of the problem.
Note that OLS is minimizing f(b) = e(b)'e(b), while TSLS is minimizing f(b, Z) = e(b)' Pz e(b) where Pz is the projection matrix formed using the instruments.
These are two different objective functions with different first-order conditions (unless Pz de(b)/db = de(b)/db) so it's not surprising to me that the results differ. One way to think about this statement is by simple analogy---the prescription in linear models is that for equivalence to hold, the instrument list must contain all of the right-hand side regressors in the model so that the projection recovers the regressors; in your nonlinear case, the instruments must be such that the gradients of the objective are recovered through projection.
In terms of Gaussian updates, we have something like:
b1 = b0 + (de/db' A de/db)^{-1} de/db' A e(b)
where A is the identity for least squares and A = Pz for TSLS.
Using your C as the instrument, EViews forms the instruments Z = I(2) (x) C so that Pz = I(2) (x) C(C'C)^{-1]C', where I(2) is the 2x2 identity, and (x) is the Kronecker operator (the Kronecker is why the rank condition is satisfied even though you entered a single instrument). Note that in this case, the TSLS projected gradient is the mean of the gradients by equation which is obviously not equivalent to the non-summed OLS gradient.
---
Now I'll have to think about your ultimate goal of obtaining estimates using GMM weights given that they are not available in our OLS estimator. If this were a linear system it wouldn't be too bad (as we could simply add all of the required linear instruments), but with the first nonlinear equation in your system it's a bit tricky to get the OLS equivalent (you can get the GMM one by adding lots of instruments, but it won't be exactly equivalent).
One final comment. You employ the absolute value function to enforce positivity of some terms. I generally avoid this function as it is not differentiable at the origin and the coefficients are only identified up to a sign transformation. For positivity, the exp function should work fine (though you'll still have problems as you approach the origin of the transformed value).
Note that OLS is minimizing f(b) = e(b)'e(b), while TSLS is minimizing f(b, Z) = e(b)' Pz e(b) where Pz is the projection matrix formed using the instruments.
These are two different objective functions with different first-order conditions (unless Pz de(b)/db = de(b)/db) so it's not surprising to me that the results differ. One way to think about this statement is by simple analogy---the prescription in linear models is that for equivalence to hold, the instrument list must contain all of the right-hand side regressors in the model so that the projection recovers the regressors; in your nonlinear case, the instruments must be such that the gradients of the objective are recovered through projection.
In terms of Gaussian updates, we have something like:
b1 = b0 + (de/db' A de/db)^{-1} de/db' A e(b)
where A is the identity for least squares and A = Pz for TSLS.
Using your C as the instrument, EViews forms the instruments Z = I(2) (x) C so that Pz = I(2) (x) C(C'C)^{-1]C', where I(2) is the 2x2 identity, and (x) is the Kronecker operator (the Kronecker is why the rank condition is satisfied even though you entered a single instrument). Note that in this case, the TSLS projected gradient is the mean of the gradients by equation which is obviously not equivalent to the non-summed OLS gradient.
---
Now I'll have to think about your ultimate goal of obtaining estimates using GMM weights given that they are not available in our OLS estimator. If this were a linear system it wouldn't be too bad (as we could simply add all of the required linear instruments), but with the first nonlinear equation in your system it's a bit tricky to get the OLS equivalent (you can get the GMM one by adding lots of instruments, but it won't be exactly equivalent).
One final comment. You employ the absolute value function to enforce positivity of some terms. I generally avoid this function as it is not differentiable at the origin and the coefficients are only identified up to a sign transformation. For positivity, the exp function should work fine (though you'll still have problems as you approach the origin of the transformed value).
-
freedomplaza
- Posts: 13
- Joined: Tue May 31, 2016 7:48 am
Re: Which matrix is near singular?
Dear Eviews Glenn, thanks for your reply. To answer your first question: in Matlab, I am estimating a GMM, which is my ultimate goal. The 2SLS discussion is an unwanted detour, which is due to Eviews insisting on calculating the first step estimates in the GMM as a 2SLS. I do not care about the 2SLS estimates, but since Eviews did not deliver proper GMM estimates, I was forced to think about the 2SLS.
Matlab is directly computing the first step estimates by minimizing the proper quadratic function of moment conditions and identity matrix. Incidentally, the estimates that I obtain from this first step concide with the numbers that I reported in my previous post, obtained from Eviews by fixing one parameter and minimizing with respect to the other. This makes me think that I am doing things properly in Matlab.
Concerning your discussion on instruments in the 2SLS, I was under the impression that if the instrument is a constant, then the matrix Pz boils down to 1. I think that this is because Pz=Z'(Z'*Z)^{-1}*Z. In this case e(b)' Pz e(b) = e(b)'e(b), i.e. the 2SLS and OLS objective functions should coincide.
Is there any way of overriding the first step 2SLS estimate of the parameters in the GMM estimation? Would be nice if Eviews computed the parameters by direct numerical minimization of the objective function. Somehow I think that the 2SLS first step estimates are designed with a linear system in mind, but may not work properly with a non-linear system like mine.
Matlab is directly computing the first step estimates by minimizing the proper quadratic function of moment conditions and identity matrix. Incidentally, the estimates that I obtain from this first step concide with the numbers that I reported in my previous post, obtained from Eviews by fixing one parameter and minimizing with respect to the other. This makes me think that I am doing things properly in Matlab.
Concerning your discussion on instruments in the 2SLS, I was under the impression that if the instrument is a constant, then the matrix Pz boils down to 1. I think that this is because Pz=Z'(Z'*Z)^{-1}*Z. In this case e(b)' Pz e(b) = e(b)'e(b), i.e. the 2SLS and OLS objective functions should coincide.
Is there any way of overriding the first step 2SLS estimate of the parameters in the GMM estimation? Would be nice if Eviews computed the parameters by direct numerical minimization of the objective function. Somehow I think that the 2SLS first step estimates are designed with a linear system in mind, but may not work properly with a non-linear system like mine.
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: Which matrix is near singular?
If the instrument is 1 then the projection matrix Pz = (ll')/T, not I.
As I said, in the linear case, you can add all of the regressors which will effectively make Pz = I. In your nonlinear case, you can do an approximately by adding various instruments, but it's not exact. Note that nonlinear IV estimation in general is a strange animal as there are potentially lots of different instruments that one can choose (c.f. Amemiya's survey).
Can you write out your full GMM specification including your model for the optimal weights (I want see what you want to compute as it's not clear what you want to do in the direct unconditional moment calculation since there really aren't any instruments).
As I said, in the linear case, you can add all of the regressors which will effectively make Pz = I. In your nonlinear case, you can do an approximately by adding various instruments, but it's not exact. Note that nonlinear IV estimation in general is a strange animal as there are potentially lots of different instruments that one can choose (c.f. Amemiya's survey).
Can you write out your full GMM specification including your model for the optimal weights (I want see what you want to compute as it's not clear what you want to do in the direct unconditional moment calculation since there really aren't any instruments).
-
freedomplaza
- Posts: 13
- Joined: Tue May 31, 2016 7:48 am
Re: Which matrix is near singular?
The GMM is based on the following moment conditions
1/T*sum_{t=1}^{t} exp{m_1t} * exp(r_t} = 0
1/T*sum_{t=1}^{t} (m_1t - m_2t)^2 -fx^2 = 0
where m_1t and m_2t are defined in the Eviews file that I attached in one of my previous messages. They are a function of the parameters that I want to estimate.
The instrument for exp{m_1t} * exp(r_t} and (m_1t - m_2t)^2 -fx^2 is a constant, since I am targeting their sample means.
1/T*sum_{t=1}^{t} exp{m_1t} * exp(r_t} = 0
1/T*sum_{t=1}^{t} (m_1t - m_2t)^2 -fx^2 = 0
where m_1t and m_2t are defined in the Eviews file that I attached in one of my previous messages. They are a function of the parameters that I want to estimate.
The instrument for exp{m_1t} * exp(r_t} and (m_1t - m_2t)^2 -fx^2 is a constant, since I am targeting their sample means.
Who is online
Users browsing this forum: No registered users and 2 guests
