<?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 portfolio optimization in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/portfolio-optimization/m-p/771816#M5683</link>
    <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;I would like to run the following optimization process with IML:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc optmodel;
	var W{1..6};

	num MVC{1..6, 1..6} = [0.00111	0.00069	0.00073	0.00053	0.00070	0.00123
		  	       0.00069	0.00081	0.00070	0.00043	0.00064	0.00117
		   	       0.00073	0.00070	0.00091	0.00050	0.00075	0.00126
		   	       0.00053	0.00043	0.00050	0.00133	0.00120	0.00185
		   	       0.00070	0.00064	0.00075	0.00120	0.00164	0.00238
		   	       0.00123	0.00117	0.00126	0.00185	0.00238	0.00430];
	num E{1..6} = [0.00690 0.00360 0.00138 -0.00169 0.00436 -0.01439];
	num Var_Rm = 0.001483;

	maximize Expected = sum{i in 1..6}W[i]*E[i];
	con sum{i in 1..6, j in 1..6}W[i]*MVC[i,j]*W[j] = Var_Rm;
	con BUDGET: sum{i in 1..6}W[i] = 1;

	solve; print W;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Ideally something simple in a first time like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
MVC = { 0.00111	0.00069	0.00073	0.00053	0.00070	0.00123
	    0.00069	0.00081	0.00070	0.00043	0.00064	0.00117
	    0.00073	0.00070	0.00091	0.00050	0.00075	0.00126
	    0.00053	0.00043	0.00050	0.00133	0.00120	0.00185
	    0.00070	0.00064	0.00075	0.00120	0.00164	0.00238
	    0.00123	0.00117	0.00126	0.00185	0.00238	0.00430 };
e = { 0.00690 0.00360 0.00138 -0.00169 0.00436 -0.01439 }
Var_Rm = { 0.001483 };

start max(w);
	w = p`; /* Transpose w into a colum vector, the NLP routines passing in a row vector as the parameter */
   return e * w;
finish;

/* specify linear constraints ????  */
con w` * MVC * w = Var_Rm;
con sum(w) = 1;

w0 = {0.17 0.17 0.17 0.17 0.17 0.15};
optn = { ?????? }

call nlpnra(rc, w_Opt, "max", w0, optn, con);
maxVal = max(w_Opt);

print w_Opt;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you in advance for any help,&lt;/P&gt;</description>
    <pubDate>Sun, 03 Oct 2021 13:59:19 GMT</pubDate>
    <dc:creator>Alain38</dc:creator>
    <dc:date>2021-10-03T13:59:19Z</dc:date>
    <item>
      <title>portfolio optimization</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/portfolio-optimization/m-p/771816#M5683</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;I would like to run the following optimization process with IML:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc optmodel;
	var W{1..6};

	num MVC{1..6, 1..6} = [0.00111	0.00069	0.00073	0.00053	0.00070	0.00123
		  	       0.00069	0.00081	0.00070	0.00043	0.00064	0.00117
		   	       0.00073	0.00070	0.00091	0.00050	0.00075	0.00126
		   	       0.00053	0.00043	0.00050	0.00133	0.00120	0.00185
		   	       0.00070	0.00064	0.00075	0.00120	0.00164	0.00238
		   	       0.00123	0.00117	0.00126	0.00185	0.00238	0.00430];
	num E{1..6} = [0.00690 0.00360 0.00138 -0.00169 0.00436 -0.01439];
	num Var_Rm = 0.001483;

	maximize Expected = sum{i in 1..6}W[i]*E[i];
	con sum{i in 1..6, j in 1..6}W[i]*MVC[i,j]*W[j] = Var_Rm;
	con BUDGET: sum{i in 1..6}W[i] = 1;

	solve; print W;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Ideally something simple in a first time like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
MVC = { 0.00111	0.00069	0.00073	0.00053	0.00070	0.00123
	    0.00069	0.00081	0.00070	0.00043	0.00064	0.00117
	    0.00073	0.00070	0.00091	0.00050	0.00075	0.00126
	    0.00053	0.00043	0.00050	0.00133	0.00120	0.00185
	    0.00070	0.00064	0.00075	0.00120	0.00164	0.00238
	    0.00123	0.00117	0.00126	0.00185	0.00238	0.00430 };
e = { 0.00690 0.00360 0.00138 -0.00169 0.00436 -0.01439 }
Var_Rm = { 0.001483 };

start max(w);
	w = p`; /* Transpose w into a colum vector, the NLP routines passing in a row vector as the parameter */
   return e * w;
finish;

/* specify linear constraints ????  */
con w` * MVC * w = Var_Rm;
con sum(w) = 1;

w0 = {0.17 0.17 0.17 0.17 0.17 0.15};
optn = { ?????? }

call nlpnra(rc, w_Opt, "max", w0, optn, con);
maxVal = max(w_Opt);

print w_Opt;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you in advance for any help,&lt;/P&gt;</description>
      <pubDate>Sun, 03 Oct 2021 13:59:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/portfolio-optimization/m-p/771816#M5683</guid>
      <dc:creator>Alain38</dc:creator>
      <dc:date>2021-10-03T13:59:19Z</dc:date>
    </item>
    <item>
      <title>Re: portfolio optimization</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/portfolio-optimization/m-p/771890#M5684</link>
      <description>&lt;P&gt;The constraint on the variance is not a linear constraint. It is quadratic. Therefore, you have to use a user-defined function module for that constraint. You can use a GLOBAL clause for the MVC and Var_Rm parameters and compute the constraint as&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;conVar = w * MVC * w` - Var_Rm;&amp;nbsp; /* constrain this eqn to 0 */&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Because you have a nonlinear constraint, you need to use the NLPQN (quasi-Newton) method instead of the Newton-Raphson function in your original post.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The SAS/IML documentation has a four-parameter example that is similar to your six-parameter problem. See the Getting Started example for &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_013/imlug/imlug_nonlinearoptexpls_sect005.htm" target="_self"&gt;the "Rosen-Suzuki Problem."&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In addition to the linear constraint sum(w)=1, you should also specify the bounds&amp;nbsp; 0 &amp;lt;= w[i] &amp;lt;= 1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Oct 2021 10:25:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/portfolio-optimization/m-p/771890#M5684</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2021-10-04T10:25:27Z</dc:date>
    </item>
    <item>
      <title>Re: portfolio optimization</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/portfolio-optimization/m-p/771910#M5685</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; already gave you an example , in IML there is an build-in function can solve this kind of question.&lt;/P&gt;
&lt;P&gt;Or check&amp;nbsp; my paper :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"Get Tangency Portfolio by SAS/IML"&lt;BR /&gt;&lt;A href="http://support.sas.com/resources/papers/proceedings17/0997-2017.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings17/0997-2017.pdf&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Oct 2021 11:39:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/portfolio-optimization/m-p/771910#M5685</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-10-04T11:39:25Z</dc:date>
    </item>
  </channel>
</rss>

