<?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 Finding most stable cluster from time series data in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Finding-most-stable-cluster-from-time-series-data/m-p/440297#M23208</link>
    <description>&lt;P&gt;&lt;SPAN&gt;I have 2 years stock market time series data comprising stocks return data. I am averaging returns on monthly basis and then using K means clustering method to get clusters for each month. So for first 1 year I am performing cluster analysis 12 times&amp;nbsp; . However due to volatile stock performances&amp;nbsp; I am getting stocks getting assigned to different clusters. How can I identify all the stocks which remains together in one cluster through whole 12 months period ?&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;Could you please recommend best method to find most stable cluster over period of 12 months ?&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Amol Deshmukh&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 26 Feb 2018 18:44:23 GMT</pubDate>
    <dc:creator>dav_amol</dc:creator>
    <dc:date>2018-02-26T18:44:23Z</dc:date>
    <item>
      <title>Finding most stable cluster from time series data</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Finding-most-stable-cluster-from-time-series-data/m-p/440297#M23208</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I have 2 years stock market time series data comprising stocks return data. I am averaging returns on monthly basis and then using K means clustering method to get clusters for each month. So for first 1 year I am performing cluster analysis 12 times&amp;nbsp; . However due to volatile stock performances&amp;nbsp; I am getting stocks getting assigned to different clusters. How can I identify all the stocks which remains together in one cluster through whole 12 months period ?&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;Could you please recommend best method to find most stable cluster over period of 12 months ?&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Amol Deshmukh&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Feb 2018 18:44:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Finding-most-stable-cluster-from-time-series-data/m-p/440297#M23208</guid>
      <dc:creator>dav_amol</dc:creator>
      <dc:date>2018-02-26T18:44:23Z</dc:date>
    </item>
    <item>
      <title>Re: Finding most stable cluster from time series data</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Finding-most-stable-cluster-from-time-series-data/m-p/440379#M23211</link>
      <description>&lt;P&gt;Assuming that you have the licence to SAS/OR, you can do this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Random assignment of 20 Stocks in 4 clusters over 3 months */
data have;
call streaminit(56456);
do stock = 1 to 20;
    do month = 1 to 3;
        clust = rand("integer", 4);
        output;
        end;
    end;
run;

/* List the stocks that share the same cluster each month */
proc sql;
create table pairs as
select 
    a.month,
    a.stock as stock1,
    b.stock as stock2
from
    have as a inner join
    have as b on a.month=b.month and a.clust=b.clust and a.stock &amp;lt; b.stock;

create table stablePairs as
select
    stock1, stock2
from pairs
group by stock1, stock2
having count(*) = (select count(distinct month) from have);
quit;
    
/* Find the groups of stocks that are always found together */
/* Note: proc optnet is part of SAS/OR */ 
proc optnet data_links=stablePairs direction=undirected;
data_links_var from=stock1 to=stock2;
clique out=stableGroups(rename=(clique=group node=stock));
run;

/* For example, stocks 4, 7 and 10 are always found in the same cluster */
proc print noobs data=stableGroups; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;                                   group    stock

                                     1         3
                                     1         6
                                     2         4
                                     2         7
                                     2        10
                                     3         5
                                     3        15
                                     4        17
                                     4        18
&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Feb 2018 04:11:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Finding-most-stable-cluster-from-time-series-data/m-p/440379#M23211</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-02-27T04:11:19Z</dc:date>
    </item>
  </channel>
</rss>

