代码拉取完成,页面将自动刷新
clear all
********************************************************************************
*** verify fweights ***
********************************************************************************
$loadspam
// frequencies
set seed 123
gen freq = max(rpoisson(3),1)
// estimate with fweights
lassologit v58 v1-v57 [fw=freq]
mat A = e(betas)
mat LA = e(lambdas)
// estimate with expanded data
expand freq
lassologit v58 v1-v57
mat B = e(betas)
mat LB = e(lambdas)
assert mreldif(LA,LB)<1e-10
assert mreldif(A,B)<1e-10
********************************************************************************
*** verify fweights (without constant) ***
********************************************************************************
$loadspam
// frequencies
set seed 123
gen freq = max(rpoisson(3),1)
// estimate with fweights
lassologit v58 v1-v57 [fw=freq], nocons
mat A = e(betas)
mat LA = e(lambdas)
// estimate with expanded data
expand freq
lassologit v58 v1-v57, nocons
mat B = e(betas)
mat LB = e(lambdas)
assert mreldif(LA,LB)<1e-10
assert mreldif(A,B)<1e-10
********************************************************************************
*** verify aweights ***
********************************************************************************
$loadspam
// aweights / pweights
// check by setting lambda very small
// => lasso logit and post-logit should be similar
set seed 123
gen double wtvar=runiform()
lassologit v58 v1-v10 [aw=wtvar], l(0.000001) tolopt(1e-15) tolzero(1e-15)
mat bL=e(beta_dense)
mat bPL=e(beta_post_dense)
assert mreldif(bL,bPL)<0.002
// confirm pw and aw are equivalent
lassologit v58 v1-v5 [aw=wtvar], l(0.05)
mat bL=e(beta_dense)
mat bPL=e(beta_post_dense)
lassologit v58 v1-v5 [pw=wtvar], l(0.05)
assert mreldif(bL,e(beta_dense))<1e-10
assert mreldif(bPL,e(beta_post_dense))<1e-10
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。