Hi, I have a time series of stock returns with multiple event date indicators, such as the following:
date return event
01jan2015 -0.2 0
02jan2015 1.2 1
03jan2015 0.3 0
04jan2015 0.4 0
05jan2015 -0.3 1
06jan2015 -0.1 0
I would like to create a new variable (timeToEvent) that takes the value of number of days from the event within a 3-day window around each event, where day 0 is each event day. The events are all spread apart by at least 3 days. For instance, it would look like this:
date return event timeToEvent
01jan2015 -0.2 0 -1
02jan2015 1.2 1 0
03jan2015 0.3 0 1
04jan2015 0.4 0 -1
05jan2015 -0.3 1 0
06jan2015 -0.1 0 1
How may I do this?
Related Posts with Creating event time variable
Random forests and neural nets in Stata (with Python integration)Hey all, I wrote a couple Stata packages to do regression or classification with random forests and…
question about xtabond2 outputI am running the below syntax Code: xtabond2 generalcrime l.generalcrime proactivity feb mar apr…
Replace value in many observations and variablesDear all I have a database of around 50 variables and 200 observations. I would like to replace with…
Generating dummy variable conditional to other dummy variable figuresHi everyone, I have two dummy variables, holder67 and holder30, which are equal to 1 if the value o…
Finding R squared and Adjusted R squared values on xtregHi Everyone, I am conducting research on panel data, set with xtset command on STATA. xtset compan…
Subscribe to:
Post Comments (Atom)
0 Response to Creating event time variable
Post a Comment