楼主: nkzhh
108029 142

[程序分享] 用stata如何检验panel的自相关和异方差   [推广有奖]

61
蒋璐韩 发表于 2009-12-6 21:20:39
谢谢!好好留着。

62
蒋璐韩 发表于 2009-12-6 21:21:36
谢谢!好好留着。

63
fantasyshot 在职认证  发表于 2009-12-7 19:54:19
Title    Testing for panel-level heteroskedasticity and autocorrelation  
Author  Vince Wiggins, StataCorp
Brian Poi, StataCorp  
Date  June 2001; revised December 2003  

--------------------------------------------------------------------------------

Question:
I see how one can correct for potential heteroskedasticity across panels using xtgls, but I am unsure of a simple way to test for it.

Answer:
Since iterated GLS with only heteroskedasticity produces maximum-likelihood parameter estimates, we can easily do an LR test.

We can type

        . xtgls ... , igls panels(heteroskedastic)
        . estimates store hetero

to fit the model with panel-level heteroskedasticity and save the likelihood.

We can fit the model without heteroskedasticity by typing

        . xtgls ...

Now there is one trick. Normally, lrtest infers the number of constraints when we fit nested models by looking at the number of parameters estimated. For xtgls, however, the panel-level variances are estimated as nuisance parameters and their count is NOT included in the parameters estimated. So, we will need to tell lrtest how many constraints we have implied.

The number of panels/groups is stored in e(N_g) and, in the second model, we are constraining all of these to be single value, so our number of constraints can be computed and stored in a local macro by typing

        . local df = e(N_g) - 1

The test is then obtained by typing

        . lrtest hetero . , df(`df')

Autocorrelation
Iterated GLS with autocorrelation does not produce the maximum likehood estimates, so we cannot use the likelihood-ratio test procedure, as with heteroskedasticity. However, Wooldridge (2002, 282–283) derives a simple test for autocorrelation in panel-data models. Drukker (2003) provides simulation results showing that the test has good size and power properties in reasonably sized samples.

There is a user-written program, called xtserial, written by David Drukker to perform this test in Stata. To install this user-written program, type

        . findit xtserial
        . net sj 3-2 st0039         (or click on st0039)
        . net install st0039        (or click on click here to install)

To use xtserial, you simply specify the dependent and independent variables:

        . xtserial depvar indepvars

A significant test statistic indicates the presence of serial correlation
人既无虎狼之爪牙,亦无狮象之力量,却能擒狼伏虎,训狮猎象,无他,惟智慧耳

64
zhonghuaqin 发表于 2009-12-7 20:01:43
请问蜻蜓点水或哪位高人为何:lrtest hetero nohetero , df(`df')不能用?STATA不能给出结果?

65
ruclaolan 发表于 2010-1-14 12:18:23
学到不少,顶
laolan

66
gnuliutingting 发表于 2010-1-18 12:59:40
Thanks, I need it!

67
晴蓝天空88 发表于 2010-1-27 21:22:27
各人高人,俺正在学习中!

68
whc8631 发表于 2010-4-16 14:14:01
好贴!可惜我用的是Eviews

69
Linda孙 发表于 2010-4-26 14:35:02
留帖子做记号哈哈,谢谢,收获不少

70
jepering 发表于 2010-4-27 11:44:57
受益匪浅,谢谢各位。

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2025-12-25 04:41