<?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: Transition matrix smoothing in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Transition-matrix-smoothing/m-p/905169#M357528</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/460341"&gt;@ReadyPlayer1&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;I replied quickly this morning ... a few minutes before my meeting started. I maintain that the matrix you posted is extremely easy to smooth (in the sense you meant and indicated). However, I think it is a very simple example and so I agree with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp; that it can quickly become much more difficult and much less obvious. I hope you get out with the answers provided by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;and &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16777"&gt;@WarrenKuhfeld&lt;/a&gt;&lt;BR /&gt;and otherwise just ask for additional help.&lt;/P&gt;
&lt;P&gt;Good luck,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
    <pubDate>Wed, 29 Nov 2023 14:28:08 GMT</pubDate>
    <dc:creator>sbxkoenk</dc:creator>
    <dc:date>2023-11-29T14:28:08Z</dc:date>
    <item>
      <title>Transition matrix smoothing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transition-matrix-smoothing/m-p/905085#M357499</link>
      <description>&lt;P&gt;I have a dataset with 4 variables: ID, date, rating_start, rating_end. The transition matrix from rating_start to rating_end is shown below for a 1-year period (not real data). I want to smooth each row so that it is monotonic (different direction either side of the diagonal). I have highlighted the cells where the data is not monotonically decreasing or increasing. I have found several published papers where the average of the non-monotonic cells is used but I cannot work out how to do this in SAS. I have hundreds of matrices that I need to do this for, which need to be regularly updated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Before smoothing:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ReadyPlayer1_0-1701234744205.png" style="width: 346px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/90420i71EE603FF81046ED/image-dimensions/346x181?v=v2" width="346" height="181" role="button" title="ReadyPlayer1_0-1701234744205.png" alt="ReadyPlayer1_0-1701234744205.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Desired after smoothing:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ReadyPlayer1_0-1701235248629.png" style="width: 343px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/90421iC5C0EB325F17B078/image-dimensions/343x178?v=v2" width="343" height="178" role="button" title="ReadyPlayer1_0-1701235248629.png" alt="ReadyPlayer1_0-1701235248629.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2023 05:24:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transition-matrix-smoothing/m-p/905085#M357499</guid>
      <dc:creator>ReadyPlayer1</dc:creator>
      <dc:date>2023-11-29T05:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: Transition matrix smoothing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transition-matrix-smoothing/m-p/905132#M357513</link>
      <description>&lt;P&gt;That's easy to do with data step programming (array processing).&lt;BR /&gt;But you can also use IML for it (IML = the SAS Interactive Matrix Language).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you provide us with one such matrix? A datastep with datalines / cards, I mean ... not a picture.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2023 08:34:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transition-matrix-smoothing/m-p/905132#M357513</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2023-11-29T08:34:34Z</dc:date>
    </item>
    <item>
      <title>Re: Transition matrix smoothing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transition-matrix-smoothing/m-p/905143#M357517</link>
      <description>&lt;P&gt;Calling&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2023 11:44:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transition-matrix-smoothing/m-p/905143#M357517</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-11-29T11:44:06Z</dc:date>
    </item>
    <item>
      <title>Re: Transition matrix smoothing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transition-matrix-smoothing/m-p/905148#M357519</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;nbsp;I have found several published papers where the average of the non-monotonic cells is used but I cannot work out how to do this in SAS&lt;/EM&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Please post the citation to the paper whose algorithm you want to use.&lt;/LI&gt;
&lt;LI&gt;Also tell us whether you can use SAS IML language or if you are restricted to the DATA step.&lt;/LI&gt;
&lt;LI&gt;In what sense are these "transition matrices"? In probability and statistics,&amp;nbsp;a transition matrix is a square matrix in which the (i,j)th element is the probability of transitioning from state i into state j. The sum of each row is 1.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;In general, this is not a simple operation and might require an iterative algorithm. The example you provided only has adjacent pairs that are not monotone. But you can construct examples where doing a pairwise average will not result in a monotonically decreasing row. For example, if the first row is&lt;/P&gt;
&lt;P&gt;{4000, 2000, 600, 700, 700, 500}&lt;/P&gt;
&lt;P&gt;and you attempt to perform "pairwise averaging" whenever adjacent cells are not decreasing, then after one pass the vector is not monotone. The example is monotone after a second pass, but you can construct other examples that need additional iterations.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
M = {
4000 2000 600 700 700 500
};
/* first pass */
do i = 1 to ncol(M)-1;
   if M[i+1] &amp;gt; M[i] then 
      M[i:i+1] = (M[i+1] + M[i]) / 2;
end;
print M;
/* second pass */
do i = 1 to ncol(M)-1;
   if M[i+1] &amp;gt; M[i] then 
      M[i:i+1] = (M[i+1] + M[i]) / 2;
