<?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: bootstrap for default rates in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/bootstrap-for-default-rates/m-p/419589#M67828</link>
    <description>&lt;P&gt;OK. That's a different question. Convert the matrix you have to a transition matrix of probabilities. Then you can use a simulation of the Markov chain model in SAS/IML to compute the end-of-year expected value and CIs for each start-of-year rating.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For a discussion and example, see &lt;A href="https://blogs.sas.com/content/iml/2016/07/07/markov-transition-matrices-sasiml.html" target="_self"&gt;"Markov transition matrices in SAS/IML"&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is a bit of a mathematical wrinkle in this approach. You have discrete categories, so unless you assign&amp;nbsp;an ordinal scale, the best you can do is discuss the expected mode. If you assign numbers for the ratings (AAA=1, AA+=2, AA=3,...) then you can get a numerical mean and CI. However, it is not clear whether the scale should be linear. I will leave that to the domain experts.&lt;/P&gt;</description>
    <pubDate>Fri, 08 Dec 2017 15:35:54 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2017-12-08T15:35:54Z</dc:date>
    <item>
      <title>bootstrap for default rates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/bootstrap-for-default-rates/m-p/419038#M67785</link>
      <description>&lt;P&gt;Hello, I would like some help with this question:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data contains S&amp;amp;P rating information for around 15,000 companies at the beginning as well as end of the year 2015.&lt;/P&gt;&lt;P&gt;PID: a serial number representing company ID;&lt;/P&gt;&lt;P&gt;Rating2015_B:&amp;nbsp; S&amp;amp;P rating at the beginning of the year 2015;&lt;/P&gt;&lt;P&gt;Rating2015_E: S&amp;amp;P rating at the end of the year 2015, “D” means company defaults at the end of year&lt;/P&gt;&lt;P&gt;Use the nonparametric bootstrap method (exclude the defaults) to generate 95% confidence intervals for default rates of each rating category. &amp;nbsp;&lt;/P&gt;&lt;P&gt;Explore the relationship between the length of CIs and number of bootstrap samples and confidence level.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have this code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;surveyselect&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;data=Mylib.LoanData&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; method=SRS&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;n=&lt;STRONG&gt;100&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;reps=&lt;STRONG&gt;100&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; seed=&lt;STRONG&gt;9999&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; out=Mylib.LoanDataBootStrapCor;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;corr&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;data=Mylib.LoanDataBootStrapCor;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by replicate;var Rating_2015B;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ods output PearsonCorr=Mylib.BootStrapPearsonCorr;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Mylib.BootStrapPearsonCorr1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set Mylib.BootStrapPearsonCorr;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;by replicate;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if first.replicate then delete;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;univariate&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;data=Mylib.BootStrapPearsonCorr1 pctldef=&lt;STRONG&gt;4&lt;/STRONG&gt;; var&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;Rating_2015B&lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output out=Mylib.BootStrapCorCI pctlpts=&amp;amp;pctlpts. pctlpre=pct_;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;print&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;data=Mylib.BootStrapCorCI;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to get some help and understand where I am going wrong and if this code is correct for this particular question.&amp;nbsp;&lt;/P&gt;&lt;P&gt;When i run the code, i'm getting error as sas is not recognizing&amp;nbsp;&lt;SPAN&gt;BootStrapPearsonCorr1 and&amp;nbsp;BootStrapCorCI&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2017 02:03:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/bootstrap-for-default-rates/m-p/419038#M67785</guid>
      <dc:creator>Anna7</dc:creator>
      <dc:date>2017-12-07T02:03:36Z</dc:date>
    </item>
    <item>
      <title>Re: bootstrap for default rates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/bootstrap-for-default-rates/m-p/419577#M67825</link>
      <description>&lt;P&gt;I think you have the correct general idea. This is the basic framework I discuss in Chapter 15 ("Resampling and Bootstrap Methods") of my book &lt;A href="https://www.sas.com/sas/books/authors/rick-wicklin.html" target="_self"&gt;Simulating Data with SAS.&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Pearson correlation applies to numerical data. From the spreadsheet that you attached, you have categorical data. Did you mean to&amp;nbsp;use PROC FREQ or some other procedure that handles categorical variables?&lt;/P&gt;
