This is the Second Midterm Exam for Financial Econometrics 1
First I make sure to download all the desired packages. Then I download the Data Set
library(readxl)
download.file("http://www.apradie.com/datos/dataex1.xlsx", "dataex1.xlsx", mode="wb")
trying URL 'http://www.apradie.com/datos/dataex1.xlsx'
Content type 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' length 169000 bytes (165 KB)
==================================================
downloaded 165 KB
data<-read_excel("dataex1.xlsx")
This dataset has real financial quarterly data of ALL Mexican firms for some quarters.
It is believed that firms get benefits from financial leverage. However, if firms abuse from financial leverage, this might have a negative impact on firm performance. Using data ONLY for the quarter “2015-01-01”, design and run a regression model to examine whether financial leverage has an effect on stock return, after considering the effect of earnings per share deflated by price. Use the variable F1r as stock return (so you do not have to calculate stock return since it is already in the dataset). You have to use all firms all quarters.
library(readxl)
download.file("http://www.apradie.com/datos/dataex1.xlsx", "dataex2.xlsx", mode="wb")
trying URL 'http://www.apradie.com/datos/dataex1.xlsx'
Content type 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' length 169000 bytes (165 KB)
==================================================
downloaded 165 KB
data <- read_excel("dataex2.xlsx")
data$quarter <- as.Date(data$quarter)
#leverage
data$leverage <- data$ltdebt/data$ta
model1 <- lm(F1r ~ leverage + I(leverage^2), data = data, na.action = na.omit)
s_model1 <- summary(model1)
s_model1
Call:
lm(formula = F1r ~ leverage + I(leverage^2), data = data, na.action = na.omit)
Residuals:
Min 1Q Median 3Q Max
-1.02792 -0.06604 0.00036 0.06378 1.14850
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.015901 0.006417 2.478 0.0133 *
leverage -0.032953 0.091823 -0.359 0.7197
I(leverage^2) -0.062556 0.230039 -0.272 0.7857
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.1523 on 1246 degrees of freedom
(375 observations deleted due to missingness)
Multiple R-squared: 0.001654, Adjusted R-squared: 5.157e-05
F-statistic: 1.032 on 2 and 1246 DF, p-value: 0.3565
For financial leverage calculate the ratio of long-term debt (ltdebt) to total assets (ta). In other words, financial leverage will be equal to the division between long-term debt and total assets. Long-term debt is the ltdebt variable, and total assets is the ta variable.
To select data of only the quarter “2015-01-01”, you can do the following:
#converting the column quarter to Date class
data$q<-as.Date(data$quarter)
#creating a subset with only quarter=2015-01-01:
data2015 <- data[data$q=="2015-01-01",]
Since this regression does not use lagged variables, you can use the lm function.
You have to run the regression, and also calculate the 95% confidence interval of the beta1 and beta2 coefficients.
library(ggplot2)
newx <- data.frame(leverage = seq(-7,0.6, by=0.5))
prd <- predict.lm(model1, newx, interval = "confidence")
pred_1 <- cbind(newx, prd)
colnames(pred_1) <- c("leverage", "F1r", "lwr", "upr")
ggplot(pred_1, aes(x = leverage, y=F1r))+
geom_point(leverage = 1) + geom_line() +
geom_errorbar(aes(ymax = upr, ymin=lwr))
Warning: Ignoring unknown parameters: leverage
THE P- VALUE FOR THE SELF MULTIPLIED LEVERAGE IS EQUAL TO 0.7857 (B2)AND SINCE THAT VALUE IS FAR GREATER THAN 0.05 I CAN SAY WITH CERTAINTY THAT THERE ISN’T A SIGNIFICANT EFFECT OF LEVERAGE WHEN IT COMES TO RETURNS PRESENTED BY THE COMPANY. NOW WHEN IT COMES TO THE LEVERAGE COEFFICIENT I’D SAY IT HOLDS NO SIGNIFICANCY SINCE THE P-VALUE IS EQUAL TO 0.7197 (B1). THUS I CANT INFER THE RELATIONSHIP IN QUESTION IS NEGATIVE. NOW, USING THE GRAPH AS A VISUAL AID THE RELATIONSHIP ISN’T LINEAR SINCE THERE IS A PART WHERE EXPECTED RETURNS TEND TO 0, WHEREAS THE REST OF THE GRAPH APPEARS POSITIVE. A LEVERAGE THAT SITS BETWEEN THE RANGES OF -1 AND 0 THE STOCK RETURNS ARE KEPT CONSTANT AT 0.
Using the same dataset, using now ALL quarters, run a multiple regression model to examine whether cashflow generated from operations and the categorical variable size type (sizetype) influence earnings per share (deflated by price and winsorized). Use all quarters and all firms.
library(pscore)
#epsp
data$eps <- data$ebit / data$sharesoutstanding
data$epsp <- data$eps / data$adjustedstockprice
data$epsp_w <- winsorizor(data$epsp, 0.02)
#cashflow
data$cflow <- data$cashflowoper/data$ta
data$cflow_w <- winsorizor(data$cflow, 0.01)
#regression model
model2 <- lm(epsp_w ~ cflow_w + sizetype , data = data, na.action = na.omit)
s_model2 <- summary(model2)
s_model2
Call:
lm(formula = epsp_w ~ cflow_w + sizetype, data = data, na.action = na.omit)
Residuals:
Min 1Q Median 3Q Max
-0.13961 -0.03738 -0.01878 0.01357 0.39716
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.053357 0.003565 14.966 < 2e-16 ***
cflow_w 0.116526 0.038681 3.013 0.00264 **
sizetypemedium -0.036567 0.009099 -4.019 6.2e-05 ***
sizetypesmall 0.001188 0.004168 0.285 0.77568
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.07174 on 1261 degrees of freedom
(359 observations deleted due to missingness)
Multiple R-squared: 0.02438, Adjusted R-squared: 0.02206
F-statistic: 10.5 on 3 and 1261 DF, p-value: 7.955e-07
To calculate Earnings per Share use EBIT (ebit) as numerator and # of shares (sharesoutstanding) as denominator. Then divide this by adjustedstockprice (there is not historical stock price in the dataset) to get Earnings per Share deflated by price (EPSP). Finally, winsorize this variable at the 2%.
For cashflow from operations, use the ratio of cashflow from operations (cashflowoper) to total assets (ta). In other words, create a variable cfr that will be equal to cashflowoper / ta. You have to winsorize this ratio at the 1%.
#95 confidence interval
min <- s_model2$coefficients[2,1]-(2*s_model2$coefficients[2,2])
max <- s_model2$coefficients[2,1]+(2*s_model2$coefficients[2,2])
min
[1] 0.03916465
max
[1] 0.1938868
min0 <- s_model2$coefficients[1,1]-(2*s_model2$coefficients[1,2])
max0 <- s_model2$coefficients[1,1]+(2*s_model2$coefficients[1,2])
min0
[1] 0.04622605
max0
[1] 0.06048708
min3 <- s_model2$coefficients[4,1]-(2*s_model2$coefficients[4,2])
max3 <- s_model2$coefficients[4,1]+(2*s_model2$coefficients[4,2])
min3
[1] -0.007148715
max3
[1] 0.009524838
Provide a clear INTERPRETATION of the coefficients and their corresponding p-values.
CASHFLOW POSSESES A POSITIVE-SIGNIFICANT RELATION OVER EPSP, WHICH CAN BE SEEN AT THE 95% CONFIDENCE INTERVAL GOING FROM 0.03916465 TO 0.1938868 SO 95% OF THE TIMES THE RANGE WILL BE SEEN WHEN REPEATING THE MODEL AND ALL OF THIS CAN BE CHECKED BY THE P-VALUE 0.00264. ALPHA 1 MEDIUM FIRMS HAVE AN AVERAGE EFFECT OF 0.036567 LESSER THAN THE EPSP WHEN IN COMPARISSON TO LARGER FIRMS SO NATURALLY THIS IS SIGNIFICANT SINCE THE P-VALUE IS (sizetypemedium 6.2e-05). SMALLER FIRMS ARE AFFECTED ON AVERAGE (sizetypesmall 0.001188) MORE EPSP THAN BIGGER FIRMS ALTHOUGH THIS ISN’T SIGNIFICANT SINCE THE P-VALUE SITS AT 0.77568 AND THE 95% CONFIDENCE INTERVAL RANGES FROM -0.007148715 TO 0.009524838, THUS THE EFFECT OF EPSP RANGES FROM NEGATIVE TO POSITIVE.