Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Calculate market beta automatically

    Hi all,

    I just started using STATA, so I do not have much knowledge about it. I need to calculate market betas for about 1000 event dates. I have the daily stock as well as market returns for each event date (period: -150 to -30 days prior to event date) in the following format:

    For each row im column 1: Event dates
    For each row in columns 2-7 (simplified): Stock return t-3, Stock return t-2, Stock return t-1, Market return t-3, Market return t-2, Market return t-1

    I want to regress stock return (columns 2-4) against market return (columns 5-7). What command do I have to use in order to calculate the market beta for each event data and save it in as a new variable (e.g. in column 8)?

    In other posts, I read that I have to use the rolling command. However, I do not know exactly how to apply it to my problem. I would be very happy, if someone can help me out. Thank you very much in advance!

    Best regards,
    Tobias

  • #2
    I don't understand finance, so I"m not sure what a market beta is. But it sounds like you want to do a regression of stock return against market return with a window of 3 time units for each event date.

    As with most things in Stata, this is most easily done (in this case, I think, only possible) in long data layout. So the first step is to -reshape long-. Then -statsby- will manage the regresions, and then you merge the file of coefficients that -statsby- creates back with your own data.

    You have presented your data description to us in a way that suggests you are working in a spreadsheet. Of course, you will need to import it to Stata. At that point you will have variable names that conform to Stata syntax. I'll assume they are called stock_return1, stock_return2, stock_return3, market_return1, market_return2, and market_return3, and the first variable is called event_date

    Code:
    reshape long stock_return market_return, i(event_date) j(time_offset)
    
    tempfile coefficients
    statsby, by(event_date) saving(`coefficients'): regress stock_return market_return
    
    merge m:1 event_date using `coefficients'

    Comment

    Working...
    X