Constructing Measures and Initial Analysis

2024-08-05

Loading Package and Data

library(tidyverse)
library(fixest)

setwd("C:/Users/chen/Dropbox/Data/Mutual funds/Fund portfolio")
load("data.RData")

Creating Measurements

The basic data structure is a balanced panel of 63 AMCs \(\times\) 20 quarters. The data has 1260 observations. The recession starts at the 5th quarter (01-03/2008) and ends at the 10th quarter (04-06/2009).

Outcomes

For the outcomes, we construct three measures of the fund portfolios.

  1. The size of the fund portfolio - measured by cumulative no. of funds in each quarter.
  2. The share of stocks in the fund portfolio - measured by the percentages of values of stocks in the portfolio (i.e., total asset values).
  3. The diversity of the fund portfolio - an entropy measure with the percentages of different assets as the input, \(-\sum_k ln(p_k)\).

Size of the fund portfolio

# get the firm-fund level data
get_first_row_of_data <- function(x) {x <- x[1,]}
temp <- asset_portfolio_final_1 %>% group_by(Firm_ID, Fund_ID) %>%
  do(get_first_row_of_data(.))

# get the no. of funds as a panel 
get_no_of_funds <- function(temp) {
  a <- as.data.frame(table(temp$Quarter_ID))
  b <- rep(0,20)
  b[a$Var1] <- a$Freq
  b <- cumsum(b)
  return(data.frame(Quarter_ID = 1:20, No_of_fund = b))
}
firm_data_1 <- temp %>% group_by(Firm_ID) %>% 
  do(get_no_of_funds(.))

Shares of stocks for a firm and the fund portfolio diversity

Restructure the data.

# get the asset portfolios at different quarters
temp <- asset_portfolio_final_1 %>% group_by(Firm_ID, Quarter_ID) %>% 
  summarise(Total_asset_value = sum(Total_asset_value),
            Stock_market_value = sum(Stock_market_value),
            Total_bonds = sum(Total_bonds),
            Bank_deposits_and_clearing_reserve = 
              sum(Bank_deposits_and_clearing_reserve),
            Other_assets = sum(Other_assets),
            Repurchase_agreements = sum(Repurchase_agreements),
            Receivable_securities_clearing_funds = 
              sum(Receivable_securities_clearing_funds),
            Warrants = sum(Warrants))

# filling out the remaining quarters
fill_rest_quarters <- function(temp_1) {
  if (dim(temp_1)[1]<20) {
    a <- matrix(rep(0,(20-dim(temp_1)[1])*dim(temp_1)[2]), 
                nrow = 20 - dim(temp_1)[1],
                ncol = dim(temp_1)[2])
    a[,1] <- rep(temp_1$Firm_ID[1], dim(a)[1])
    a[,2] <- 1:(20-dim(temp_1)[1])
    a <- as.data.frame(a)
    colnames(a) <- colnames(temp_1)
    temp_1 <- rbind(a, temp_1)
  }
  return(temp_1)
}

temp_1 <- temp %>% group_by(Firm_ID) %>% do(fill_rest_quarters(.))

Construct the measures.

# get the ratio of different assets

temp_1 <- temp_1 %>% mutate(Total_asset_value = Total_asset_value + 
                              (Total_asset_value==0)) %>%
  mutate(Stock_ratio = Stock_market_value/Total_asset_value,
         Bond_ratio = Total_bonds/Total_asset_value,
         Bank_deposits_ratio = Bank_deposits_and_clearing_reserve/
           Total_asset_value,
         Other_ratio = Other_assets/Total_asset_value,
         Repurchase_agreements_ratio = Repurchase_agreements/
           Total_asset_value,
         Receivable_securities_ratio = 
           Receivable_securities_clearing_funds/
           Total_asset_value,
         Warrants_ratio = Warrants/Total_asset_value)

# define a function to calculate the normalized entropy 
compute_entropy <- function(x) {
  n <- length(x)
  x_1 <- x[x>0]
  if (length(x_1)==0) {
    y <- 0
  } else if (length(x_1)>0) {
    y <- -sum(x_1*log(x_1))/log(n)
  }
  return(y)
}

