楼主: 唐伯小猫
24046 14

[一般统计问题] 弱弱问一下,如何在stata 做Wls?(50积分答谢) [推广有奖]

11
蓝色 发表于 2007-11-23 07:36:00

这是greene书上的例子

use "d:\data\dta\greena\table51-greene.dta", clear
rename x1 age
rename x2 income
rename x3 exp
rename x4 ownrent
rename x5 selfemp

generate incomesq = income^2
drop if exp==0

*save chapter12hetero,replace

regress exp age ownrent income incomesq
rvpplot income, xlab(0 2 to 12) xline(2 4 6 8 10) ylab(-500 0 to 2000) yline(0 500 1000 1500)
regress exp age ownrent income incomesq, robust

matrix d = vecdiag(e(V))
matrix v =  cholesky(diag(d))
matrix s = sqrt((72-5)/72)*vecdiag(v)
matrix list s

regress exp age ownrent income incomesq, hc2

whitetst
hettest
bpagan income incomesq

wls0 exp age ownrent income incomesq , wvar(income) type(abse) noconst          /* 12.3a */
wls0 exp age ownrent income incomesq , wvar(incomesq) type(abse) noconst        /* 12.3b */
wls0 exp age ownrent income incomesq , wvar(income incomesq) type(e2) noconst   /* 12.3c */
wls0 exp age ownrent income incomesq , wvar(income incomesq) type(abse) noconst /* 12.3d */
wls0 exp age ownrent income incomesq , wvar(income incomesq) type(loge2)        /* 12.3e */
wls0 exp age ownrent income incomesq , wvar(income incomesq) type(xb2)          /* 12.3h */
regress exp age ownrent income incomesq [aw = 1/income]
regress exp age ownrent income incomesq [aw = 1/incomesq]

regress exp age ownrent income incomesq


predict e, resid
generate ee=e^2
regress ee income incomesq, noconst


predict p1
regress exp age ownrent income incomesq [aw = 1/p1]

generate abse=abs(e)
regress abse income incomesq, noconst


predict p2
regress exp age ownrent income incomesq [aw = 1/p2]

generate logee=log(ee)
regress logee income incomesq

predict p3
replace p3 = exp(p3)
regress exp age ownrent income incomesq [aw = 1/p3]


generate loginc = log(income)
regress logee loginc


predict p4
replace p4 = exp(p4)
regress exp age ownrent income incomesq [aw=1/p4]

reghv exp age ownrent income incomesq, var(loginc)

regress exp age ownrent income incomesq


predict p
generate p5 = p^2
regress exp age ownrent income incomesq [aw=1/p5]
reghv exp age ownrent income incomesq, var(income incomesq)

已有 1 人评分经验 论坛币 学术水平 热心指数 信用等级 收起 理由
Sunknownay + 100 + 5 + 1 + 1 + 1 热心帮助其他会员

总评分: 经验 + 100  论坛币 + 5  学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

12
唐伯小猫 发表于 2007-11-23 07:42:00

谢谢楼上各位,我做出来了!多谢:)

心若向阳,无畏悲伤。

13
freeliu 发表于 2010-2-12 16:54:19
楼主是怎么解决的啊? 最近碰到同样的问题了。

14
一幢山一片海 发表于 2015-4-2 11:30:52
唐伯小猫 发表于 2007-11-23 07:42
谢谢楼上各位,我做出来了!多谢:)
你好,请问stata中权重变量在众多自变量里该选择哪一个呢?谢谢你。

15
考博小猪 学生认证  发表于 2020-6-10 15:56:44
先做wald test,得到回归的拟合值 那个拟合值就weight

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

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