BookmarkSubscribeRSS Feed
littlewho
Fluorite | Level 6

Hello,

 

I have a dataset consisting of quarterly returns of a portfolio and of some market indexes over a period of time. I am trying to fit a regression model that looks like this:

portfolio returns = coef1 * index_returns1 + coef2 * index_returns2 + ... + intercept
sum of coefficients should be 1
all coefficients should be positive or equal to 0

I tried to used the following piece of code, inspired from http://support.sas.com/kb/22/642.html:

proc model data=work.temp3;
	parameters a b c d e f g;
	bounds a>=0, b>=0, c>=0, d>=0, e>=0, f>=0;
	restrict a+b+c+d+e+f=1;
	
	qret=a*growth_WILLLRGCAPGR + b*growth_WILLLRGCAPVAL + c*growth_WILLMIDCAPGR + 
		d*growth_WILLMIDCAPVAL + e*growth_WILLSMLCAPGR + f*growth_WILLSMLCAPVAL + g;
	fit qret;
quit;

Screenshot from 2020-07-23 16-57-13.png

But the results are very very strange and they don't even respect the constraints. What would be the right approach?

I also uploaded the dataset if you need it. 

 

Thanks!

 

2 REPLIES 2
ballardw
Super User

@littlewho wrote:

Hello,

 

I have a dataset consisting of quarterly returns of a portfolio and of some market indexes over a period of time. I am trying to fit a regression model that looks like this:

portfolio returns = coef1 * index_returns1 + coef2 * index_returns2 + ... + intercept
sum of coefficients should be 1
all coefficients should be positive or equal to 0

I tried to used the following piece of code, inspired from http://support.sas.com/kb/22/642.html:

proc model data=work.temp3;
	parameters a b c d e f g;
	bounds a>=0, b>=0, c>=0, d>=0, e>=0, f>=0;
	restrict a+b+c+d+e+f=1;
	
	qret=a*growth_WILLLRGCAPGR + b*growth_WILLLRGCAPVAL + c*growth_WILLMIDCAPGR + 
		d*growth_WILLMIDCAPVAL + e*growth_WILLSMLCAPGR + f*growth_WILLSMLCAPVAL + g;
	fit qret;
quit;

Screenshot from 2020-07-23 16-57-13.png

But the results are very very strange and they don't even respect the constraints. What would be the right approach?

I also uploaded the dataset if you need it. 

 

Thanks!

 


 

Note that the Bounds you set allow for a, b, c etc to be between 0 and 1 since the bound was >= 0.

And the values like 1.54E-33 are so small that for most calculations they are essentially 0. You might find that 1 for B was actually something like 0.999999999999 that is displayed in a format that forced rounding to 0. I suggest generating an output data set of the estimates and looking at the values with a wider format. And then use that data set to sum the value for a - f and see what SAS shows there.

 

I might also suggest looking at the range of values of your other variables. It may be that the range of values is such that your "model" is dominated by one or two variables. Do the diagnostics tell that a number of records were dropped? If one or more of your growth variables is missing from a portfolio it is very likely that record was not used in the model. So the remaining records may be "odd" from your perspective.

 

Ksharp
Super User

@Rick_SAS  Wrote a blog about it . some PROC like proc reg/hpglm/genmod can do that.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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