<?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: How to get the estimated density function from proc kde in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/How-to-get-the-estimated-density-function-from-proc-kde/m-p/317894#M11122</link>
    <description>&lt;P&gt;Sure. The KDE is a nonparametric density function (PDF) on a finite domain. To get the CDF from the PDF,&amp;nbsp;&amp;nbsp;Numerically integrate the PDF. See the article &lt;A href="http://blogs.sas.com/content/iml/2011/07/08/the-area-under-a-density-estimate-curve-nonparametric-estimates.html" target="_self"&gt;"The area under s density curve: Nonparametric estimates"&lt;/A&gt;&amp;nbsp; The article uses PROC UNIVARIATE, but you can use PROC KDE if you prefer.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you use a very fine grid for the KDE, you should be able to closely approximate the CDF and therefore the probabilities for any interval. You can use the NGRID= option to specify how many grid points you want in the output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you require interpolation, see the article &lt;A href="http://blogs.sas.com/content/iml/2012/03/16/linear-interpolation-in-sas.html" target="_self"&gt;"Interpolation in SAS"&lt;/A&gt;&amp;nbsp; I think if you use lots of grid points (maybe1001) you won't need interpolation. After all, the KDE is only an estimate. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you say, for each test value&amp;nbsp;in the data base, you can get an approximate probability by finding the first x value in the linear grid that is greater than or equal to the test value and looking up the CDF for that x.&lt;/P&gt;</description>
    <pubDate>Fri, 09 Dec 2016 13:41:59 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2016-12-09T13:41:59Z</dc:date>
    <item>
      <title>How to get the estimated density function from proc kde</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-get-the-estimated-density-function-from-proc-kde/m-p/317858#M11118</link>
      <description>&lt;P&gt;I would like to estimate the (cumulative) density function of a continuous variable (TimeToEvent) with proc kde.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc KDE data=DistributionSet;
  univar TimeToEvent / percentiles=0 to 100 by 0.01;
  ods output percentiles=P1CDF;
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As I only have one variable, I use an univar statement.&lt;/P&gt;&lt;P&gt;For smoothing I use the SJPI method.&lt;/P&gt;&lt;P&gt;If I output the estimated density function, it looks just great.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, in a next step, I would like to use the estimated density function to map probabilities (probabilities like P(X&amp;lt;=x)) &amp;nbsp;to certain values of the continuous variable &lt;SPAN&gt;(TimeToEvent) &lt;/SPAN&gt;&amp;nbsp;in a data base. In order to do that, I should have access to either the expression of the estimated smooth density function or&amp;nbsp;a fine map of either the estimated smooth density function or the cumulative density function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The only solution I could come up with is the following: I output 10000 percentile values (percentiles=0 to 100 by 0.01). However, I think these percentile values are calculated directly from the sample of the TimeToEvent variable (if I plot the values I see a stepwise function), not based on the estimated smooth density function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you suggest a better solution on how to "access" the estimated smooth density function?&lt;/P&gt;</description>
      <pubDate>Fri, 09 Dec 2016 11:07:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-get-the-estimated-density-function-from-proc-kde/m-p/317858#M11118</guid>
      <dc:creator>berencsiklara</dc:creator>
      <dc:date>2016-12-09T11:07:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the estimated density function from proc kde</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-get-the-estimated-density-function-from-proc-kde/m-p/317894#M11122</link>
      <description>&lt;P&gt;Sure. The KDE is a nonparametric density function (PDF) on a finite domain. To get the CDF from the PDF,&amp;nbsp;&amp;nbsp;Numerically integrate the PDF. See the article &lt;A href="http://blogs.sas.com/content/iml/2011/07/08/the-area-under-a-density-estimate-curve-nonparametric-estimates.html" target="_self"&gt;"The area under s density curve: Nonparametric estimates"&lt;/A&gt;&amp;nbsp; The article uses PROC UNIVARIATE, but you can use PROC KDE if you prefer.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you use a very fine grid for the KDE, you should be able to closely approximate the CDF and therefore the probabilities for any interval. You can use the NGRID= option to specify how many grid points you want in the output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you require interpolation, see the article &lt;A href="http://blogs.sas.com/content/iml/2012/03/16/linear-interpolation-in-sas.html" target="_self"&gt;"Interpolation in SAS"&lt;/A&gt;&amp;nbsp; I think if you use lots of grid points (maybe1001) you won't need interpolation. After all, the KDE is only an estimate. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you say, for each test value&amp;nbsp;in the data base, you can get an approximate probability by finding the first x value in the linear grid that is greater than or equal to the test value and looking up the CDF for that x.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Dec 2016 13:41:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-get-the-estimated-density-function-from-proc-kde/m-p/317894#M11122</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-12-09T13:41:59Z</dc:date>
    </item>
  </channel>
</rss>