# calculate three entropy measures
temp_1 <- temp_1 %>% rowwise() %>% 
  mutate(fund_portfolio_diversity_sb = 
           compute_entropy(c(Stock_ratio, Bond_ratio)),
         fund_portfolio_diversity_sbc = 
           compute_entropy(c(Stock_ratio, Bond_ratio, Bank_deposits_ratio)),
         fund_portfolio_diversity_all = 
           compute_entropy(c(Stock_ratio, Bond_ratio, Bank_deposits_ratio,
                             Other_ratio, Repurchase_agreements_ratio,
                             Receivable_securities_ratio, Warrants_ratio)))

Independent variables

Clean the data of the net values of funds.

## obtain the same structure as portfolio
net_value <- net_value %>% filter(季度>=200703 & 季度<=201112)
colnames(net_value) <- c("Fund_code","Quarter","Fund_abbreviation",
                         "Shares","Unit_net_value")

## fill out the missing quarters
net_value <- cbind(net_value, asset_portfolio[,c(20:25)])

get_net_value_of_missing_quarters <- function(temp) {
  t0 <- temp$Fund_issue_time_ID[1]
  t1 <- min(temp$Quarter_ID)
  if (t0 < t1) {
    tempi <- do.call("rbind", replicate(t1-t0,temp[1,],simplify=F))
    temp <- rbind(tempi, temp)
  }
  return(temp)
}
net_value <-  net_value %>% group_by(Fund_ID) %>% 
  do(get_net_value_of_missing_quarters(.))
net_value <- cbind(net_value, asset_portfolio_final_1[,4:5])

# update the net asset value 
update_net_value_of_asset <- function(temp) {
  t0 <- temp$Fund_issue_time_ID[1]
  t1 <- min(temp$Quarter_ID)
  if (t0 < t1) {
    a <- temp$`Net_asset_value_(NAV)`[1:(t1-t0+1)]
    b <- temp$Total_asset_value[1:(t1-t0+1)]
    b <- (b[-1]-b[-(t1-t0+1)])/b[-1]
    for (i in (t1-t0):1) {
      a[i] <- a[i+1]/(1+b[i])
    } 
    temp$`Net_asset_value_(NAV)`[1:(t1-t0+1)] <- a
    temp$Quarter_ID[1:(t1-t0+1)] <- t0:t1
  }
  return(temp)
}
net_value <-  net_value %>% group_by(Fund_ID) %>% 
  do(update_net_value_of_asset(.))
net_value <- net_value %>% 
  mutate(Unit_net_value_1 = `Net_asset_value_(NAV)`/Shares)

Next, construct the firm-quarter level IVs. Here, we use two IVs:

  • The total NPVs (net present values) of the funds owned by AMCs prior to the current quarter. This can be thought of as the size measure.
  • The net value per unit of the funds owned by the AMCs prior to the current quarter. This value equals to the NPVs divided by the total no. of shares. This can be thought of as a quality measure.
# fill out the missing values of net asset value
net_value <- net_value %>% 
  mutate(Net_asset_value_1 = Shares*Unit_net_value) %>% 
  mutate(`Net_asset_value_(NAV)` = 
           coalesce(`Net_asset_value_(NAV)`, Net_asset_value_1))
temp <- net_value %>% group_by(Firm_ID, Quarter_ID) %>% 
  summarise(Net_asset_value = sum(`Net_asset_value_(NAV)`),
            Unit_net_value_0 = sum(Shares*Unit_net_value)/sum(Shares),
            Unit_net_value_1 = sum(`Net_asset_value_(NAV)`)/sum(Shares))
temp <- temp %>% mutate(Unit_net_value_0 = ifelse(
  is.na(Unit_net_value_0), Unit_net_value_1, Unit_net_value_0),
  Unit_net_value_1 = ifelse(
    is.na(Unit_net_value_1), Unit_net_value_0, Unit_net_value_1))

firm_data_1 <- left_join(firm_data_1, temp, 
                         by = c("Firm_ID","Quarter_ID"))
firm_data_1 <- firm_data_1 %>% replace(is.na(.),0)