&lt;P&gt;2. You only have one variable listed on the VAR statement in PROC CORR. The correlation of a variable with itself is always 1, so even if you had numerical data your output would contain&amp;nbsp;a column&amp;nbsp;of all 1s, which is probably not what you want. Options: include a WITH statement or specify more than one variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 14:49:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/bootstrap-for-default-rates/m-p/419577#M67825</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-12-08T14:49:18Z</dc:date>
    </item>
    <item>
      <title>Re: bootstrap for default rates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/bootstrap-for-default-rates/m-p/419581#M67826</link>
      <description>&lt;P&gt;Hi, thanks for your reply. Yes with this dataset, I only have those 2 columns with the categorical data. Currently I have the transition matrix for the beginning of the year default rating and end of year default rating. After that, I am confused as to how the code should proceed to determine the migration relationship and to determine the confidence interval. I am not aware of how to write the code for those two parts.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/17094i0186E6F19ECC594B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 15:02:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/bootstrap-for-default-rates/m-p/419581#M67826</guid>
      <dc:creator>Anna7</dc:creator>
      <dc:date>2017-12-08T15:02:53Z</dc:date>
    </item>
    <item>
      <title>Re: bootstrap for default rates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/bootstrap-for-default-rates/m-p/419589#M67828</link>
      <description>&lt;P&gt;OK. That's a different question. Convert the matrix you have to a transition matrix of probabilities. Then you can use a simulation of the Markov chain model in SAS/IML to compute the end-of-year expected value and CIs for each start-of-year rating.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For a discussion and example, see &lt;A href="https://blogs.sas.com/content/iml/2016/07/07/markov-transition-matrices-sasiml.html" target="_self"&gt;"Markov transition matrices in SAS/IML"&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is a bit of a mathematical wrinkle in this approach. You have discrete categories, so unless you assign&amp;nbsp;an ordinal scale, the best you can do is discuss the expected mode. If you assign numbers for the ratings (AAA=1, AA+=2, AA=3,...) then you can get a numerical mean and CI. However, it is not clear whether the scale should be linear. I will leave that to the domain experts.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 15:35:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/bootstrap-for-default-rates/m-p/419589#M67828</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-12-08T15:35:54Z</dc:date>
    </item>
    <item>
      <title>Re: bootstrap for default rates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/bootstrap-for-default-rates/m-p/419663#M67840</link>
      <description>&lt;P&gt;Thank you for your reply. I am at beginner level for SAS so I am not aware of a lot of the terminology and many features of SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not really sure which route to take in order to solve this question, but I have attempted different things.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Previously it was this code to figure out the confidence interval, however I am unaware of what is going wrong and how to improve the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;surveyselect&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;data=Mylib.LoanData&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; method=SRS&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;n=&lt;STRONG&gt;100&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;reps=&lt;STRONG&gt;100&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; seed=&lt;STRONG&gt;9999&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; out=Mylib.LoanDataBootStrapCor;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;corr&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;data=Mylib.LoanDataBootStrapCor;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by replicate;var Rating_2015B;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ods output PearsonCorr=Mylib.BootStrapPearsonCorr;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Mylib.BootStrapPearsonCorr1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set Mylib.BootStrapPearsonCorr;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;by replicate;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if first.replicate then delete;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;univariate&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;data=Mylib.BootStrapPearsonCorr1 pctldef=&lt;STRONG&gt;4&lt;/STRONG&gt;; var&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;Rating_2015B&lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output out=Mylib.BootStrapCorCI pctlpts=&amp;amp;pctlpts. pctlpre=pct_;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;print&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;data=Mylib.BootStrapCorCI;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So then I tried the transition matrix and right now I have gotten this far.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/17095iCD05E386C67D278F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This has the percentage for every default rate from the beginning of the year to the end.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I am unaware of how to write the code for confidence interval and determining any relationship. The question asks to use:&lt;/P&gt;&lt;P&gt;nonparametric bootstrap method (exclude the defaults) to generate 95% confidence intervals for default rates of each rating category. &amp;nbsp;&lt;/P&gt;&lt;P&gt;Explore the relationship between the length of CIs and number of bootstrap samples and confidence level.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It would be great, if I can get some help in writing the code. I am not aware of the logic and what the code should be and the functions.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 18:47:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/bootstrap-for-default-rates/m-p/419663#M67840</guid>
      <dc:creator>Anna7</dc:creator>
      <dc:date>2017-12-08T18:47:36Z</dc:date>
    </item>
    <item>
      <title>Re: bootstrap for default rates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/bootstrap-for-default-rates/m-p/420974#M67936</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;nbsp;&amp;nbsp;I am not aware of the logic and what the code should be and the functions.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's start with the logic. Focus on the first&amp;nbsp;cell (the other cells are similar.) The original data says that there were 1029 companies that started with A rating. At the end of the time period, 832 / 1029 = 0.8085&amp;nbsp;was the proportion that stayed A rated.&amp;nbsp; You can compute this proportion for every rating category in the row. This is the empirical point estimate for the probability that a company that started A rated&amp;nbsp;ends up in Rating[j]..&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you run a Monte Carlo simulation, you get a point estimate in each cell for &lt;STRONG&gt;each&lt;/STRONG&gt; of the B simulations that you run. This gives you the sampling distribution for the transition probability. For example, you get&amp;nbsp;B values in the first cell. They might be&amp;nbsp;&lt;/P&gt;
&lt;P&gt;0.83, 0.92, 0.85, 0.73, 0.79, etc.&lt;/P&gt;
&lt;P&gt;The mean of those values is the Monte Carlo estimate of the mean. It might be 0.82.&amp;nbsp; The interval [&lt;EM&gt;a,b&lt;/EM&gt;] is an approximate 95% confidence interval where &lt;EM&gt;a&lt;/EM&gt; is the 2.5th&amp;nbsp;percentile and &lt;EM&gt;b&amp;nbsp;&lt;/EM&gt;is the 97.5th percentile.&amp;nbsp; For each cell, you can use PROC UNIVARIATE to compute the mean and percentiles of the simulated estimates.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2017 20:14:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/bootstrap-for-default-rates/m-p/420974#M67936</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-12-13T20:14:31Z</dc:date>
    </item>
  </channel>
</rss>

