Gerber Statistic and Hierarchical Risk Parity with Factor Modelling
Want to share your content on Rbloggers? click here if you have a blog, or here if you don't.
By Nico, Yi and Chris
Portfolio Allocation
This section allocates portfolio by incorporating the Gerber Statistic, Factor Modelling, and the Hierarchical Risk Parity framework. The Gerber Statistic is aimed to improve the correlation/covariance matrix by filtering out data sets that do not move beyond a certain threshold. The HRP framework is used to allocate weightings by clustering securities based on their similarities and then enforce a risk parity among the clusters.
The steps to generate portfolio weightings for each period is as follows
 filter out the securities with available data for both security returns and factor returns
 apply crosssectional regression on security returns to generate factor betas and specific risks
 use Gerber Statistic method to generate factor covariance matrix
 combine factor betas, factor covariance matrix, and specific risks to generate the covariance and the correlation matrix for the portfolio securities
 apply the HRP framework with covariance and correlation matrices as input, generating the weightings for each security in the portfolio
 benchmark the portfolio cumulative returns against benchmark
Three different portfolios were generated to showcase the results. The three portfolios are:
 Vanilla Covariance Matrix with HRP Generated Weights
 Gerber Statistic Covariance Matrix with Minimum Variance Weights
 Gerber Statistic Covariance Matrix with HRP Generated Weights
These portfolios were then compared to the S&P 500. The date of valuation starts from January 31, 2007 due to the limited time frame of the data.
Data Description
The universe of equities selected comrpise of equities listed in the S&P 500 and NASDAQ since 2005 adjusted for survivorship bias. The data is sourced from Bloomberg. The historical data for the equities stretches back to 1990 with the backtest only begining in 2005. This is due for the need to operate within the bloomberg monthly limit, the use of multiyear averages in the factors, and the need to measure the consecutive changes accurately by providing a long enough history for the computation to provide a realistic value. Companies with a market capitalization of less than $10 million are excluded from the analysis.
The factors being analyzed are categorized into 7 groups. These include:

Traditional Value (TV)

Relative Value (RV)

Historical Growth (HG)

Profit Trends (PT)

Price Momentum (PM)

Price Reversal (PR)

Small Size (SS)
For the composition of these factor groups, please see the appendix.
Only equities that have the information to calculate all the factors in the factor groups are included in the analysis due to a lack of available data from bloomberg for every firm. This leaves us with 962 stocks at the start of the time series and ending with 1824 in the universe.
Here are the specific performances of each individual strategy:
Vanilla Covariance and HRP
Gerber and HRP
Gerber and MinimumVariance
S&P 500
Appendix
Here are the components of the factor groups:
 Traditional Value (TV)
 Price/12Month Forward Earnings Consensus Estimate. Twelvemonth forward earnings is calculated as the timeweighted average of FY1 and FY2 (the upcoming and the following fiscal yearend earnings forecasts). The weight for FY1 is the ratio of the number of days left in the year to the total number of days in a year, and the weight for FY2 is one minus the weight for FY1.
 Price/Trailing 12Month Sales. Trailing sales is computed as the sum of the quarterly sales over the last 4 quarters.
Price/Trailing 12Month Cash Flows. The trailing cash flow is computed as the sum of the quarterly cash flow over the last 4 quarters.  Dividend Yield. This is computed as the total DPS paid over the last year, divided by the current price.
 Price/Book Value. For the book value we use the last quarterly value.
 Relative Value (RV)
 IndustryRelative Price/Trailing 12Month Sales
 IndustryRelative Price/Trailing 12Month Earnings
 IndustryRelative Price/Trailing 12Month Cash Flows
 IndustryRelative Price/Trailing 12Month Sales (Current Spread vs. 5Year Average)
 IndustryRelative Price/Trailing 12Month Earnings (Current Spread vs. 5Year Average)
 IndustryRelative Price/Trailing 12Month Cash Flows (Current Spread vs. 5Year Average)
 Historical Growth (HG)
 Number of Consecutive Quarters of Positive Changes in Trailing 12Month Cash Flows (counted over the last 24 quarters). For each of the last 24 quarters we compute the trailing 12month cash flow, and then count the number of times the consecutive changes in those trailing cash flows are of the same sign from quarter to quarter, starting with the most recent quarter and going back. If the consecutive quartertoquarter changes are negative, we count each change as 1, and if they are positive we count each change as +1.
 Number of Consecutive Quarters of Positive Change in Trailing 12Month Quarterly Earnings (counted over the last 24 quarters). We calculate the trailing 12month quarterly earnings by summing up the quarterly earnings for the last 4 quarters, and compute the number of consecutive quarters in the same way as in the item above.
 12Month Change in Quarterly Cash Flows. This is the difference between the trailing 12month cash flow for the most recent quarter and the trailing 12month cash flow for the quarter exactly one year back from the most recent quarter. 3Year Average Annual Sales Growth. For each of the last 3 years we compute the 1year percentage change in sales, and then compute the 3year average of those 1year percentage changes.
 3Year Average Annual Earnings Growth. The same calculation as in the item above is done, but for earnings.
 12Quarter Trendline in Trailing 12Month Earnings. For each of the last 12 quarters we take the trailing 12 month earnings and calculate the slope of the linear trendline fitted to those 12 points, and then divide that slope by the average 12month trailing earnings across all 12 quarters.
 12Quarter Trendline in Trailing 12Month Cash Flows. This is calculated in the same way as described in the item above, but using cash flows instead of earnings.
 Profit Trends (PT)
 Number of Consecutive Quarters of Declines in (Receivables + Inventories)/Trailing 12Month Sales (counted over the last 24 quarters). We start with the most recent quarter and count back. If the consecutive quartertoquarter changes are negative, we count each change as +1, and if they are positive we count each change as 1. Receivables is calculated as the average of the receivables for this quarter and the quarter one year ago, and the inventories number is calculated similarly.
