How does the function quadprog() work?

2 views (last 30 days)
Pauline van Straten
Pauline van Straten on 27 May 2015
Edited: Pauline van Straten on 27 May 2015
Hi all, I have tried many things but the definitions for the input of the function quadprog() is different at different sources. Can somebody help me how I should use this function?
I defined the nr of assets. input_matrix equals the covariance matrix. And the mu_matrix the expected return. Both matrices with daily data. The inverse of the covariance matrix. The expected return of each asset daily which is also a matrix. nr_assets=k;
T= size(input_matrix,1);
weight_matrix=zeros(T,nr_assets);
i_vector = ones(k,1);
for i = 1:T
data_i = input_matrix(i,:);
cov_matrix_i = Vech2Sym(k,data_i);
mu_vector_i = mu_matrix (i,:)';
inverse_cov_matrix_i = inv(cov_matrix_i);
With these data I created 3different matrices:
A= i_vector' * inverse_cov_matrix_i*i_vector;
B= i_vector' * inverse_cov_matrix_i*mu_vector_i;
C=mu_vector_i'*inverse_cov_matrix_i*mu_vector_i;
And weight_1 = (C-q*B)/(A*C-B^2)
weight_2 = (q*A-B) / (A*C-B^2);
weight_matrix(i,:) = quadprog (inverse of covariance matrix, ???,???, ???,1,0,1). lb =0 because no short selling aloud.
(I also defined a function which puts vech of A into A. )
Is anyone able to help me? All help is appreciated.
--
Student

Answers (0)

Categories

Find more on Physics in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!