怀特检验的stata步骤

更新时间:2023-05-06 12:08:30 阅读: 评论:0

clear
cd "G:\econometrics\teach\hetero"          /*your data path*/
capture log clo
log using "result\heterskedasicity.log", replace
*1) Open your data file 
u "data\hprice1.dta", clear
*2) Regress housing price on hou size, and test for heterskedasicity
reg price lotsize sqrft bdrms
whitetst  /*You can also try "whitetst, fitted" for e=d+d1yhat+d2yhat^2+v */
bpagan  lotsize sqrft bdrms
*3) Regress Log(housing price) on Log(hou size), and test for heterskedasicity
reg lprice llotsize lsqrft bdrms
whitetst  /*You can also try "whitetst, fitted" for e=d+d1yhat+d2yhat^2+v */
bpagan  llotsize lsqrft bdrms
*4) OLS, with robust sd
reg price lotsize sqrft bdrms, robust
*5)GLS/WLS
bpagan  llotsize 
reg price lotsize sqrft bdrms  [aw = 1/lotsize]
*5)FGLS
reg price lotsize sqrft bdrms          /*First, doing OLS, and
                        we know from 2, this model has heterskedasicity*/
predict e, residual              /*get the residual */
gen ln_e2=log(e*e)            /*generate log of the square of residual */   
reg ln_e2 lotsize sqrft bdrms      /*reg residual square on all Xs */
predict ghat, xb                /*get predicted value for ln_e2*/
gen =exp(ghat)                /*get hhat */
reg price lotsize sqrft bdrms  [aw = 1/]  /*WLS, using the estimated variance as weight*/
log clo

本文发布于:2023-05-06 12:08:30,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/90/97931.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:
相关文章
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图