Path: blob/master/sandbox/GMV_analytical.R
1433 views
GMV = function (sigma) {12#'Global Minimum Variance3#'Calculates the portfolio weights in accordance with a minimum variance strategy.4#'From Goltz, F. & Lodh, A. 2013 "Scientific Beta Efficient Minimum Volatility Indices " EDHEC-Risk Institute Scientific Beta(2013)5#'@Title Global Minimum Variance6#'@author Corporate Knights Inc.: Michael Fong /email{[email protected]}, Kyle Balkissoon /email{[email protected]}7#'@param sigma = Covariance matrix of returns8#'9#'10step1 = sigma11unit_vector = c(rep(1,ncol(step1)))12# Calculate GMV portfolio weight matrix13step2 = (step1)^(-1)%*%unit_vector14step3 = as.numeric(t(unit_vector)%*%(step1)^(-1)%*%unit_vector)15step4 = step2/step316# Long-Only Adjustment - Set negative weights to zero17step5 = ifelse(step4<0,0,step4)18# Normalize Weights19step6 = step5/sum(step5)20return(step6)21}2223