Question: Is there a way to use the "fmincon()" function in Matlab with ppform objects or to convert the ppform object into a function handle? Or even another way to smooth a function that will allow me to minimize it after the smoothing?
I am trying to build a script on Matlab to compute a mean-VaR efficient frontier. To do that I need to minimize the portfolio Value at Risk for a given value of expected return of the portfolio; the main issue is that the Value at Risk, seen as a function of the portfolio wights, is a very irregular non-convex function. Because of the features of the VaR function, one needs to smooth it first, and only then it is possible to do the minimization process.
In order to smooth the function I tried using a cuibic spline, using the Matlab function called "csaps()", available in the curve fitting toolbox. Once the smoothed function is computed I can also plot it using the "fnplot()" function; the main issue is that the format of the output of the "csaps()" function is a "struct" object (precisely it's a ppform object) and not a "function handle", which means that functions like "fmincon()" cannot be used to minimize it.
`
r1 = rand(100);
r2 = rand(100);
%r1 and r2 are dummy variable (they should be asset returns)
alpha = 0.05;
q = zeros(length(0:0.01:1),1);
lambda = 0:0.01:1;
i = 1;
for l = 0:0.01:1
rend = l*r1 + (1-l)*r2;
q(i) = -quantile(rend,alpha);
i = i+1;
end
s99 = csaps(lambda,q,.9999); %requires curve fitting toolbox
%this comand produces the ppform object
hold on
plot(lambda,q)
fnplt(s99)
legend("base function", "smoothed function")
hold off
[x] = fmincon(s99,x0,A,b,Aeq,beq,lb,ub);
%I need to transform the ppform object (s99) into a function
%handle, this way I can use fmincon() to minimize it
`