<?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 Re: portfolio optimization under higher moments (skewness-kurtosis) in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/portfolio-optimization-under-higher-moments-skewness-kurtosis/m-p/300107#M3018</link>
    <description>&lt;P&gt;You can implement triple-nested DO loops if you want to implement the summation formula, but the second line gives the matrix formula, which will be much easier and faster to compute.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assuming that the weight vector is a column vector, the objective function is the matrix product w`*M3*(w@w), where w@w is &lt;A href="http://blogs.sas.com/content/iml/2014/12/08/direct-product-kronecker-product.html" target="_self"&gt;the Kronecker product:&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
M3 = {32 -7 -7 -8,
      -7 -8 -8 17};

start skpf(w) global(M3);   /* w is column vector */
   return w` * M3 * (w@w);
finish;

w = {0.2, 0.8};  /* w is column vector */
v = skpf(w);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I assume that the sum of the weights is unity. If so, then you need to include an constaint when you optimize because there is really only N-1 parameters: &amp;nbsp;w[n] = 1 - (w[1] + w[2] + ... + w[n-1]).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In particular, for your example where N=2, you get the following graph of the objective function. Notice that the maximum is on the boundary for this example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/5016i5F48320E646C4476/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="sgplot.png" title="sgplot.png" /&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 22 Sep 2016 13:34:42 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2016-09-22T13:34:42Z</dc:date>
    <item>
      <title>portfolio optimization under higher moments (skewness-kurtosis)</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/portfolio-optimization-under-higher-moments-skewness-kurtosis/m-p/300100#M3017</link>
      <description>&lt;DIV class="lia-quilt-column lia-quilt-column-04 lia-quilt-column-left lia-quilt-column-main-left"&gt;&lt;DIV class="lia-quilt-column-alley lia-quilt-column-alley-left"&gt;&lt;DIV class="lia-message-author lia-component-author"&gt;&lt;DIV class="lia-message-author-post-count"&gt;Posts: 2&lt;/DIV&gt;&lt;DIV class="lia-message-author-ipaddress"&gt;Hello dears,&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="lia-quilt-column lia-quilt-column-20 lia-quilt-column-right lia-quilt-column-main-right"&gt;&lt;DIV class="lia-quilt-column-alley lia-quilt-column-alley-right"&gt;&lt;DIV class="lia-message-body lia-component-body"&gt;&lt;DIV class="lia-message-body-content"&gt;&lt;P&gt;knowing that the variance of portfolio is as follow:&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/5013i4384AD9DFC881849/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="variance portfolio.png" title="variance portfolio.png" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I just set a program of&amp;nbsp;minimization of portfolio variance&amp;nbsp;where the objective function is as follow:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;min f = (sum{i in N}(sum{j in N}(w[i]*var[i,j]*w[j])));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;var[i,j] is the covariance between i and j.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;and wi are decison variables (optimal weight)&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, I 'm trying to maximize the skewness of portfolio&amp;nbsp;&lt;/P&gt;&lt;P&gt;I calculated&amp;nbsp;the matrix&amp;nbsp;of&amp;nbsp;skewness co-skewness of assets returns.&amp;nbsp;But&amp;nbsp;I can not&amp;nbsp;express&amp;nbsp;the objective function&amp;nbsp;as it contains&amp;nbsp;a&amp;nbsp;triple&amp;nbsp;sum.&amp;nbsp;it&amp;nbsp;is&amp;nbsp;having the following forms.&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/5011i903DA19B7C3BF676/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="sskk.png" title="sskk.png" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where wi are &lt;STRONG&gt;&lt;U&gt;decision variables&lt;/U&gt;&lt;/STRONG&gt; (vector of optimal weights to invest in each asset).&lt;/P&gt;&lt;P&gt;and sijk are assets (i,j,k)coskewness&lt;/P&gt;&lt;P&gt;W is the vector of weghts&amp;nbsp;&lt;/P&gt;&lt;P&gt;M3 is the skewenss co-skewness matrix&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/5014iF12C56081B3A4472/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="matrice de skewness co-skewness.png" title="matrice de skewness co-skewness.png" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you help me please!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 22 Sep 2016 12:49:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/portfolio-optimization-under-higher-moments-skewness-kurtosis/m-p/300100#M3017</guid>
      <dc:creator>JANET1987</dc:creator>
      <dc:date>2016-09-22T12:49:30Z</dc:date>
    </item>
    <item>
      <title>Re: portfolio optimization under higher moments (skewness-kurtosis)</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/portfolio-optimization-under-higher-moments-skewness-kurtosis/m-p/300107#M3018</link>
      <description>&lt;P&gt;You can implement triple-nested DO loops if you want to implement the summation formula, but the second line gives the matrix formula, which will be much easier and faster to compute.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assuming that the weight vector is a column vector, the objective function is the matrix product w`*M3*(w@w), where w@w is &lt;A href="http://blogs.sas.com/content/iml/2014/12/08/direct-product-kronecker-product.html" target="_self"&gt;the Kronecker product:&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
M3 = {32 -7 -7 -8,
      -7 -8 -8 17};

start skpf(w) global(M3);   /* w is column vector */
   return w` * M3 * (w@w);
