% FRONTIER.M
% Generates 3-D Investment Opportunity Set for 3 
%   assets whose returns are skew-stable with a common
%   value of alpha.
% Written by J. Huston McCulloch, Economics Dept., 
%   Ohio State Univ., mcculloch.2@osu.edu, 2/97.
% See http://www.econ.ohio-state.edu/jhm/ios.html
%   for explanation and motivation.

clear
% Set common value of alpha:
alpha = 1.8;
% Set assorted parameter values for the 3 assets:
beta = [-1, 1, 0];
c = [3, 4, 5];
delta = [8, 6, 10];

% The interval [0,1] is divided into m sub-intervals,
%   bounded by m+1 values of t.
m = 100;
t = 0:(1/m):1;

% Create m+1 portfolios mixing assets 2 and 3 in 
%   the proportions (1-t) and t:
d2 = delta(2);
d3 = delta(3);
c2 = c(2);
c3 = c(3);
b2 = beta(2);
b3 = beta(3);
z = (1-t)*d2 + t*d3;
x = ((1-t)*c2).^alpha + (t*c3).^alpha;
y = (((1-t)*c2).^alpha)*b2 + ((t*c3).^alpha)*b3;
y = y ./ x;
x = x .^ (1/alpha);

% Mix asset 1 with each each of the above portfolios, again in 
%   each of the m+1 proportions ((1-t), t).
% These go into vectors xx, etc, and then these are concatenated 
%   into matrices xa, etc.

d1 = delta(1);
c1 = c(1);
b1 = beta(1);
xa = [];
ya = [];
za = [];
for i = 1: m+1,
disp(i)     % (count on-screen to show progress)
% d2 etc give the parameters of the "second" asset, which here is 
%   in fact a portfolio of assets 2 and 3.
d2 = z(i);
c2 = x(i);
b2 = y(i);
zz = (1-t)*d1 + t*d2;
xx = ((1-t)*c1).^alpha + (t*c2).^alpha;
yy = (((1-t)*c1).^alpha)*b1 + ((t*c2).^alpha)*b2;
yy = yy ./ xx;
xx = xx .^ (1/alpha);
xa = [xa ; xx(1,:)];
ya = [ya ; yy(1,:)];
za = [za ; zz(1,:)];
end

% Plot the resulting surface with side lighting from direction s:
s = [-110,30]
surfl(xa',ya',za',s)
title(['Investment Opportunity Set; Alpha = ', num2str(alpha)]);
xlabel ('scale c')
ylabel('skewness beta')
zlabel('mean delta')
shading flat
view(-20,30)
colormap hot

% Colormap cool is also nice.  Colormap copper prints out well
%   on white paper.  Spinmap(30,1) creates dramatic effects.
% These can be invoked from the command window while the figure 
%   is in the Figure window, if the windows have been sized 
%   and positioned appropriately.

% View(-20,30) is the best 3d perspective.  
% View(0,0) gives the side view from the -beta direction, 
%   and looks much like a conventional IOS.
% View(-90,0) gives the front view from the -c direction.
% View(0,90) gives the top view, from the +delta direction.

% END FRONTIER.M