Next, create variables with great recession and time trends.

firm_data_1 <- firm_data_1 %>% mutate(Recession = case_when(
  Quarter_ID < 5 ~ "Pre-recession",
  Quarter_ID > 10 ~ "Post_recession",
  TRUE ~ "During_recession"
)) %>% mutate(Recession = as.factor(Recession))
firm_data_1$Time_trend <- rep(1:20,63)

Inital Analysis of Main Effects

For the initial analysis, we use the previous design with \(Y\) as DV and \(X\) as IVs. Time trends, great recession dummies and their interactions are added as the main control variables. \[ y_{it} = \beta X_{i,t-1} + \alpha_i + \lambda_t \times \text{Recession}_t + \gamma C_{it} + e_{it} \] For the base version, we do not add control variables (\(C_{it}\)), such as the no. of board members etc.

No of funds

Load package and declare the panel data.

firm_data_1 <- panel(firm_data_1, panel.id = ~Firm_ID+Quarter_ID)

Run the main regression of the no. of funds.

model_no_of_funds <- feols(No_of_fund ~ 
                             l(log(Net_asset_value),1,0) +
                             l(Unit_net_value_1,1,0)| 
                             Firm_ID + Quarter_ID,
                           firm_data_1)
summary(model_no_of_funds)
## OLS estimation, Dep. Var.: No_of_fund
## Observations: 1,059
## Fixed-effects: Firm_ID: 63,  Quarter_ID: 20
## Standard-errors: Clustered (Firm_ID) 
##                                      Estimate Std. Error t value   Pr(>|t|)    
## l(log(Net_asset_value), 1, fill = 0) 0.616935   0.162570 3.79488 0.00033796 ***
## l(Unit_net_value_1, 1, fill = 0)     0.484809   0.281566 1.72183 0.09008688 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 1.35348     Adj. R2: 0.841611
##                 Within R2: 0.062829

Stock ratio

Run the main regression of the share of stocks.

model_stock_ratio <- feols(Stock_ratio ~ 
                             l(log(Net_asset_value),1,0) +
                             l(Unit_net_value_1,1,0)| 
                             Firm_ID + Quarter_ID,
                           firm_data_1)
summary(model_stock_ratio)
## OLS estimation, Dep. Var.: Stock_ratio
## Observations: 1,059
## Fixed-effects: Firm_ID: 63,  Quarter_ID: 20
## Standard-errors: Clustered (Firm_ID) 
##                                       Estimate Std. Error   t value   Pr(>|t|)
## l(log(Net_asset_value), 1, fill = 0)  0.012252   0.013009  0.941781 3.4996e-01
## l(Unit_net_value_1, 1, fill = 0)     -0.154218   0.032809 -4.700473 1.4902e-05
##                                         
## l(log(Net_asset_value), 1, fill = 0)    
## l(Unit_net_value_1, 1, fill = 0)     ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.127705     Adj. R2: 0.695326
##                  Within R2: 0.056636

Fund portfolio diversity

Run the main regression of the share of stocks.

model_fund_portfolio_diversity <- feols(fund_portfolio_diversity_all ~ 
                             l(log(Net_asset_value),1,0) +
                             l(Unit_net_value_1,1,0)| 
                             Firm_ID + Quarter_ID,
                           firm_data_1)
summary(model_fund_portfolio_diversity)
## OLS estimation, Dep. Var.: fund_portfolio_diversity_all
## Observations: 1,059
## Fixed-effects: Firm_ID: 63,  Quarter_ID: 20
## Standard-errors: Clustered (Firm_ID) 
##                                       Estimate Std. Error   t value Pr(>|t|)
## l(log(Net_asset_value), 1, fill = 0) -0.015827   0.007823 -2.023048 0.047386
## l(Unit_net_value_1, 1, fill = 0)     -0.004314   0.022243 -0.193931 0.846864
##                                         
## l(log(Net_asset_value), 1, fill = 0) *  
## l(Unit_net_value_1, 1, fill = 0)        
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.092706     Adj. R2: 0.578091
##                  Within R2: 0.008614