<?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: bivariate kerneldensity estimation with proc KDE setting the bandwith in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/bivariate-kerneldensity-estimation-with-proc-KDE-setting-the/m-p/337294#M17787</link>
    <description>&lt;P&gt;&amp;gt;&amp;nbsp;&lt;SPAN&gt;there is no method available to plot it like image.plot in R, right? &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;PROC KDE provides the PLOTS= option which can plot a surface plot or contour plot&amp;nbsp;of the density estimate. If you need something fancier, you can also output the KDE and use SAS graphics to visualize the estimate. &amp;nbsp;For example, see&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.sas.com/content/iml/2015/10/12/create-surface-plot-sas.html" target="_self"&gt;How to create a surface plot in SAS&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.sas.com/content/iml/2012/07/02/create-a-contour-plot-in-sas.html" target="_self"&gt;How to create a contour plot in SAS&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 02 Mar 2017 10:43:59 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2017-03-02T10:43:59Z</dc:date>
    <item>
      <title>bivariate kerneldensity estimation with proc KDE setting the bandwith</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/bivariate-kerneldensity-estimation-with-proc-KDE-setting-the/m-p/336674#M17778</link>
      <description>Dear community, I don't know if this is the right location of my post, but my question is the following: I want to estimate a bivariate KDE and i want to set the bwm seperatly. I can do this until a number of 20. But if i want to set it like it is recommended in the manual of proc kde (calculate a plug in from std of the variables) it is not possible and I get the error message "The SAS System stopped processing this step because of insufficient memory". In addition i choosed ngrid=400 gridl=5799520 gridu=5837259. I'm working with SAS Studio. Any ideas why this appear? In R the same algorithm with the same values is working very well. Thanks for help in advance! lalilu</description>
      <pubDate>Tue, 28 Feb 2017 18:18:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/bivariate-kerneldensity-estimation-with-proc-KDE-setting-the/m-p/336674#M17778</guid>
      <dc:creator>lalilu</dc:creator>
      <dc:date>2017-02-28T18:18:40Z</dc:date>
    </item>
    <item>
      <title>Re: bivariate kerneldensity estimation with proc KDE setting the bandwith</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/bivariate-kerneldensity-estimation-with-proc-KDE-setting-the/m-p/337146#M17779</link>
      <description>&lt;P&gt;For an example, see&amp;nbsp;&lt;A href="http://support.sas.com/documentation/cdl/en/statug/68162/HTML/default/viewer.htm#statug_kde_examples03.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/statug/68162/HTML/default/viewer.htm#statug_kde_examples03.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;The memory problem might be caused by using too large a value for NGRID=. If you double that number, SAS uses four times as much memory and computation. &amp;nbsp;Try dialing back that number to NGRID=150 or 200, which is still a very fine grid.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If that doesn't fix the problem, please post your complete&amp;nbsp;PROC KDE code.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2017 21:01:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/bivariate-kerneldensity-estimation-with-proc-KDE-setting-the/m-p/337146#M17779</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-03-01T21:01:00Z</dc:date>
    </item>
    <item>
      <title>Re: bivariate kerneldensity estimation with proc KDE setting the bandwith</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/bivariate-kerneldensity-estimation-with-proc-KDE-setting-the/m-p/337281#M17781</link>
      <description>Dear Rick, thanks for your answer. I've already tried this. I just can set ngrid to 10 that it is working. To explain a bit more what I'm doing: I'm translating an existing function from R (&lt;A href="https://www.rdocumentation.org/packages/Kernelheaping/versions/1.5/topics/dshapebivr" target="_blank"&gt;https://www.rdocumentation.org/packages/Kernelheaping/versions/1.5/topics/dshapebivr&lt;/A&gt;) into SAS. This algoithm is able to estimate the density of anonymised geographical data. I'm working with the election data of Berlin (Germany). You are right 100 should be fine, then I get exact data for around 0.5 km^2. And until now there is no method available to plot it like image.plot in R, right? You can find my code and the data in the attachement, just add your path for reading in. I've already programmed all, and i get also adequate estimate without defining bwm. In that case it is not clear for me why they are good because the literature says something different. Thanks again for your help.</description>
      <pubDate>Thu, 02 Mar 2017 09:47:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/bivariate-kerneldensity-estimation-with-proc-KDE-setting-the/m-p/337281#M17781</guid>
      <dc:creator>lalilu</dc:creator>
      <dc:date>2017-03-02T09:47:56Z</dc:date>
    </item>
    <item>
      <title>Re: bivariate kerneldensity estimation with proc KDE setting the bandwith</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/bivariate-kerneldensity-estimation-with-proc-KDE-setting-the/m-p/337289#M17784</link>
      <description>a little correction: and i get also adequate estimate without defining bwm inside my algorithm. In the first kde where I calcluated a pilotestimat i choosed the bwm in the way that i cutted the number until it worked (for example 8000 to 8). I know this is not a good approach, but the result is ok.</description>
      <pubDate>Thu, 02 Mar 2017 10:32:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/bivariate-kerneldensity-estimation-with-proc-KDE-setting-the/m-p/337289#M17784</guid>
      <dc:creator>lalilu</dc:creator>
      <dc:date>2017-03-02T10:32:10Z</dc:date>
    </item>
    <item>
      <title>Re: bivariate kerneldensity estimation with proc KDE setting the bandwith</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/bivariate-kerneldensity-estimation-with-proc-KDE-setting-the/m-p/337294#M17787</link>
      <description>&lt;P&gt;&amp;gt;&amp;nbsp;&lt;SPAN&gt;there is no method available to plot it like image.plot in R, right? &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;PROC KDE provides the PLOTS= option which can plot a surface plot or contour plot&amp;nbsp;of the density estimate. If you need something fancier, you can also output the KDE and use SAS graphics to visualize the estimate. &amp;nbsp;For example, see&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.sas.com/content/iml/2015/10/12/create-surface-plot-sas.html" target="_self"&gt;How to create a surface plot in SAS&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.sas.com/content/iml/2012/07/02/create-a-contour-plot-in-sas.html" target="_self"&gt;How to create a contour plot in SAS&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2017 10:43:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/bivariate-kerneldensity-estimation-with-proc-KDE-setting-the/m-p/337294#M17787</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-03-02T10:43:59Z</dc:date>
    </item>
    <item>
      <title>Re: bivariate kerneldensity estimation with proc KDE setting the bandwith</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/bivariate-kerneldensity-estimation-with-proc-KDE-setting-the/m-p/337365#M17791</link>
      <description>&lt;P&gt;&lt;FONT color="#3366ff"&gt;Let me refer to the manual with regard to bivariate bandwidth selection:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;For the bivariate case, Wand and Jones (&lt;A href="http://support.sas.com/documentation/cdl/en/statug/68162/HTML/default/statug_kde_references.htm#statug_kdewand_m93" target="_blank"&gt;1993&lt;/A&gt;) note that automatic bandwidth selection is both difficult and computationally expensive. Their study of various ways of specifying a bandwidth matrix also shows that using two bandwidths, one in each coordinate’s direction, is often adequate. PROC KDE enables you to adjust the two bandwidths by specifying a multiplier for the default bandwidths recommended by Bowman and Foster (&lt;A href="http://support.sas.com/documentation/cdl/en/statug/68162/HTML/default/statug_kde_references.htm#statug_kdebowm_a93" target="_blank"&gt;1993&lt;/A&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV class="AAmathobject"&gt;&lt;IMG width="114" height="42" class="math" alt="\begin{eqnarray*} h_{X} &amp;amp; =&amp;amp; {\hat\sigma }_{X}n^{-1/6} \\ h_{Y} &amp;amp; =&amp;amp; {\hat\sigma }_{Y}n^{-1/6} \end{eqnarray*}" src="http://support.sas.com/documentation/cdl/en/statug/68162/HTML/default/images/statug_kde0109.png" border="0" /&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Here &lt;IMG width="16" height="13" class="math" style="vertical-align: -2px;" alt="${\hat\sigma }_{X}$" src="http://support.sas.com/documentation/cdl/en/statug/68162/HTML/default/images/statug_kde0110.png" border="0" /&gt; and &lt;IMG width="15" height="13" class="math" style="vertical-align: -2px;" alt="${\hat\sigma }_{Y}$" src="http://support.sas.com/documentation/cdl/en/statug/68162/HTML/default/images/statug_kde0111.png" border="0" /&gt; are the sample standard deviations of &lt;SPAN class=" AAmathtext"&gt;X&lt;/SPAN&gt; and &lt;SPAN class=" AAmathtext"&gt;Y&lt;/SPAN&gt;, respectively. These are the optimal bandwidths for two independent normal variables that have the same variances as &lt;SPAN class=" AAmathtext"&gt;X&lt;/SPAN&gt; and &lt;SPAN class=" AAmathtext"&gt;Y&lt;/SPAN&gt;. They are, therefore, conservative in the sense that they tend to oversmooth the surface.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#3366ff"&gt;The bandwidth calculation due to Bowman and Foster&amp;nbsp;is performed internally by PROC KDE, and the initial bandwidths are set accordingly.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;You can specify the BWM= option to adjust the aforementioned bandwidths to provide the appropriate amount of smoothing for your application.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#3366ff"&gt;The final&amp;nbsp;bandwidth used for computing the KDE is the initial bandwidth times BWM.&amp;nbsp; If you want more&amp;nbsp;smoothing than the default, set&amp;nbsp;BWM &amp;gt; 1.0.&amp;nbsp; If you want less smoothing than the default, set BMW &amp;lt; 1.0.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#3366ff"&gt;Your IML code&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*  calculate bwm plug-in;
proc iml;
    use data;
    read all var {X Y FREQ} into xy;
    n=sum(xy[,3]);
    stdx=std(xy[,1])/(n**(1/6));
    call symput("stdxg", char(stdx));
    stdy=std(xy[,2])/(n**(1/6));
    call symput("stdyg", char(stdy));
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#3366ff"&gt;duplicates the internal initial bandwidth calculation.&amp;nbsp; When you set BWM to &amp;amp;stdxg and &amp;amp;stdyg in&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc kde data=data;
bivar (X (bwm=&amp;amp;stdxg ngrid=&amp;amp;gridsize gridl=&amp;amp;minX gridu=&amp;amp;maxX ) 
       Y (bwm=&amp;amp;stdyg ngrid=&amp;amp;gridsize gridl=&amp;amp;minY gridu=&amp;amp;maxY )) / plots=all;
       freq FREQ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#3366ff"&gt;the final bandwidth used to calculate the KDE is the variance in each dimension rather than the standard deviation.&amp;nbsp; Is this what you want?&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2017 14:24:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/bivariate-kerneldensity-estimation-with-proc-KDE-setting-the/m-p/337365#M17791</guid>
      <dc:creator>dougc</dc:creator>
      <dc:date>2017-03-02T14:24:07Z</dc:date>
    </item>
    <item>
      <title>Re: bivariate kerneldensity estimation with proc KDE setting the bandwith</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/bivariate-kerneldensity-estimation-with-proc-KDE-setting-the/m-p/337390#M17792</link>
      <description>this was exactly my Problem. Thank you very much for your help.</description>
      <pubDate>Thu, 02 Mar 2017 14:57:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/bivariate-kerneldensity-estimation-with-proc-KDE-setting-the/m-p/337390#M17792</guid>
      <dc:creator>lalilu</dc:creator>
      <dc:date>2017-03-02T14:57:58Z</dc:date>
    </item>
  </channel>
</rss>

