楼主: kch7716598
11246 15

[程序分享] stata的vuong检验求助 [推广有奖]

11
白菜不是这样种 学生认证  发表于 2020-9-20 14:58:21
{smcl}
{* 02may2007}{...}
{cmd:help vuong}{right:version:  1.0.0}
{hline}

{title:Title}

{p 4 8}{cmd:vuong}  -  Performs Vuong (1989 Econometrica) test comparing (possibly)
non-nested linear regression specifications. {p_end}


{title:Syntax}

{p 4 6 2}
{cmd:vuong}
{it:modelA modelB}


{title:Description}

{p 4 4 2}
{cmd:vuong} computes the Vuong (1989 Econometrica) test as implemented in Dechow (1994 Journal of Accounting and economics.  The test statistic is obtained by first computing the following quantity for each observation i:{p_end}

{p 8 8 2}
m(i)=0.5*log(RSSa/RSSb) + 0.5*n*[(ea(i))^2/RSSa - (eb(i))^2/RSSb]
{p_end}

{p 4 4 2}
where RSSa is the residual sum of squares for regression specification A and ea(i) is observation i's residual in regression specification A.  The definitions of RSSb and eb(i) are similar for regression specification B.  n is the number of observations in the regression.
{p_end}

{p 4 4 2}
The test statistic is computed by regressing the m(i)'s on a constant.  The t-statistic on the constant, multiplied by -sqrt[(n-1)/n], is the Z-statistic for the Vuong test.  A positive value indicates that {it:modelA} is better specified than {it:modelB} and vice versa.
{p_end}


{title:Example}

{phang}{stata "reg y x" : . reg y x}{p_end}
{phang}{stata "est store modA" : . est store modA}{p_end}
{phang}{stata "reg y z" : . reg y z}{p_end}
{phang}{stata "est store modB" : . est store modB}{p_end}
{phang}{stata "vuong modA modB" : . vuong modA modB}{p_end}

{title:Author}

{p 4 4}Judson Caskey, UT, judson.caskey@mccombs.utexas.edu{p_end}




12
白菜不是这样种 学生认证  发表于 2020-9-20 14:59:00
白菜不是这样种 发表于 2020-9-20 14:58
{smcl}
{* 02may2007}{...}
{cmd:help vuong}{right:version:  1.0.0}
用记事本保存为vuong.hlp,这个是帮助文件

13
白菜不是这样种 学生认证  发表于 2020-9-20 14:59:32
******************************
* vuong.ado
* Judson A. Caskey
* UCLA
* 26-Apr-2007
*
* Computes Vuong (1989 Econometrica) test
* of two non-nested regressions as implemented
* and described in Dechow (1994 Journal of
* Accounting and Economics)
*
******************************

cap prog drop vuong
prog define vuong, rclass

syntax [anything]

tempname mod1 mod2 rss1 rss2 rsq1 rsq2 n zstat pval nbad
tempvar s1 s2 e1 e2 m

if `"`: word count `anything''"' ~= "2" {
        di as err "You must specify two distinct models"
        exit
        }

est_expand `"`anything'"', min(1) max(2)
local `mod1' : word 1 of `r(names)'
local `mod2' : word 2 of `r(names)'
if "``mod1''"=="``mod2''" {
        di as err "You must specify two distinct models"
        exit
        }

quietly estimates restore ``mod1''
local `rss1'=e(rss)
local `rsq1'=e(r2)
quietly _predict `e1' if e(sample), resid
quietly gen `s1'=e(sample)

quietly estimates restore ``mod2''
local `rss2'=e(rss)
local `rsq2'=e(r2)
quietly _predict `e2' if e(sample), resid
quietly gen `s2'=e(sample)

quietly count if `s1'==1 & `s2'==1 & ~missing(`e1',`e2')
local `n'=r(N)

quietly gen `m'=log(``rss1''/``rss2'')/2 + ``n''*((`e1'^2)/``rss1'' - (`e2'^2)/``rss2'')/2 if `s1'==1 & `s2'==1 & ~missing(`e1',`e2')

quietly reg `m'

local `zstat'=-sqrt((e(N)-1)/e(N))*_b[_cons]/_se[_cons]
local `pval'=(1-normal(abs(``zstat'')))*2

di as result _column(20) "   Model 1"  _column(35) "   Model 2"
di as result "R-Squared" _column(20) %10.4f ``rsq1'' _column(35) %10.4f ``rsq2''
di as result ""
di as result "Vuong Z-Statistic" _column(20) %10.4f ``zstat''
di as result "  p-value" _column(20) %10.4f ``pval''

return scalar r2_1=``rsq1''
return scalar r2_2=``rsq2''
return scalar Z=``zstat''
return scalar p=``pval''

quietly count if (`s1'==1 & `s2'==0) | (`s1'==0 & `s2'==1)
local `nbad'=r(N)
di as result ""
if ``nbad''>0 di as err "``nbad'' observations in one model but not the other"

end

14
白菜不是这样种 学生认证  发表于 2020-9-20 15:01:09
白菜不是这样种 发表于 2020-9-20 14:59
******************************
* vuong.ado
* Judson A. Caskey
用记事本,保存为vuong.ado。把vuong.ado和vuong.hlp保存到stata目录下ado→base→v文件中。亲测可用,文件为2020年9月20日谷歌下载的。

15
和怪物 发表于 2020-11-26 13:12:04
白菜不是这样种 发表于 2020-9-20 15:01
用记事本,保存为vuong.ado。把vuong.ado和vuong.hlp保存到stata目录下ado→base→v文件中。亲测可用,文 ...
unexpected end of file
(error occurred while loading vuong.ado)
请问出现这个是什么原因喃

16
jxapp_64297 发表于 2021-8-28 09:44:46
Vuong test is not appropriate for testing zero-inflation.  Specify option
forcevuong to perform the test anyway.
这是什么意思

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

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2026-1-8 13:11