finish;

w = {0.2, 0.8};  /* w is column vector */
v = skpf(w);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I assume that the sum of the weights is unity. If so, then you need to include an constaint when you optimize because there is really only N-1 parameters: &amp;nbsp;w[n] = 1 - (w[1] + w[2] + ... + w[n-1]).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In particular, for your example where N=2, you get the following graph of the objective function. Notice that the maximum is on the boundary for this example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/5016i5F48320E646C4476/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="sgplot.png" title="sgplot.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2016 13:34:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/portfolio-optimization-under-higher-moments-skewness-kurtosis/m-p/300107#M3018</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-09-22T13:34:42Z</dc:date>
    </item>
    <item>
      <title>Re: portfolio optimization under higher moments (skewness-kurtosis)</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/portfolio-optimization-under-higher-moments-skewness-kurtosis/m-p/300111#M3019</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you, as I understand your solution allows me to compute the skewness of &amp;nbsp;portfolio (wi (weights) are known).&lt;BR /&gt;However, in my case the wi are unknown and I try to find them (decision variables).&lt;BR /&gt;In fact I am trying to write the expression of the portfolio skewness (to maximize) as follow:&lt;BR /&gt;(for example for Two titles) we have:&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/5017i2ADB9F242BD2DB17/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="sk en fonction des pondérations.png" title="sk en fonction des pondérations.png" /&gt;&lt;/P&gt;&lt;P&gt;For N assets, how could I write it ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;In fact, my objectiv function&amp;nbsp;is as follow :&amp;nbsp;&lt;/P&gt;&lt;P&gt;Max sk_pf&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much in advance!&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2016 13:52:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/portfolio-optimization-under-higher-moments-skewness-kurtosis/m-p/300111#M3019</guid>
      <dc:creator>JANET1987</dc:creator>
      <dc:date>2016-09-22T13:52:08Z</dc:date>
    </item>
    <item>
      <title>Re: portfolio optimization under higher moments (skewness-kurtosis)</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/portfolio-optimization-under-higher-moments-skewness-kurtosis/m-p/300118#M3020</link>
      <description>&lt;P&gt;Yes, I understand. You asked how to write the objective function, which I provided. The function is vectorized and will support an arbitrary number of assets. &amp;nbsp;You just need to&amp;nbsp;use the objective function as part of a constrained nonlinear optimization. See the &lt;A href="http://support.sas.com/documentation/cdl/en/imlug/68150/HTML/default/viewer.htm#imlug_nonlinearoptexpls_sect001.htm" target="_self"&gt;SAS/IML documentation chapter about nonlinear optimization&lt;/A&gt;, and especially the&lt;A href="http://support.sas.com/documentation/cdl/en/imlug/68150/HTML/default/viewer.htm#imlug_nonlinearoptexpls_sect004.htm" target="_self"&gt; "Getting Started" example that shows how to run a linearly constrained optimization&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I like the NLPNRA algorithm myself. &amp;nbsp;You can read about &lt;A href="http://support.sas.com/documentation/cdl/en/imlug/68150/HTML/default/viewer.htm#imlug_nonlinearoptexpls_sect015.htm" target="_self"&gt;how to specify a linear constraint&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One change from before. I forgot that the NLP routines pass in a row vector as the parameter. Therefore you want to transpose the input argument before using it. &amp;nbsp;The following code gives the optimal value for your 2-D example. To support more variables, just update the new M3 matrix, the constraint matrix, and the initial guess.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
M3 = {32 -7 -7 -8,
      -7 -8 -8 17};

start skpf(p) global(M3);
   w = p`;   /* w is column vector */
   return w` * M3 * (w@w);
finish;

