Login or Register Log in with. Forums FAQ. Search in titles only. Posts Latest Activity. Page of 1. Filtered by:. John Bullock. I'm using Stata Here is an example: Code:. Tags: instrumental variablesivreg2. Martin Bresslein. The only thing that differs between ivregress and ivreg2 in the results is the test statistic against the null model.

Comment Post Cancel. Hi, Martin, Thank you. This is curious: I re-ran my code and found the same discrepancies.

## Help for reghdfe

A Stack Overflow poster also found them when using ivreg2 3. When he used ivreg2 2. Here are the specific discrepancies that I observe: Code:. Richard Williams. Rounding may be throwing the comparisons off.By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service.

Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It only takes a minute to sign up. Suppose I have hierarchical data such as students clustered into classrooms. I want to use a two stage least squares regression with an instrument that affects students at the classroom level to test my hypothesis.

What is the appropriate method to test if my instrument is weak? The Cragg-Donald F-statistic with Stock and Yogo critical values seems appropriate for the general case of identifying weak instruments but it doesn't build in any adjustment for clustering.

The appropriate weak instrument test for testing for weak instruments in panel data or more generally data that is non-i. When the i. The critical values reported by ivreg2 for the Kleibergen-Paap statistic are the Stock-Yogo critical values for the Cragg-Donald i.

Sign up to join this community. The best answers are voted up and rise to the top. Home Questions Tags Users Unanswered. Testing for weak instruments in panel data Ask Question. Asked 6 years, 11 months ago. Active 6 years, 9 months ago. Viewed 3k times. Andre Silva 2, 5 5 gold badges 25 25 silver badges 52 52 bronze badges. Jonathan Jonathan 1 1 silver badge 8 8 bronze badges. See also discussion on statalist. Active Oldest Votes. Sign up or log in Sign up using Google.

Sign up using Facebook. Sign up using Email and Password.Login or Register Log in with. Forums FAQ. Search in titles only. Posts Latest Activity. Page of 1. Filtered by:. Tunga Kantarci. I would like to ask two questions which regard the endogeneity test, and the versions of it, produced by xtivreg2. If I understand it correctly, if the "robust" and "cluster" options are specified in the xtivreg2 command, xtivreg2 calculates a version of the endogneiety test that is robust to heteroskedasticity and serial correlation within panel groups.

I would like to see the exact formula used to calculate the endogeneity test. On the other hand, the documentation of ivreg2 does not specify the exact formula used. Which endogeneity test is used here? Where can I find the exact formulas calculating the versions of the test that are robust to heteroskedasticity, robust to serial correlation in the errors within panel groups, and robust to both at the same time?

I also wanted to check the result produced by the "estat endogenous" command that can be executed after the ivregress command. I expected that the endogeneity option of the xtivreg2 command and the output of the estat endogenous command both use the same endogeneity test and hence lead to the same test value. Apperantly they use different statistics, or that my approach of differncing the data and using the ivregress command incorrect, although I cannot really think of a reason why it would be incorrect because I obtain the very same coefficient estimates in xtivreg2 and in ivregress after differencing.

From the documentation of "estat endogenous", the formula used to calculate the endogeneity test, that is robust to heterskedasticity and serial correlation within panel groups, is not clear to me. Is there a Stata reference that clearly states the statistics and formulas used by estat endogenous? Tags: None.

Hi, This is an update to my first question above - I cannot seem to edit the original message instead. Would this guess be correct? If I am not overlooking, documentation of xtivreg2 is not explicit on the test used.

Comment Post Cancel. Hi, Would it be possible, perhaps for Mark as the author, to consider my questions on xtivreg2 above? Steve Samuels. Perhaps that will answer your question. Steve Samuels Statistical Consulting sjsamuels gmail. Mark Schaffer. Steve is right - xtivreg2 is just a wrapper for ivreg2 after applying the relevant panel data transformation to the dataso for discussion of the tests implemented in xtivreg2 just check the help file for ivreg2 or the Stata Journal articles cited therein.

They provide detailed information on various subjects indeed. They are explicit on the statsitics used. However, they are not always explicit on the versions of the statistics used.

Regarding my question 1 above: I simply would like to ask which statistic or the version of the regarding statistic is used as the test for endogeneity test "in the presence of heteroskedasticity and serial correlation on panel groups".Search everywhere only in this topic.

Advanced Search. Classic List Threaded. IVreg2 on interaction term. Dear Statalist, I would very much appreciate if you could help me with the following concern on IVreg2.

I have an interaction term of two dummy variables d1, d2the first is endogenous, d2 is very probably not. I have 1 instrument for d1. My problem is now a technical one: I do not know how to write an ivreg2-command including two IVs. If you allow, I would like to ask a second question. Is it possible to use newey2 in an IV-regression I need autocorrelation robust standard errors; data is an unbalanced panel.

Many thanks indeed! Martin Weiss AW: IVreg2 on interaction term. You seem to want to create a one-to-one mapping of instruments to endogenous covariates, but the -syntax- does not allow for that Heine Gesendet: Mittwoch, April An: [hidden email] Betreff: st: IVreg2 on interaction term Dear Statalist, I would very much appreciate if you could help me with the following concern on IVreg2.

Christopher F Baum. In reply to this post by D. But if you have a panel, what you want is Mark Schaffer's xtivreg2, which is a 'wrapper' for ivreg2. Same options apply. The syntax does not allow for it because the underlying econometric theory does not allow for it. Search everywhere only in this topic Advanced Search IVreg2 on interaction term. Free forum by Nabble. Edit this page.Back to index. If you want to predict afterwards but don't care about setting the names of each fixed effect, use the save fe suboption.

