全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
723 2
2024-05-12
gen policy = year - 2017
tab policy
replace policy = -3 if policy < -3
replace policy = 2 if policy > 2
forvalues i = 3(-1)1{
        gen pre_`i'= (policy == -`i' & treat == 1)
}
gen current = (policy ==0 & treat==1)
forvalues j = 1(1)2{
        gen post_`j' = (policy == `j' & treat == 1)
}

reghdfe invest pre_* current post_* Growth SOE Lev ROA Size CF Growth Indep Duality Schrcr1,absorb(code year)
这是我的代码,如何显示了如下错误,不知道怎么回事
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------search for r(110)                                                                                                                                    (manual:  [R] search)--------------------------------------------------------------------------------------------------------------------------------------------------------------------------Search of official help files, FAQs, Examples, and Stata Journals[P]     error . . . . . . . . . . . . . . . . . . . . . . . .  Return code 110        __________ already defined        A variable or a value label has already been defined, and you        attempted to redefine it.  This occurs most often with generate.        If you really intend to replace the values, use replace.  If you        intend to replace a value label, specify the replace option with        the label define command.  If you are attempting to alter an        existing label, specify the add or modify option with the        label define command.(end of search)        

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2024-5-12 18:51:04
你的代码看起来是使用 stata 进行双重差分(DID)分析的尝试。在运行 `reghdfe` 命令时遇到了错误。为了更好地理解并解决这个问题,我需要看到具体的错误信息。请将输出中的错误信息复制粘贴到你的问题中。

通常,这类错误可能是由于数据格式、缺失值、变量类型或 absorb 选项的使用不正确导致的。检查一下 `invest`(因变量)和所有自变量是否存在缺失值,以及所有变量是否都是数值型。另外,确保 `code` 和 `year` 变量在你的数据中并且适合用于吸收效应。

如果错误信息不明确,你也可以尝试简化模型,先移除一些控制变量,看看错误是否仍然存在。或者,你可以使用 `regress` 命令代替 `reghdfe` 进行初步的回归,以检查问题是否出在高级的固定效应估计上。

此文本由CAIE学术大模型生成,添加下方二维码,优先体验功能试用



二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2024-5-14 14:18:36
你的代码
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群