Number of Consecutive Quarters of Positive Change in Trailing 12Month Cash Flows/Trailing  12Month Sales (counted over the last 24 quarters). We start with the most recent quarter and count back. If the consecutive quartertoquarter changes are positive, we count each changeas +1, and if they are negative we count each change as 1.
 Consecutive Quarters of Declines in Trailing 12Month Overhead/Trailing 12Month Sales (counted over the last 24 quarters). We start with the most recent quarter and count back. If the consecutive quartertoquarter changes are negative, we count each change as +1, and if they are positive we count each change as 1. The trailing 12month overhead equals trailing 12 month sales minus trailing 12month COGS minus trailing 12month EBEX, where the trailing 12month values are obtained by summing the quarterly values for the last 4 quarters.
 IndustryRelative Trailing 12Month (Receivables + Inventories)/Trailing 12Month Sales. The industryrelative ratio is obtained by standardizing the underlying ratio using the mean and standard deviation of that ratio across all companies in that industry group.
 IndustryRelative Trailing 12Month Sales/Assets. The assets value is the average of the assets for this quarter and the assets for the quarter one year ago. The industryrelative ratio is obtained by standardizing the underlying ratio using the mean and standard deviation of that ratio across all companies in that industry group.
 Trailing 12Month Overhead/Trailing 12Month Sales. Trailing 12month overhead equals trailing 12month sales minus trailing 12month COGS minus trailing 12month EBEX, where the trailing 12month values are obtained by summing the quarterly values for the last 4 quarters.
 Trailing 12Month Earnings/Trailing 12Month Sales
 Number of Consecutive Quarters of Declines in (Receivables + Inventories)/Trailing 12Month Sales (counted over the last 24 quarters). We start with the most recent quarter and count back. If the consecutive quartertoquarter changes are negative, we count each change as +1, and if they are positive we count each change as 1. Receivables is calculated as the average of the receivables for this quarter and the quarter one year ago, and the inventories number is calculated similarly.
 Price Momentum (PM)
 Slope of 52Week Trendline (calculated with 20day lag) Percent Above 260Day Low (calculated with 20day lag)
 4/52Week Price Oscillator (calculated with 20day lag). This is computed as the ratio of the average weekly price over the past 4 weeks to the average weekly price over the past 52 weeks, minus 1.
 39Week Return (calculated with 20day lag)
 52Week Volume Price Trend (calculated with 20day lag).
 Price Reversal (PR)
 5Day IndustryRelative Return. This is calculated as the 5day return minus the capweighted average 5day return within that industry.
 5Day Money Flow/Volume. To obtain the numerator of this ratio, for each of the past 5 days we compute the closing price times the volume (shares traded) for that day, multiply that by 1 if that day’s return is negative, and sum those daily values. To obtain the denominator, we simply sum the closing price times the daily volume across the past 5 days (without multiplying those daily products further by 1 if the corresponding daily return is negative).
 1226 Day MACD10Day Signal Line.
 14Day RSI (RelativeStrength Index).
 20Day Lane’s Stochastic Indicator.
 4Week IndustryRelative Return. This is calculated as the 4week return minus the capweighted average 4week return within that industry.
 Small Size (SS)
 Log of Market Capitalization
 Log of Market Capitalization Cubed
 Log of Stock Price
 Log of Total Last Quarter Assets
 Log of Trailing 12Month Sales
Rbloggers.com offers daily email updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/datascience job.
Want to share your content on Rbloggers? click here if you have a blog, or here if you don't.