Code covered by the BSD License  

Highlights from
Response Surface Models of Drug Interactions with Curve Fitting Toolbox

image thumbnail

Response Surface Models of Drug Interactions with Curve Fitting Toolbox

by

 

20 Mar 2009 (Updated )

"Response Surface Models of Drug Interactions with Curve Fitting Toolbox" webinar demo files

createSurfaceFits(Propofol, Remifentanil, Algometry)
function [fitresult, gof] = createSurfaceFits(Propofol, Remifentanil, Algometry)
%CREATESURFACEFITS(PROPOFOL,REMIFENTANIL,ALGOMETRY)
%  Fit surfaces to data.
%
%  Data for 'LOWESS' fit:
%      X Input : Propofol
%      Y Input : Remifentanil
%      Z output: Algometry
%      Weights : (none)
%
%  Data for 'Custom Model' fit:
%      X Input : Propofol
%      Y Input : Remifentanil
%      Z output: Algometry
%      Weights : (none)
%
%  Output:
%      fitresult : a cell-array of sfit objects representing the fits.
%      gof : structure array with goodness-of fit info.
%
%  See also FIT, SFIT.

%  Auto-generated by MATLAB on 17-Mar-2009 17:55:58

%  Copyright 2009, The MathWorks, Inc.

% Initialize arrays to store fits and goodness-of-fit.
fitresult = cell( 2, 1 );
gof = struct( 'sse', cell( 2, 1 ), ...
    'rsquare', [], 'dfe', [], 'adjrsquare', [], 'rmse', [] );

%% Fit: 'LOWESS'.
ft = fittype( 'lowess' );
opts = fitoptions( ft );
opts.Span = 0.4;
opts.Weights = zeros(1,0);
opts.Normalize = 'on';
[fitresult{1}, gof(1)] = fit( [Propofol, Remifentanil], Algometry, ft, opts );

% Create a figure for the plots.
figure( 'Name', 'LOWESS' );

% Plot fit with data.
subplot( 2, 1, 1 );
h = plot( fitresult{1}, [Propofol, Remifentanil], Algometry );
grid on
% Label axes
xlabel( 'Propofol' );
ylabel( 'Remifentanil' );
zlabel( 'Algometry' );
legend( h, 'LOWESS', 'Algometry vs. Propofol, Remifentanil', 'Location', 'NorthEast' );
view( -73.5, 26 );

% Plot residuals.
subplot( 2, 1, 2 );
h = plot( fitresult{1}, [Propofol, Remifentanil], Algometry, 'Style', 'Residual' );
grid on
% Label axes
xlabel( 'Propofol' );
ylabel( 'Remifentanil' );
zlabel( 'Algometry' );
legend( h, 'LOWESS - residuals', 'Location', 'NorthEast' );
view( -31.5, 2 );

%% Fit: 'Custom Model'.
ft = fittype( 'combinedEffect(x,y, IC50A, IC50B, alpha, n)', 'indep', {'x', 'y'}, 'depend', 'z' );
opts = fitoptions( ft );
opts.Display = 'Off';
opts.Lower = [0 0 -Inf -Inf];
opts.StartPoint = [0.819245961226993 0.121341114747929 0.482001197242532 0.434543887431172];
opts.Upper = [Inf Inf Inf Inf];
opts.Weights = zeros(1,0);
[fitresult{2}, gof(2)] = fit( [Propofol, Remifentanil], Algometry, ft, opts );

% Create a figure for the plots.
figure( 'Name', 'Custom Model' );

% Plot fit with data.
subplot( 2, 1, 1 );
h = plot( fitresult{2}, [Propofol, Remifentanil], Algometry );
grid on
% Label axes
xlabel( 'Propofol' );
ylabel( 'Remifentanil' );
zlabel( 'Algometry' );
legend( h, 'Custom Model', 'Algometry vs. Propofol, Remifentanil', 'Location', 'NorthEast' );

% Make contour plot.
subplot( 2, 1, 2 );
h = plot( fitresult{2}, [Propofol, Remifentanil], Algometry, 'Style', 'Contour' );
grid on
% Label axes
xlabel( 'Propofol' );
ylabel( 'Remifentanil' );
legend( h, 'Custom Model', 'Algometry vs. Propofol, Remifentanil' );


Contact us