【问题标题】:Stata: How to find firms which changed the status in the time-series datasetStata:如何在时间序列数据集中找到改变状态的公司
【发布时间】:2015-01-08 17:06:14
【问题描述】:

我有一个数据集,其中包含有关不同公司及时表现的信息。它有变量:公司 id、年份、公司的出口状态(基本上,如果是出口商,则为 1)。我想知道有多少公司(在特定组中,在特定时间间隔内)做出了出口决定,例如将导出状态从 0 更改为 1。我想通过转换为 csv 然后通过 python 脚本解析来避免暴力方法。

【问题讨论】:

标签: statistics stata economics


【解决方案1】:

这是使用滞后运算符的一种方式:

clear

input firm_id   t   exp
0   1   0
0   2   1
1   1   0
1   2   1
1   3   1
2   1   0
2   2   1
2   3   0
3   1   1
3   2   1
4   1   0
4   2   0
end

xtset firm_id t
gen start_exp = cond(exp==1 & L.exp==0,1,0)
bys t: sum start_exp

【讨论】:

  • cond() 是无害的,但没有必要。可能是exp==1 & L.exp==0
  • @RobertoFerrer 你是绝对正确的,但我发现cond() 更容易阅读,尤其是k 个月后。
猜你喜欢
  • 2017-10-12
  • 2013-10-18
  • 1970-01-01
  • 2021-12-09
  • 2022-06-13
  • 1970-01-01
  • 1970-01-01
  • 2015-10-02
  • 2016-08-11
相关资源
最近更新 更多