Let's say I have the tracking error calculation for a portfolio:
How would I determine the N-obervations required for a statistically significant tracking error? Alternatively, how would I determine if the tracking error itself were statistically significant?
Some illustrative code here
import statsmodels.stats.moment_helpers as mh import pandas as pd import numpy as np def generate_correlated_random_return_matrix(annual_means, annual_vols, corr, t_periods, n_samples, period_adjust=12.): """ Generates a return matrix from a multivariate random normal distribution. **Args**: *annual_means*: An array of mean annual returns. *annual_vols*: An array of annual vols. *corr*: Correlation matrix. An example being: >>> [[1,0],[0,1]] *t_periods*: How many months would you like to simulate? n_samples**: How many times do you want to run this simulation? """ means = np.divide(annual_means, period_adjust) vols = np.divide(annual_vols, period_adjust ** .5) cov = np.asmatrix(mh.corr2cov(corr, vols), float) sim_array = np.random.multivariate_normal(means, cov, [n_samples, t_periods]) return sim_array te_tests = generate_correlated_random_return_matrix(annual_means=[.03,.03],annual_vols=[.1,.1],corr=[[1,.8],[.8,1]],t_periods=10000,n_samples=1) df = pd.DataFrame(te_tests) expanding_te = pd.expanding_std(df - df) mu = (df - df).std() true_te = (df - df).std() vol_of_expanding_TE = expanding_te.std() z_score_of_TE_at_obs_N = ((expanding_te - true_te)/vol_of_expanding_TE).plot()
This I guess would give me a way to state the "measured TE is statistically indistinguishable from the
TRUE TE", I suppose. Unsure if what I am using as standard deviation is correct, though.