如何计算FOMC利率变动公告对标普500指数回报的事件窗口

huangapple go评论49阅读模式
英文:

How to calculate an event window for FOMC interest change announcement on S&P500 returns

问题

我正在使用Stata进行一项关于FOMC利率变动公告对S&P500回报的事件研究。我有日期和事件日(公告日)的变量,其中每次发生事件时值为1。

我在计算事件窗口时遇到了问题。事件窗口需要从-2到2的范围。所以每当事件值为1时,我需要在新变量中的值为事件日为-2、-1、0,而在事件日为1、2时为1、2。

举个例子,在新变量中,第15行应该是0,第14行应该是-1,第16行应该是1,依此类推。这个循环需要遍历所有事件值为1的情况。

英文:

I'm doing a event study in Stata on the effect of FOMC interest change announcement on S&P500 returns.
I have variables for date and for event days (announcementdays), where the value is 1 every time there is an event.

I have trouble with calculating my event window. The event window needs to range from -2 to 2. So everytime the event value is 1, I need the values in a new variable to be -2,-1, 0 on the event day and 1, 2.

To illustrate, in the new variable row 15 should be 0, observation 14 should -1 and observation 16 should be 1 and so on. This loop needs to go through all the occasions where the event is equal to 1.

End Output

答案1

得分: 1

我认为你指的是我通常称为“事件时间”变量的内容。以下是如何在一个简单示例数据集上创建这样一个变量。

输入 id 日期 事件 
1 20 0
1 21 0
1 22 1
1 23 0
2 20 0
2 21 0
2 22 1
2 23 0 
结束 

请查看下面的注释:

* 首先,如果有事件,创建一个带有日期的列
gen date_with_event = date if event==1 

* 然后,找到每个ID的最早事件日期
bys id: egen first_date_with_event = min(date_with_event)

* 事件时间是当前日期减去该日期
gen event_time = date - first_date_with_event

list 

最终输出为

    +----------------------------------------------------+
     | id   date   event   date_w~t   first_~t   event_~e |
     |----------------------------------------------------|
  1. |  1     20       0          .         22         -2 |
  2. |  1     21       0          .         22         -1 |
  3. |  1     22       1         22         22          0 |
  4. |  1     23       0          .         22          1 |
  5. |  2     20       0          .         22         -2 |
     |----------------------------------------------------|
  6. |  2     21       0          .         22         -1 |
  7. |  2     22       1         22         22          0 |
  8. |  2     23       0          .         22          1 |
     +----------------------------------------------------+
英文:

I think you're referring to what I typically call the "event time" variable. Here's how to make such a variable on a simple example dataset.

input id date event 
1 20 0
1 21 0
1 22 1
1 23 0
2 20 0
2 21 0
2 22 1
2 23 0 
end 

Check out the comments below:

* First make a column with the date whenever there's an event
gen date_with_event = date if event==1 

* Then find the earliest event for each ID
bys id: egen first_date_with_event = min(date_with_event)

* The event time is the current date minus that date
gen event_time = date - first_date_with_event

list 

The final output is

    +----------------------------------------------------+
     | id   date   event   date_w~t   first_~t   event_~e |
     |----------------------------------------------------|
  1. |  1     20       0          .         22         -2 |
  2. |  1     21       0          .         22         -1 |
  3. |  1     22       1         22         22          0 |
  4. |  1     23       0          .         22          1 |
  5. |  2     20       0          .         22         -2 |
     |----------------------------------------------------|
  6. |  2     21       0          .         22         -1 |
  7. |  2     22       1         22         22          0 |
  8. |  2     23       0          .         22          1 |
     +----------------------------------------------------+

huangapple
  • 本文由 发表于 2023年5月28日 21:57:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/76351852.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定