Pyrite | Level 9

## proc model optimization

Hi All,

Overall i  want to optimize my equations using Nelson Siegel  to build Hazard Rate Curves through proc model. I have a problem to define the following  equation:

HAZARDRate = Spread / (1 - RecoveryRate);

because i cannot calculate directly  HAZARDRate, i don't have a formula, so i calculate it like implied HazardRate as you can see here

``````	PROC model data=input    MAXITER=&Maxiter	CONVERGE=0.0000001	SINGULAR=0.0000001	MAXSUBIT=&Maxsubit	NOITPRINT noprint	;
Price=sum(%hr(n=65));
PARMS HazardRate;
BOUNDS HazardRate<=1;
fit PredictedPrice start=(HazardRate=0.01) /   OUTPREDICT  OUTEST=predictedhr;
run;
quit;``````

and hr defined like

``````%global j;

%macro hr(n);
%do i=1 %to &n;
%let j=%eval(&i-1);
%if &j=0 %then %do;
(real_amount&i*exp(-HazardRate*tm_d&i/365)+remainingprincipal&i*((1-exp(-HazardRate*tm_d&i/365))*RecoveryRate))*df&i,
%end;
%else %do;
(real_amount&i*exp(-HazardRate*tm_d&i/365)+remainingprincipal&i*((exp(-HazardRate*tm_d&j/365)-exp(-HazardRate*tm_d&i/365)))*RecoveryRate)*df&i,
%end;
%end;
0
%mend;``````

So how can i define this equation? Is there any way?

RecoveryRate - parameter

Thank you,

Alexey

2 REPLIES 2
SAS Employee

## Re: proc model optimization

If you want to estimate unknown parameters in PROC MODEL using nonlinear regression, you need to have an equation in the form:

y = f(x,theta) + epsilon

where y is the dependent variable, x's are the exogenous variables, theta is vector of parameters to be estimated, epsilon is the error term. Your input data should contain columns of y and x's, and you write out the equation for f(x,theta) explicitly, then specify the y variable on the FIT statement.

I am afraid it is not clear to me what your equation y = f(x, theta) + epsilon is. If you can first write out the functional form y = f(x,theta) + epsilon explicitly mathematically, then you can write out the f(x, theta) explicitly in PROC MODEL. If your goal is not to estimate parameters from nonlinear regression, then please clarify on what your objective is.

SAS Employee

## Re: proc model optimization

Alexey,

If you're new to PROC MODEL it can be difficult to know the best syntax to express your model.  I'd be happy to help if you could clarify what data you have and what you are trying to estimate.  If your data consists of many contract prices (price) then your FIT statement (ignoring extraneous options) would just be

``fit price;``

How you write out the right hand side of your price model depends on how time, discount factors, amounts (remaining and real) are represented in your INUPUT data set (e.g. what are the rows and columns in your INPUT data set).  If you can specify these details it should be possible estimate your model.

Marc

Discussion stats
• 2 replies
• 306 views
• 0 likes
• 3 in conversation