Hello all,
I have a panel data set with N=9 and T= 72. That is, it is dominated by the time dimension.
I am using Nonlinear Least Squares to estimate y_it = G(X_it, Beta) where X is a vector. Since I have large T and -nl allows for HAC standard errors, I wanted to use the Newey-west type. So the command line would look like:
xtset country time
nl (y_it = G(X_it, y_it-1 , {Beta}, {tita}) ) , vce( hac nwest 1)
However, I get an error message.
After some exploration it seems HAC standard errors may only be allowed with time series data? Below, I use a concrete example (I am using the equation fro the example in the manual but with my data since the example is cross-section). You can see the default -nl is working. However, it does not work when I use HAC standard errors. It does work If I use data only for one of the countries.
So I guess my questions are:
did I get it right about the impossibility of using HAC standard errors with -nl in panel data? If not, that may be the problem with the error message "invalid values for time variable"?
Is there another way I can get similar HAC standard errors given that the typical clustered standard errors at country level is not a good option (N=9)?
*************************example****************** **************************
. xtset id qdate
panel variable: id (strongly balanced)
time variable: qdate, 1995q1 to 2012q4
delta: 1 quarter
. nl (y = {b0=1}*(1 - exp(-1*{xb: x1 x2 x3})))
(obs = 639)
Iteration 0: residual SS = 1.087753
Iteration 1: residual SS = 1.087609
(output omitted)
Iteration 24: residual SS = 1.08407
Iteration 25: residual SS = 1.08407
Source | SS df MS
-------------+------------------------------ Number of obs = 639
Model | .150733652 4 .037683413 R-squared = 0.1221
Residual | 1.08406976 635 .001707196 Adj R-squared = 0.1165
-------------+------------------------------ Root MSE = .0413182
Total | 1.23480341 639 .0019324 Res. dev. = -2262.894
------------------------------------------------------------------------------
y | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
/b0 | .1432534 .0798919 1.79 0.073 -.0136309 .3001376
/xb_x1 | -2.563193 1.479896 -1.73 0.084 -5.469275 .342889
/xb_x2 | -.3452112 .1553889 -2.22 0.027 -.6503495 -.0400729
/xb_x3 | .5535491 .253464 2.18 0.029 .0558201 1.051278
------------------------------------------------------------------------------
. nl (y = {b0=1}*(1 - exp(-1*{xb: x1 x2 x3}))) if id==1, vce(hac nwest 1)
(obs = 71)
Iteration 0: residual SS = .0434943
Iteration 1: residual SS = .0434926
(output omitted)
Iteration 68: residual SS = .0386671
Iteration 69: residual SS = .0386671
Nonlinear regression Number of obs = 71
HAC kernel (lags): Newey-West (1) R-squared = 0.1742
Adj R-squared = 0.1249
Root MSE = .0240233
Res. dev. = -332.1074
------------------------------------------------------------------------------
| HAC
y | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
/b0 | .0091456 .0053915 1.70 0.094 -.0016159 .019907
/xb_x1 | -81.13559 36.95537 -2.20 0.032 -154.8988 -7.372364
/xb_x2 | -8.989475 4.26374 -2.11 0.039 -17.49994 -.4790137
/xb_x3 | 13.99074 6.900514 2.03 0.047 .2172568 27.76423
------------------------------------------------------------------------------
. nl (y = {b0=1}*(1 - exp(-1*{xb: x1 x2 x3}))), vce(hac nwest 1)
(obs = 639)
Iteration 0: residual SS = 1.087753
Iteration 1: residual SS = 1.087609
(output omitted)
Iteration 24: residual SS = 1.08407
Iteration 25: residual SS = 1.08407
invalid values for time variable
r(451);
************************************************** ************
I have a panel data set with N=9 and T= 72. That is, it is dominated by the time dimension.
I am using Nonlinear Least Squares to estimate y_it = G(X_it, Beta) where X is a vector. Since I have large T and -nl allows for HAC standard errors, I wanted to use the Newey-west type. So the command line would look like:
xtset country time
nl (y_it = G(X_it, y_it-1 , {Beta}, {tita}) ) , vce( hac nwest 1)
However, I get an error message.
After some exploration it seems HAC standard errors may only be allowed with time series data? Below, I use a concrete example (I am using the equation fro the example in the manual but with my data since the example is cross-section). You can see the default -nl is working. However, it does not work when I use HAC standard errors. It does work If I use data only for one of the countries.
So I guess my questions are:
did I get it right about the impossibility of using HAC standard errors with -nl in panel data? If not, that may be the problem with the error message "invalid values for time variable"?
Is there another way I can get similar HAC standard errors given that the typical clustered standard errors at country level is not a good option (N=9)?
*************************example****************** **************************
. xtset id qdate
panel variable: id (strongly balanced)
time variable: qdate, 1995q1 to 2012q4
delta: 1 quarter
. nl (y = {b0=1}*(1 - exp(-1*{xb: x1 x2 x3})))
(obs = 639)
Iteration 0: residual SS = 1.087753
Iteration 1: residual SS = 1.087609
(output omitted)
Iteration 24: residual SS = 1.08407
Iteration 25: residual SS = 1.08407
Source | SS df MS
-------------+------------------------------ Number of obs = 639
Model | .150733652 4 .037683413 R-squared = 0.1221
Residual | 1.08406976 635 .001707196 Adj R-squared = 0.1165
-------------+------------------------------ Root MSE = .0413182
Total | 1.23480341 639 .0019324 Res. dev. = -2262.894
------------------------------------------------------------------------------
y | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
/b0 | .1432534 .0798919 1.79 0.073 -.0136309 .3001376
/xb_x1 | -2.563193 1.479896 -1.73 0.084 -5.469275 .342889
/xb_x2 | -.3452112 .1553889 -2.22 0.027 -.6503495 -.0400729
/xb_x3 | .5535491 .253464 2.18 0.029 .0558201 1.051278
------------------------------------------------------------------------------
. nl (y = {b0=1}*(1 - exp(-1*{xb: x1 x2 x3}))) if id==1, vce(hac nwest 1)
(obs = 71)
Iteration 0: residual SS = .0434943
Iteration 1: residual SS = .0434926
(output omitted)
Iteration 68: residual SS = .0386671
Iteration 69: residual SS = .0386671
Nonlinear regression Number of obs = 71
HAC kernel (lags): Newey-West (1) R-squared = 0.1742
Adj R-squared = 0.1249
Root MSE = .0240233
Res. dev. = -332.1074
------------------------------------------------------------------------------
| HAC
y | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
/b0 | .0091456 .0053915 1.70 0.094 -.0016159 .019907
/xb_x1 | -81.13559 36.95537 -2.20 0.032 -154.8988 -7.372364
/xb_x2 | -8.989475 4.26374 -2.11 0.039 -17.49994 -.4790137
/xb_x3 | 13.99074 6.900514 2.03 0.047 .2172568 27.76423
------------------------------------------------------------------------------
. nl (y = {b0=1}*(1 - exp(-1*{xb: x1 x2 x3}))), vce(hac nwest 1)
(obs = 639)
Iteration 0: residual SS = 1.087753
Iteration 1: residual SS = 1.087609
(output omitted)
Iteration 24: residual SS = 1.08407
Iteration 25: residual SS = 1.08407
invalid values for time variable
r(451);
************************************************** ************