<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Regression with positive coefficients sum up to 1 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Regression-with-positive-coefficients-sum-up-to-1/m-p/671827#M201798</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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:&lt;/P&gt;&lt;PRE&gt;portfolio returns = coef1 * index_returns1 + coef2 * index_returns2 + ... + intercept
sum of coefficients should be 1
all coefficients should be positive or equal to 0&lt;/PRE&gt;&lt;P&gt;I tried to used the following piece of code, inspired from &lt;A href="http://support.sas.com/kb/22/642.html:" target="_blank"&gt;http://support.sas.com/kb/22/642.html:&lt;/A&gt;&lt;/P&gt;&lt;PRE&gt;proc model data=work.temp3;
	parameters a b c d e f g;
	bounds a&amp;gt;=0, b&amp;gt;=0, c&amp;gt;=0, d&amp;gt;=0, e&amp;gt;=0, f&amp;gt;=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;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot from 2020-07-23 16-57-13.png" style="width: 524px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47598i90D370341C9F06B2/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot from 2020-07-23 16-57-13.png" alt="Screenshot from 2020-07-23 16-57-13.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;But the results are very very strange and they don't even respect the constraints. What would be the right approach?&lt;/P&gt;&lt;P&gt;I also uploaded the dataset if you need it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 23 Jul 2020 14:05:30 GMT</pubDate>
    <dc:creator>littlewho</dc:creator>
    <dc:date>2020-07-23T14:05:30Z</dc:date>
    <item>
      <title>Regression with positive coefficients sum up to 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regression-with-positive-coefficients-sum-up-to-1/m-p/671827#M201798</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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:&lt;/P&gt;&lt;PRE&gt;portfolio returns = coef1 * index_returns1 + coef2 * index_returns2 + ... + intercept
sum of coefficients should be 1
all coefficients should be positive or equal to 0&lt;/PRE&gt;&lt;P&gt;I tried to used the following piece of code, inspired from &lt;A href="http://support.sas.com/kb/22/642.html:" target="_blank"&gt;http://support.sas.com/kb/22/642.html:&lt;/A&gt;&lt;/P&gt;&lt;PRE&gt;proc model data=work.temp3;
	parameters a b c d e f g;
	bounds a&amp;gt;=0, b&amp;gt;=0, c&amp;gt;=0, d&amp;gt;=0, e&amp;gt;=0, f&amp;gt;=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;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot from 2020-07-23 16-57-13.png" style="width: 524px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47598i90D370341C9F06B2/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot from 2020-07-23 16-57-13.png" alt="Screenshot from 2020-07-23 16-57-13.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;But the results are very very strange and they don't even respect the constraints. What would be the right approach?&lt;/P&gt;&lt;P&gt;I also uploaded the dataset if you need it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jul 2020 14:05:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regression-with-positive-coefficients-sum-up-to-1/m-p/671827#M201798</guid>
      <dc:creator>littlewho</dc:creator>
      <dc:date>2020-07-23T14:05:30Z</dc:date>
    </item>
    <item>
      <title>Re: Regression with positive coefficients sum up to 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regression-with-positive-coefficients-sum-up-to-1/m-p/671906#M201832</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/333001"&gt;@littlewho&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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:&lt;/P&gt;
&lt;PRE&gt;portfolio returns = coef1 * index_returns1 + coef2 * index_returns2 + ... + intercept
sum of coefficients should be 1
all coefficients should be positive or equal to 0&lt;/PRE&gt;
&lt;P&gt;I tried to used the following piece of code, inspired from &lt;A href="http://support.sas.com/kb/22/642.html:" target="_blank" rel="noopener"&gt;http://support.sas.com/kb/22/642.html:&lt;/A&gt;&lt;/P&gt;
&lt;PRE&gt;proc model data=work.temp3;
	parameters a b c d e f g;
	bounds a&amp;gt;=0, b&amp;gt;=0, c&amp;gt;=0, d&amp;gt;=0, e&amp;gt;=0, f&amp;gt;=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;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot from 2020-07-23 16-57-13.png" style="width: 524px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47598i90D370341C9F06B2/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot from 2020-07-23 16-57-13.png" alt="Screenshot from 2020-07-23 16-57-13.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;But the results are very very strange and they don't even respect the constraints. What would be the right approach?&lt;/P&gt;
&lt;P&gt;I also uploaded the dataset if you need it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that the Bounds you set allow for a, b, c etc to be between 0 and 1 since the bound was &amp;gt;= 0.&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jul 2020 17:47:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regression-with-positive-coefficients-sum-up-to-1/m-p/671906#M201832</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-07-23T17:47:29Z</dc:date>
    </item>
    <item>
      <title>Re: Regression with positive coefficients sum up to 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regression-with-positive-coefficients-sum-up-to-1/m-p/672064#M201907</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp; Wrote a blog about it . some PROC like proc reg/hpglm/genmod can do that.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jul 2020 12:05:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regression-with-positive-coefficients-sum-up-to-1/m-p/672064#M201907</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-07-24T12:05:08Z</dc:date>
    </item>
  </channel>
</rss>