end;
print M;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2023 12:04:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transition-matrix-smoothing/m-p/905148#M357519</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2023-11-29T12:04:19Z</dc:date>
    </item>
    <item>
      <title>Re: Transition matrix smoothing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transition-matrix-smoothing/m-p/905151#M357521</link>
      <description>&lt;P&gt;Check out the OPSCAL function in IML. It can average adjacent categories to achieve monotonicity.&amp;nbsp; &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/v_045/casimllang/casimllang_common_sect279.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/v_045/casimllang/casimllang_common_sect279.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2023 12:20:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transition-matrix-smoothing/m-p/905151#M357521</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2023-11-29T12:20:38Z</dc:date>
    </item>
    <item>
      <title>Re: Transition matrix smoothing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transition-matrix-smoothing/m-p/905169#M357528</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/460341"&gt;@ReadyPlayer1&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;I replied quickly this morning ... a few minutes before my meeting started. I maintain that the matrix you posted is extremely easy to smooth (in the sense you meant and indicated). However, I think it is a very simple example and so I agree with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp; that it can quickly become much more difficult and much less obvious. I hope you get out with the answers provided by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;and &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16777"&gt;@WarrenKuhfeld&lt;/a&gt;&lt;BR /&gt;and otherwise just ask for additional help.&lt;/P&gt;
&lt;P&gt;Good luck,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2023 14:28:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transition-matrix-smoothing/m-p/905169#M357528</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2023-11-29T14:28:08Z</dc:date>
    </item>
    <item>
      <title>Re: Transition matrix smoothing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transition-matrix-smoothing/m-p/905280#M357571</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Thanks everyone for your input, this is my first time using this community, really impressed with how quick you all are!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1) Smoothing algorithms by constrained maximum likelihood: methodologies and implementations for Comprehensive Capital Analysis and Review stress testing and International Financial Reporting Standard 9 expected credit loss estimation - Bill Huajian Yang (&lt;A href="https://www.risk.net/journal-of-risk-model-validation/5587081/smoothing-algorithms-by-constrained-maximum-likelihood-methodologies-and-implementations-for-comprehensive-capital-analysis-and-review-stress-testing-and-international-financial-reporting-standard-9-expected" target="_blank"&gt;https://www.risk.net/journal-of-risk-model-validation/5587081/smoothing-algorithms-by-constrained-maximum-likelihood-methodologies-and-implementations-for-comprehensive-capital-analysis-and-review-stress-testing-and-international-financial-reporting-standard-9-expected&lt;/A&gt;). There is a sentence "These algorithms can be implemented by a modeler using, for example, the SAS PROC NLMIXED package."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2) I do not have IML available, only datastep&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;3) These are the counts of transitions;&amp;nbsp;I will produce the % transitions using the processed count matrices.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2023 23:11:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transition-matrix-smoothing/m-p/905280#M357571</guid>
      <dc:creator>ReadyPlayer1</dc:creator>
      <dc:date>2023-11-29T23:11:14Z</dc:date>
    </item>
    <item>
      <title>Re: Transition matrix smoothing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transition-matrix-smoothing/m-p/905284#M357573</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;nbsp;I do not have IML available, only datastep&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks for the response. I will leave you in the capable hands of the other experts. Best wishes.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2023 23:26:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transition-matrix-smoothing/m-p/905284#M357573</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2023-11-29T23:26:01Z</dc:date>
    </item>
    <item>
      <title>Re: Transition matrix smoothing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transition-matrix-smoothing/m-p/905290#M357576</link>
      <description>&lt;P&gt;Opscal functionality is also available from the SAS/STAT procedure transreg.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2023 23:58:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transition-matrix-smoothing/m-p/905290#M357576</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2023-11-29T23:58:24Z</dc:date>
    </item>
    <item>
      <title>Re: Transition matrix smoothing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transition-matrix-smoothing/m-p/905552#M357662</link>
      <description>&lt;P&gt;You could fit a growth curve as mentioned in&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2018/10/10/fit-growth-curve-sas.html" target="_blank"&gt;Fit a growth curve in SAS - The DO Loop&lt;/A&gt;&lt;/P&gt;
&lt;DIV id="tinyMceEditorKsharp_0" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_1-1701421934169.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/90555i650D403710220B02/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_1-1701421934169.png" alt="Ksharp_1-1701421934169.png" /&gt;&lt;/span&gt;&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;
&lt;P&gt;&lt;A href="https://support.sas.com/resources/papers/proceedings/proceedings/sugi29/188-29.pdf" target="_blank"&gt;188-29: Repeated Measures Modeling with PROC MIXED (sas.com)&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_2-1701421956065.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/90556i3AD2EAA3B827654B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_2-1701421956065.png" alt="Ksharp_2-1701421956065.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2023 09:12:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transition-matrix-smoothing/m-p/905552#M357662</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-12-01T09:12:43Z</dc:date>
    </item>
  </channel>
</rss>

