<?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: proc optmodel to minimize varience in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/proc-optmodel-to-minimize-varience/m-p/327625#M1644</link>
    <description>&lt;P&gt;I think the following does what you want, first calling PROC CORR to compute the covariance from the historical data and then calling PROC OPTMODEL to formulate and solve the optimization problem:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc corr data=styledata(drop=date)
   out=corrout(where=(_type_ ne 'CORR')) cov noprint;
run;

data stats(drop=_name_);
   set corrout;
   if _type_ = 'COV' then delete;
run;
proc transpose data=stats out=stats;
   id _type_;
run;

proc optmodel;
   /* declare parameters and read data */
   set &amp;lt;str&amp;gt; ASSETS;
   str target = 'AMP';
   set BENCH = ASSETS diff {target};
   num cov {ASSETS, ASSETS};
   read data stats into ASSETS=[_name_];
   read data corrout(where=(_type_='COV')) into [_name_]
      {i in ASSETS} &amp;lt;cov[_name_,i]=col(i)&amp;gt;;

   /* declare optimization model */
   var W {BENCH} &amp;gt;= 0 &amp;lt;= 1;
   /* Var(X - Y) = Var(X) + Var(Y) - 2 Cov(X,Y) */
   min Variance = 
      sum {i in BENCH, j in BENCH} cov[i,j] * W[i] * W[j]
    + cov[target,target] 
    - 2 * sum {i in BENCH} cov[i,target] * W[i];
   con InvestAll:
      sum {i in BENCH} W[i] = 1;

   /* call solver and print optimal solution */
   solve;
   print W;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 26 Jan 2017 02:41:03 GMT</pubDate>
    <dc:creator>RobPratt</dc:creator>
    <dc:date>2017-01-26T02:41:03Z</dc:date>
    <item>
      <title>proc optmodel to minimize varience</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/proc-optmodel-to-minimize-varience/m-p/326614#M1634</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to minimise the following function;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Varience (e) = Varience (R) - Varience (w1r1+w2r2+w3r3+w4r4)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I am not quite sure that how to state its objective function using the SAS coding, can someone help me out in that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 04:02:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/proc-optmodel-to-minimize-varience/m-p/326614#M1634</guid>
      <dc:creator>Amalik</dc:creator>
      <dc:date>2017-01-23T04:02:44Z</dc:date>
    </item>
    <item>
      <title>Re: proc optmodel to minimize varience</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/proc-optmodel-to-minimize-varience/m-p/327215#M1636</link>
      <description>&lt;P&gt;I'd like to help, but I need more detail. &amp;nbsp;Which are decision variables, and which are data?&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2017 22:40:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/proc-optmodel-to-minimize-varience/m-p/327215#M1636</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2017-01-24T22:40:25Z</dc:date>
    </item>
    <item>
      <title>Re: proc optmodel to minimize varience</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/proc-optmodel-to-minimize-varience/m-p/327353#M1640</link>
      <description>&lt;P&gt;Hi Rob,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am actually conducting style analysis of AMP fund on 4 benchmark returns,&lt;/P&gt;&lt;P&gt;I actually want to minimise the variance of the tracking error and find the weights that minimise the following function,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;min VAR(R.f - SUM[w_i * R.s_i]) = min VAR(F - w*S)
  s.t. SUM(w_i) = 1; w_i &amp;gt; 0

where:
R.f   Fund returns
R.s   Style returns
w_i   Style weights&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;For my case it becomes,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;min Var(AMP_AIT) – &amp;nbsp;Var (w1*US_Small_Val + w2*US_Small_Gr + w3*US_Large_Gr + w4*_US_Large_Val)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;subject to the constraints where sum&amp;nbsp;Wi = 1 and Wi &amp;gt;= 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to use the proc optmodel in this regard will be greatly helpful for me. I have also attaced my dataset for your reference.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2017 12:22:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/proc-optmodel-to-minimize-varience/m-p/327353#M1640</guid>
      <dc:creator>Amalik</dc:creator>
      <dc:date>2017-01-25T12:22:41Z</dc:date>
    </item>
    <item>
      <title>Re: proc optmodel to minimize varience</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/proc-optmodel-to-minimize-varience/m-p/327625#M1644</link>
      <description>&lt;P&gt;I think the following does what you want, first calling PROC CORR to compute the covariance from the historical data and then calling PROC OPTMODEL to formulate and solve the optimization problem:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc corr data=styledata(drop=date)
   out=corrout(where=(_type_ ne 'CORR')) cov noprint;
run;

data stats(drop=_name_);
   set corrout;
   if _type_ = 'COV' then delete;
run;
proc transpose data=stats out=stats;
   id _type_;
run;

proc optmodel;
   /* declare parameters and read data */
   set &amp;lt;str&amp;gt; ASSETS;
   str target = 'AMP';
   set BENCH = ASSETS diff {target};
   num cov {ASSETS, ASSETS};
   read data stats into ASSETS=[_name_];
   read data corrout(where=(_type_='COV')) into [_name_]
      {i in ASSETS} &amp;lt;cov[_name_,i]=col(i)&amp;gt;;

   /* declare optimization model */
   var W {BENCH} &amp;gt;= 0 &amp;lt;= 1;
   /* Var(X - Y) = Var(X) + Var(Y) - 2 Cov(X,Y) */
   min Variance = 
      sum {i in BENCH, j in BENCH} cov[i,j] * W[i] * W[j]
    + cov[target,target] 
    - 2 * sum {i in BENCH} cov[i,target] * W[i];
   con InvestAll:
      sum {i in BENCH} W[i] = 1;

   /* call solver and print optimal solution */
   solve;
   print W;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2017 02:41:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/proc-optmodel-to-minimize-varience/m-p/327625#M1644</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2017-01-26T02:41:03Z</dc:date>
    </item>
    <item>
      <title>Re: proc optmodel to minimize varience</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/proc-optmodel-to-minimize-varience/m-p/327641#M1645</link>
      <description>&lt;P&gt;I just can't thank you enough Rob, the coding worked. I am really grateful to you for this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2017 06:56:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/proc-optmodel-to-minimize-varience/m-p/327641#M1645</guid>
      <dc:creator>Amalik</dc:creator>
      <dc:date>2017-01-26T06:56:55Z</dc:date>
    </item>
  </channel>
</rss>