/* specify linear constraints  */
con = { 0  0  .   .,  /* min w[i]   */
        1  1  .   .,  /* max w[i]   */
        1  1  0   1}; /* sum(w) = 1 */
x0 = {0.5 0.5};
optn = {1    /* maximize objective function */
        1 }; /* summarize iteration history */
call nlpnra(rc, xOpt, "skpf", x0, optn, con);
maxVal = skpf(xOpt);
print rc, xOpt maxVal;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 22 Sep 2016 14:17:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/portfolio-optimization-under-higher-moments-skewness-kurtosis/m-p/300118#M3020</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-09-22T14:17:10Z</dc:date>
    </item>
    <item>
      <title>Re: portfolio optimization under higher moments (skewness-kurtosis)</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/portfolio-optimization-under-higher-moments-skewness-kurtosis/m-p/300135#M3021</link>
      <description>&lt;P&gt;Great, I will follow your recommendations! thank you very much !&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2016 15:16:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/portfolio-optimization-under-higher-moments-skewness-kurtosis/m-p/300135#M3021</guid>
      <dc:creator>JANET1987</dc:creator>
      <dc:date>2016-09-22T15:16:54Z</dc:date>
    </item>
    <item>
      <title>Re: portfolio optimization under higher moments (skewness-kurtosis)</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/portfolio-optimization-under-higher-moments-skewness-kurtosis/m-p/300299#M3023</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much, but I'm sorry,&amp;nbsp;I really don't understand why using proc iml if I don't have to compute the value of portfolio skewness ( since weights are unkown). In fact, I'd like to&amp;nbsp;express&amp;nbsp;my objective function in terms of weights (wi) and I think that proc optmodel could be usuful!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2016 08:14:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/portfolio-optimization-under-higher-moments-skewness-kurtosis/m-p/300299#M3023</guid>
      <dc:creator>JANET1987</dc:creator>
      <dc:date>2016-09-23T08:14:29Z</dc:date>
    </item>
    <item>
      <title>Re: portfolio optimization under higher moments (skewness-kurtosis)</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/portfolio-optimization-under-higher-moments-skewness-kurtosis/m-p/300332#M3024</link>
      <description>&lt;P&gt;I think you are not understanding the objective function that I wrote.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The argument is a VECTOR of weights: w = [w1, w2, w3, ..., wk]. &amp;nbsp;The '*' operator performs matrix multiplication. So in fact&lt;/P&gt;
&lt;P&gt;w` * M3 * (w@w)&lt;/P&gt;
&lt;P&gt;is exactly the formula that you wrote. &amp;nbsp;It is merely the matrix formulation, but it reduces to the same (i,jk) summation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2016 11:50:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/portfolio-optimization-under-higher-moments-skewness-kurtosis/m-p/300332#M3024</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-09-23T11:50:18Z</dc:date>
    </item>
    <item>
      <title>Re: portfolio optimization under higher moments (skewness-kurtosis)</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/portfolio-optimization-under-higher-moments-skewness-kurtosis/m-p/301184#M3030</link>
      <description>&lt;P&gt;Hello, I did not immediately reply your answer because I have taken a long time to understand it! It is so awesome! Thank you very much! I really appreciate your help! I read chapter 14 about Nonlinear optimization examples! I just discovered that SAS could do it!It’s so great!&amp;nbsp;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;Nevertheless , I have one more problem. I have one linear constraint and one Nonlinear constraint (quartic constraint about portfolio kurtosis which is less than a scalar). As I understand I must use NLPQN instead of NLPNRA! IS that sufficient?&lt;/P&gt;&lt;P&gt;In the other hand, I still think about the mining of “optn”!&lt;/P&gt;&lt;P&gt;Finally, I want to state decision variables wi as positive, I question whether it been subject to a further constraint.&lt;/P&gt;&lt;P&gt;Sorry for those lots of questions. Thank you in advance!&amp;nbsp;&lt;img id="smileyembarrassed" class="emoticon emoticon-smileyembarrassed" src="https://communities.sas.com/i/smilies/16x16_smiley-embarrassed.png" alt="Smiley Embarassed" title="Smiley Embarassed" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Sep 2016 09:10:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/portfolio-optimization-under-higher-moments-skewness-kurtosis/m-p/301184#M3030</guid>
      <dc:creator>JANET1987</dc:creator>
      <dc:date>2016-09-28T09:10:46Z</dc:date>
    </item>
  </channel>
</rss>

