Is there some pre-defined statsmodels function that lets me use GMM together with Newey west standard errors?

456 Views Asked by At

I found statsmodels.sandbox.regression.gmm for gmm regressions but dont understand how I can use it with Newey West errors in a simple way.

Maybe let me outline my specific case: I have only one explanatory variable and one dependent variable. this is the code I am using:

import numpy as np 
import pandas as pd from statsmodels.sandbox.regression.gmm 
import GMM 

X = var_beta["f1"] 
X = sm.add_constant(X) 
y = var_beta["f2"] 

model_1 = GMM(y, X, None) 
results = model_1.fit(weights_method = 'hac', wargs={'maxlag': 30}) 

This returns:

AttributeError: 'GMM' object has no attribute 'fitstart'. 

And if I add

beta = np.array([0.0061,-0.3283])
results = model_1.fit(beta, optim_method='nm', weights_method = 'hac',wargs={'maxlag': 30})

I get

numpy.linalg.LinAlgError: SVD did not converge

Although I do not understand why I should add this. Found it in an example and do not know what the equivalent for my sample would be. Regardless, it would return this error message anyways.

What am I doing wrong? Is it because I did not specify any instruments or moment conditions? The problem is that I am basing the procedure on a paper which only states:

"We estimate the regressions using the generalized methods of moments (GMM), with the weighting matrix computed according to Newey and West (1987) with 30 lags for the overlapping daily series"

But the authors do not elaborate any further, so I would not know which moment restrictions or instruments to use (if I have to use them at all). The regression (a normal CAPM regression) is super simple and should look like

Regression

where the left-hand-side corresponds to y, and the right-hand-side to X from above in the code respectively.

I have to admit that I am completely new to the whole GMM procedure and me failing to apply the code could be due to my non-existent expertise within the domain. It is just one of many components that I have to apply in my Master thesis and this one really is giving me a headache.

1

There are 1 best solutions below

4
On

When fitting using GMM's .fit() method, specify weights_method argument to choose covariance matrix estimation procedure, for Newey-West you need weights_method = 'hac'.