Code covered by the BSD License  

Highlights from
Modeling Variable Annuities with MATLAB

image thumbnail

Modeling Variable Annuities with MATLAB

by

 

15 Mar 2010 (Updated )

Pricing Guaranteed Minimum Withdrawal Benefit

createSurfaceFit(IGWBGrid, initSAGrid, costGrid)
function [fitresult, gof] = createSurfaceFit(IGWBGrid, initSAGrid, costGrid)
%CREATESURFACEFIT1(IGWBGRID,INITSAGRID,COSTGRID)
%  Fit surface to data.
%
%  Data for 'GMWB Cost Surface' fit:
%      X Input : IGWBGrid
%      Y Input : initSAGrid
%      Z output: costGrid
%      Weights : (none)
%
%  Output:
%      fitresult : an sfit object representing the fit.
%      gof : structure with goodness-of fit info.
%
%  See also FIT, SFIT.

%  Auto-generated by MATLAB on 07-Mar-2010 23:29:51


%% Fit: 'GMWB Cost Surface'.
ft = fittype( 'loess' );
opts = fitoptions( ft );
opts.Weights = zeros(1,0);
opts.Normalize = 'on';
[fitresult, gof] = fit( [IGWBGrid, initSAGrid], costGrid, ft, opts );

% Plot fit with data.
figure( 'Name', 'GMWB Cost Surface' );
h = plot( fitresult, [IGWBGrid, initSAGrid], costGrid );
legend( h, 'GMWB Cost Surface', 'costGrid vs. IGWBGrid, initSAGrid', 'Location', 'NorthEast' );
% Label axes
xlabel( 'IGWBGrid' );
ylabel( 'initSAGrid' );
zlabel( 'costGrid' );
grid on
view( 145.5, 24 );


Contact us