Visualizing MSE and Shrinkage
Now let’s create a graph for both of the estimations first for error and then for shrinkage. Here, graphs for the comparison between Ledoit-Wolf and OAS have been plotted in the factor of MSE and shrinkage accordingly.
Python3
# plotting Mean Square Error(MSE) # error plotting for Ledoit-Wolf plt.subplot( 2 , 1 , 1 ) plt.errorbar( numOfSamplesRange, ledoitWolf_mse.mean( 1 ), yerr = ledoitWolf_mse.std( 1 ), label = "Ledoit-Wolf" , color = "yellow" , lw = 2 , ) # error plotting for OAS coefficient plt.errorbar( numOfSamplesRange, oas_mse.mean( 1 ), yerr = oas_mse.std( 1 ), label = "OAS" , color = "green" , lw = 2 , ) plt.ylabel( "Squared error" ) plt.legend(loc = "upper right" ) plt.title( "Comparison of covariance estimators(Ledoit-Wolf vs OAS)" ) plt.xlim( 2 , 32 ) plt.show() |
Output:
Python3
# plot Shrinkage coefficient # Shrinkage plotting for Ledoit-Wolf plt.subplot( 2 , 1 , 2 ) plt.errorbar( numOfSamplesRange, ledoitWolf_shrinkage.mean( 1 ), yerr = ledoitWolf_shrinkage.std( 1 ), label = "Ledoit-Wolf" , color = "yellow" , lw = 2 , ) # Shrinkage plotting for OAS coefficient plt.errorbar( numOfSamplesRange, oas_shrinkage.mean( 1 ), yerr = oas_shrinkage.std( 1 ), label = "OAS" , color = "green" , lw = 2 , ) plt.xlabel( "number of samples" ) plt.ylabel( "Shrinkage counting" ) plt.legend(loc = "lower right" ) plt.ylim(plt.ylim()[ 0 ], 1.0 + (plt.ylim()[ 1 ] - plt.ylim()[ 0 ]) / 10.0 ) plt.xlim( 2 , 32 ) plt.show() |
Output:
Ledoit-Wolf vs OAS Estimation in Scikit Learn
Generally, Shrinkage is used to regularize the usual covariance maximum likelihood estimation. Ledoit and Wolf proposed a formula which is known as the Ledoit-Wolf covariance estimation formula; This close formula can compute the asymptotically optimal shrinkage parameter with minimizing a Mean Square Error(MSE) criterion feature. After that, one researcher Chen et al. made improvements in the Ledoit-Wolf Shrinkage parameter. He proposed Oracle Approximating Shrinkage (OAS) coefficient whose convergence is significantly better under the assumption that the data are Gaussian.
There are some basic concepts are needed to develop the Ledoit-Wolf estimators given below step by step: