Announcement

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

  • Test event study

    Hi,

    I am currently revising to an exam and trying different problemsets, one is on a event study. However, the format of the datasets have been challenging as they are different from what I have experienced earlier.


    The task is as follows:

    Problem 2

    Event Study Investigate whether announcements of increases in expected earnings lead to positive abnormal returns. The file EventStudy_Firmdata contains daily return data on N = 150 announcements of increases in expected earnings. For each event, T = 100 days of return data are given. The data is already in event time, and the announcement takes place at = 0. The calendar dates of the announcements do not overlap. The file EventStudy_Marketdata contains the returns on the market index of all publicly traded stocks, calculated over the same period in calendar time as the respective returns in EventStudy Firmdata (e.g. market1 is the market return over the same horizon as the returns in event1). Conduct an event study with the following speci cations:

    The event window runs from the event day ( = 0) to the day after the event day ( = 1) such that the length of the event window is L2 = 2.

    The estimation window spans from = 64 to = 5 (i.e. the length of the estimation window is L1 = 60).

    Use the market model to estimate the normal returns and to obtain abnormal returns.

    1. Test the hypothesis that the event has no e ect on abnormal returns, using the J1 test described in CLM chapter 4. Test the one-sided hypothesis that the event has no e ect on abnormal returns against the alternative hypothesis that the event has a positive e ect on abnormal returns. Report the values of the test statistic as well as the p-value and your conclusion.



    My code is as follows:



    clear


    use "EventStudy_Firmdata.dta"


    merge 1:1 tau using"EventStudy_Marketdata.dta"


    drop _merge


    * Set up matrices to store the alpha and beta results

    matrix alphas = J(1, 150, .)

    matrix betas = J(1, 150, .)


    * Define the event and estimation windows as binary variables

    generate event_window = (tau >= 0 & tau <= 1)

    generate estimation_window = (tau >= -64 & tau <= -5)


    * Initialize matrices to store alphas, betas, and MSEs

    matrix alphas = J(1, 150, .)

    matrix betas = J(1, 150, .)


    * Loop through indices from 1 to 150

    forval i = 1/150 {

    * Perform regression quietly

    quietly regress event`i' market`i' if estimation_window == 1



    * Store the alpha and beta values

    matrix alphas[1, `i'] = _b[_cons]

    matrix betas[1, `i'] = _b[market`i']

    }


    matrix rmse = J(1, 150, .)


    forval i = 1/150 {

    quietly regress event`i' market`i' if estimation_window == 1



    predict y_hat`i'



    generate residual`i' = event`i' - y_hat`i'



    generate squared_residuals`i' = residual`i'^2

    }


    forval i = 1/150 {

    egen mean_squared_residual`i' = mean(squared_residuals`i')



    scalar temp_sqrt = sqrt(mean_squared_residual`i')

    matrix rmse[1, `i'] = temp_sqrt

    }



    * Optionally, you can list the matrices to see the values

    matrix list alphas

    matrix list betas

    matrix list rmse


    * Retrieve the matrix into a local macro variable to calculate the sum

    matrix total_rmse = rmse * J(150, 1, 1) // This multiplies each element of rmse by 1 and sums vertically


    * The result is stored in a 1x1 matrix. We need to extract the value

    scalar sum_rmse = total_rmse[1,1]


    * Now calculate the mean by dividing by the number of observations

    scalar mean_rmse = sum_rmse / 150


    * Display the mean RMSE value

    display "Mean RMSE: " mean_rmse


    * Loop through the events to generate abnormal returns and CARs

    forval i = 1/150 {

    * Generate abnormal returns for each event

    generate abnormal_returns`i' = event`i' - (alphas[1, `i'] + betas[1, `i'] * market`i') if event_window == 1

    }


    forval i = 1/150 {

    generate cum_abnormal_returns`i' = sum(abnormal_returns`i') if event_window == 1

    }


    forval i = 1/150 {

    replace cum_abnormal_returns`i' = . if tau == 0

    }


    * Initialize the matrix to store individual means

    matrix CAR_matrix = J(1, 150, .)


    * Loop to calculate mean for each variable and store it in the matrix

    forval i = 1/150 {

    quietly summarize cum_abnormal_returns`i' if event_window == 1

    matrix CAR_matrix[1, `i'] = r(mean)

    }


    * Manually sum all the elements of the matrix to calculate the overall average

    scalar sum = 0

    forval i = 1/150 {

    scalar sum = sum + CAR_matrix[1, `i']

    }

    scalar overall_average = sum / 150


    * Display the overall average

    display "The overall average of the CAR values is: " overall_average


    scalar J = overall_average / mean_rmse


    display J



    display J gives the wrong sum, as the correct answer is supposed to be 1.034

    Any help would be greatly appreciated
    Attached Files

  • #2
    test answer

    Comment

    Working...
    X