avaialable from (https://rpubs.com/staszkiewicz/FM_OE)

Task

Test signalling theory on the coca cola stocks on 22 march 2023

Solution

  1. Load Required Libraries:
library(quantmod)
## Ładowanie wymaganego pakietu: xts
## Ładowanie wymaganego pakietu: zoo
## 
## Dołączanie pakietu: 'zoo'
## Następujące obiekty zostały zakryte z 'package:base':
## 
##     as.Date, as.Date.numeric
## Ładowanie wymaganego pakietu: TTR
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo
library(dplyr)
## 
## ######################### Warning from 'xts' package ##########################
## #                                                                             #
## # The dplyr lag() function breaks how base R's lag() function is supposed to  #
## # work, which breaks lag(my_xts). Calls to lag(my_xts) that you type or       #
## # source() into this session won't work correctly.                            #
## #                                                                             #
## # Use stats::lag() to make sure you're not using dplyr::lag(), or you can add #
## # conflictRules('dplyr', exclude = 'lag') to your .Rprofile to stop           #
## # dplyr from breaking base R's lag() function.                                #
## #                                                                             #
## # Code in packages is not affected. It's protected by R's namespace mechanism #
## # Set `options(xts.warn_dplyr_breaks_lag = FALSE)` to suppress this warning.  #
## #                                                                             #
## ###############################################################################
## 
## Dołączanie pakietu: 'dplyr'
## Następujące obiekty zostały zakryte z 'package:xts':
## 
##     first, last
## Następujące obiekty zostały zakryte z 'package:stats':
## 
##     filter, lag
## Następujące obiekty zostały zakryte z 'package:base':
## 
##     intersect, setdiff, setequal, union
library(ggplot2)
  1. Download Coca-Cola Stock Data:
getSymbols("KO", from = "2023-03-10", to = "2023-03-30")
## [1] "KO"
  1. Identify the Event Date:

The event date is March 22, 2023.

event_date<- "2023-03-22"
  1. Calculate Returns:
KO_returns <- diff(log(KO$KO.Adjusted))
  1. Create a Dummy Variable for the Event:
event_dummy <- ifelse(index(KO_returns) == "2023-03-22", 1, 0)
  1. Estimate the Event Study:
event_study <- lm(KO_returns[-1] ~ event_dummy[-1])
summary(event_study)
## 
## Call:
## lm(formula = KO_returns[-1] ~ event_dummy[-1])
## 
## Residuals:
##        Min         1Q     Median         3Q        Max 
## -0.0093136 -0.0035189  0.0008286  0.0027027  0.0115637 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)  
## (Intercept)      0.004659   0.001823   2.556   0.0267 *
## event_dummy[-1] -0.009146   0.006574  -1.391   0.1917  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.006316 on 11 degrees of freedom
## Multiple R-squared:  0.1496, Adjusted R-squared:  0.07232 
## F-statistic: 1.936 on 1 and 11 DF,  p-value: 0.1917

Interpreting the Results:

Coefficient of event_dummy: This coefficient represents the abnormal return on the event day. If it’s significantly positive, it suggests that the event (likely a dividend announcement or stock buyback) positively signaled the company’s future prospects. If it’s significantly negative, it suggests a negative signal. Additional Considerations:

Control Variables:

You might consider including control variables (e.g., market returns, industry returns) to isolate the effect of the event. Event Window: To account for potential market reactions before or after the event, you can define an event window (e.g., -2 to +2 days around the event) and calculate cumulative abnormal returns. Statistical Tests: Use statistical tests (e.g., t-test) to assess the significance of the abnormal returns.

Example Code:

# Assuming the event was a dividend announcement on March 22, 2023

# Calculate cumulative abnormal returns
event_window <- c(-2, 2)
event_date<- "2023-03-22"
poz<-match(as.Date(event_date), index(KO_returns))# to get the numeric position of the date in the value vector 
w_beg<- poz+event_window[1]
w_end<- poz+event_window[2]
event_dummy[w_beg:w_end]<-1 # to define the widow

CAR <- cumsum(KO_returns[-1] *  event_dummy[-1])[(w_beg-1):(w_end-1)]

# Test for significance
t_stat <- CAR[length(CAR)] / sd(CAR) / sqrt(length(CAR))
p_value <- 2 * pt(-abs(t_stat), df = length(CAR) - 1)

# Print results
cat("Cumulative Abnormal Return:", CAR[length(CAR)], "\n")
## Cumulative Abnormal Return: 0.01455535
cat("t-statistic:", t_stat, "\n")
## t-statistic: 0.9825981
cat("p-value:", p_value, "\n")
## p-value: 0.3814372

Excersise

  • Assuming that the dividend announcement of Microsoft (5$ per stock) took place on 17 April 2020, check whether this impact the market, assess the market efficiency level