Example: reghdfe price weight, absorb turn trunk, savefe. This option does not require additional computations, and is required for subsequent calls to predict, d. The complete list of accepted statistics is available in the tabstat help. The most useful are count range sd median p. To save the summary table silently without showing it after the regression tableuse the qui etly suboption. You can use it by itself summarize ,quietly or with custom statistics summarize mean, quietly.

Note that all the advanced estimators rely on asymptotic theory, and will likely have poor performance with small samples but again if you are using reghdfe, that is probably not your case.

Warning: in a FE panel regression, using r obust will lead to inconsistent standard errors if for every fixed effect, the other dimension is fixed.

For instance, in an standard panel with individual and time fixed effects, we require both the number of individuals and time periods to grow asymptotically.

If that is not the case, an alternative may be to use clustered errors, which as discussed below will still have their own asymptotic requirements.

**Stata 2SLS**

For a discussion, see Stock and Watson, "Heteroskedasticity-robust standard errors for fixed-effects panel-data regression," Econometrica 76 : Multi-way-clustering is allowed. Thus, you can indicate as many clustervar s as desired e. Each clustervar permits interactions of the type var1 var2 this is faster than using egen group for a one-off regression.

Warning: The number of clusters, for all of the cluster variables, must go off to infinity. A frequent rule of thumb is that each cluster variable must have at least 50 different categories the number of categories for each clustervar appears on the header of the regression table. The following suboptions require either the ivreg2 or the avar package from SSC.

For a careful explanation, see the ivreg2 help filefrom which the comments below borrow. At most two cluster variables can be used in this case. Is the same package used by ivreg2, and allows the bwkerneldkraay and kiefer suboptions. This is useful almost exclusively for debugging.

Requires ivsuite ivregressbut will not give the exact same results as ivregress. Explanation: When running instrumental-variable regressions with the ivregress package, robust standard errors, and a gmm2s estimator, reghdfe will translate vce robust into wmatrix robust vce unadjusted.

This maintains compatibility with ivreg2 and other packages, but may unadvisable as described in ivregress technical note. Specifying this option will instead use wmatrix robust vce robust. However, computing the second-step vce matrix requires computing updated estimates including updated fixed effects.

Since reghdfe currently does not allow this, the resulting standard errors will not be exactly the same as with ivregress. This issue is similar to applying the CUE estimator, described further below. Possible values are 0 none1 some information2 even more3 adds dots for each iteration, and reportes parsing details4 adds details for every iteration step.

For debugging, the most useful value is 3. For simple status reports, set verbose to 1. Without any adjustment, we would assume that the degrees-of-freedom used by the fixed effects is equal to the count of all the fixed effects e. However, in complex setups e. Note: changing the default option is rarely needed, except in benchmarks, and to obtain a marginal speed-up by excluding the pair wise option.

It is equivalent to dof pairwise clusters continuous.By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service. Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It only takes a minute to sign up. I was running a 2SLS regression with ivreg2 in Stata and I used the Cumby and Huizinga's test for autocorrelation with ivactest -- I found that there was a problem of autocorrelation in the estimation.

Then I used the option for autocorrelation consistent standard errors, but running ivactest again it seems the residuals still suffer from autocorrelation. I would like to know if Cumby and Huizinga's test still 'works' when you already introduced robust SE to deal with autocorrelation, in the sense that you might observe through the test if the autocorrelation problem was correctly dealt with.

I'm adding an example from Stata's output just to show that the test changes with the way the standard erros are calculated. I would like to know if Cumby and Huizinga's test still is a valid measure to see if one eliminates the problem of autocorrelation after using autocorrelation consistent standard errors. I'm assuming you used the robust and bw options from ivreg2.

### 面板数据基本分析stata语令

Neither of these changes the estimates of the coefficients in your regression, these methods only change the way the standard errors of the coefficients are computed. This means that your residuals are unchanged after specifying robust.

If there was autocorrelation in your original residuals, there will still be autocorrelation now. By the way: actest is a more recent version of ivactestyou can download it using ssc install actest.

Sign up to join this community. The best answers are voted up and rise to the top. Home Questions Tags Users Unanswered. SE robust to autocorrelation and testing afterwards Ask Question. Asked 4 years, 6 months ago. Active 4 years, 6 months ago. Viewed times. Edit: I'm adding an example from Stata's output just to show that the test changes with the way the standard erros are calculated.Ind i.

Answer: A Test heteroskedasticity. Try the following codes.

## Announcement

You can NOT use the fact given above. However, you can use the following code. The following is an example. Your data should look like the following sample. Once you found the problems of heteroscedasticity and autocorrelation using the tests provided, then it will be proper to use FGLS using the following STATA command: iis country tis year xtgls y x1 x2 x3, i country t year panels correlated corr psar1 This code corrects for heteroscedasticity across sections or countriesit corrects for autocorrelation within countries serial correlation and contemporaneous correlation spatial correlation between countries as well.

Data format Country year x1 x2 x3 1 1 x x x 1 2 x x x 2 1 x x x 2 2 x x x 3 1 x x x 3 2 x x x XTGLS is a random effects model estimation method, in your case, you can use xtreg with vce robust option to correct for heteoscedasticity which uses Huber-White method. GMM in the presence of arbitrary heteroskedasticity and autocorrelation. GMM in the presence of arbitrary heterosked.

## thoughts on “Ivreg2 bw”