BookmarkSubscribeRSS Feed
jserby
Calcite | Level 5

Hello! I have found the message board helpful in the past and wanted to reach out now. 

 

I am trying to do an M-factor approach (or Z-factor some places) that uses a merton model framework for markov transitions in the rating space. 

 

The approach requires fitting a parameter M in the following equation

  

(probnorm((Std_norm_av_cum_P - sqrt(&rho.)*M)/(1-&rho.)) - Std_norm_cum_P

 

Where rho is a chosen correlation established as a fixed value outside the model; Std_norm_av_cum_P is the long term transition probabilities, and Std_norm_cum_P is the current time period transitions.

 

I was able to run proc model using OLS to determine M using the following model.

proc model data=R_&y._&q._set   OUTPARMS=M_rho_Initial_&y._&q. ;
	parms M ;
	label M='M_factor_t' ;
		Std_norm_cum_P = probnorm((Std_norm_av_cum_P - sqrt(&rho.)*M)/(1-&rho.)) ;
	
	fit Std_norm_cum_P ;
run;
quit;

The matrix analyzed here is a 7X7 matrix.

 

However, the model needs to actually minimize using the system demonstrated in the chart which is attached. The system multiples by the outer matrices which are the Count by starting rating level and the long term PD by end rating level. These values are available in other datasets (both are 7X1 matrices).

I just do not know how to multiply them within the Proc Model statement.

 

I tried bringing in all three datasets view the data step, then I tried manually creating the arrays (although, admittedly, I am not good at using arrays and that may be the solution, but I do not know how to do it). The following code is where I ended up and it is not working:

proc model data=R_&y._&q._set   OUTPARMS=M_rho_Initial_&y._&q. ;
	parms M ;
	exogenous M;
	label M='M_factor_t' ;
	Array count_ARRAY {7} c1-c7 ( &Count_list. );
	Array PD_1_yr_ARRAY {7} p1-p7 ( &PD_1_yr_list. );

		eq.Esq = (count_ARRAY{1-7} * ((probnorm((Std_norm_av_cum_P - sqrt(&rho.)*M)/(1-&rho.)) - Std_norm_cum_P)*PD_1_yr_ARRAY{1-7})**2;
	/* WEIGHT */
	solve M ;
run;
quit;

Where &Count_list.  are the counts by rating level and &PD_1_yr_list. are the long term PDs by rating level. As you can see I am trying to matrix multiply using the arrays and it is not working.

 

Can anyone help out with how to do this?

 

Using SAS 9.4 and do not have Proc Optmodel

 

2 REPLIES 2
Reeza
Super User
I don't know enough about what you're doing to offer a solution, but you are definitely referencing your arrays incorrectly.

You can read up this short tutorial if you'd like:
https://stats.idre.ucla.edu/sas/seminars/sas-arrays/

I suspect you need to loop and then add or sum those values throughout but like I said, I don't understand what you need here.

Good Luck.
jserby
Calcite | Level 5

Thank you. I tried revising with Arrays to try the matrix muliplication and found that I am still hitting a wall. See the code below for the change. 

 

proc model data=R_&y._&q._set2   OUTPARMS=M_rho_Initial_&y._&q. ;
	parms M ;
	exogenous M;
	label M='M_factor_t' ;
	array current [7] End_1-End_7;
	array long [7] Endl_1-Endl_7;
	array Scaled [7] scale_1-scale_7;
	Bounds -1 <= M <=1;
	
			
		eq.Esq = COUNT*(
					(   (  ( probnorm((long[1] - sqrt(&rho.)*M)/sqrt(1-&rho.)) - current[1] )**2  )*Scaled[1]   )+
					(   (  ( probnorm((long[2] - sqrt(&rho.)*M)/sqrt(1-&rho.)) - current[2] )**2  )*Scaled[2]   )+
					(   (  ( probnorm((long[3] - sqrt(&rho.)*M)/sqrt(1-&rho.)) - current[3] )**2  )*Scaled[3]   )+
					(   (  ( probnorm((long[4] - sqrt(&rho.)*M)/sqrt(1-&rho.)) - current[4] )**2  )*Scaled[4]   )+
					(   (  ( probnorm((long[5] - sqrt(&rho.)*M)/sqrt(1-&rho.)) - current[5] )**2  )*Scaled[5]   )+
					(   (  ( probnorm((long[6] - sqrt(&rho.)*M)/sqrt(1-&rho.)) - current[6] )**2  )*Scaled[6]   )+
					(   (  ( probnorm((long[7] - sqrt(&rho.)*M)/sqrt(1-&rho.)) - current[7] )**2  )*Scaled[7]   )
			);
	
	solve M ;
run;
quit;

I am multiplying through the Matrices and getting the following error:

 

 

ERROR: The Newton method Jacobian matrix of partial derivatives of the
       equations with respect to the variables to be solved is singular
       at observation 1, for iteration 2. The system of equations cannot
       be solved.

I have set this up such that the sum of squared errors is fit on the multiplied matrices, but the matrix should multiply to a single summed value instead of a column; I do not think this is where the issue is.

 

I could use further guidance on the Proc Model use and steps, as well as input on the approach, if any help can be provided.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1115 views
  • 0 likes
  • 2 in conversation