<?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 Negative residual values with heatmap in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Negative-residual-values-with-heatmap/m-p/587719#M167880</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I&amp;nbsp;have a large dataset(&amp;gt;5,000,000 observations) and I'm trying a few different models with an insurance cost(OOP,or out of pocket)&amp;nbsp;as the outcome.There are lots of zeros in the outcome variable,so I'm trying PROC HPGENSELECT with a Tweedie&amp;nbsp;or ZINB distributions(separate models),&lt;/P&gt;&lt;P&gt;When I try to do a heat map of the residuals or standardised residuals v. the predicted observations,the map won't show the negative residuals in the y axis.&lt;/P&gt;&lt;P&gt;I'm using&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods graphics on/MAXOBS=5565474 NXYBINSMAX= 673740588;
proc sgplot data=ZINB_resid_stan;
heatmap x=predZINB_OOP y=resid_stan;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Do I need some more code to make the heatmap show the negative values? I've attached an example of the heatmap output.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;</description>
    <pubDate>Wed, 11 Sep 2019 04:44:31 GMT</pubDate>
    <dc:creator>daltonchris7720</dc:creator>
    <dc:date>2019-09-11T04:44:31Z</dc:date>
    <item>
      <title>Negative residual values with heatmap</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Negative-residual-values-with-heatmap/m-p/587719#M167880</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I&amp;nbsp;have a large dataset(&amp;gt;5,000,000 observations) and I'm trying a few different models with an insurance cost(OOP,or out of pocket)&amp;nbsp;as the outcome.There are lots of zeros in the outcome variable,so I'm trying PROC HPGENSELECT with a Tweedie&amp;nbsp;or ZINB distributions(separate models),&lt;/P&gt;&lt;P&gt;When I try to do a heat map of the residuals or standardised residuals v. the predicted observations,the map won't show the negative residuals in the y axis.&lt;/P&gt;&lt;P&gt;I'm using&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods graphics on/MAXOBS=5565474 NXYBINSMAX= 673740588;
proc sgplot data=ZINB_resid_stan;
heatmap x=predZINB_OOP y=resid_stan;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Do I need some more code to make the heatmap show the negative values? I've attached an example of the heatmap output.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2019 04:44:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Negative-residual-values-with-heatmap/m-p/587719#M167880</guid>
      <dc:creator>daltonchris7720</dc:creator>
      <dc:date>2019-09-11T04:44:31Z</dc:date>
    </item>
    <item>
      <title>Re: Negative residual values with heatmap</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Negative-residual-values-with-heatmap/m-p/587819#M167911</link>
      <description>&lt;P&gt;I suspect if you add&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; REFLINE 0 / axis=y;&lt;/P&gt;
&lt;P&gt;you will see that the negative bins are actually there. You can use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC MEANS data=ZINB_resid_stan;&lt;BR /&gt;var resid_stan;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;to find the minimum value of resid_stan, which I'd guess to be about -3.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The following example shows that the HEATMAP statement can, indeed, show negative values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
call streaminit(1);
do i = 1 to 10000;
   x = rand("Normal");
   y = rand("Normal");
   output;
end;
run;

proc sgplot data=test;
  heatmap x=x y=y;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 Sep 2019 12:53:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Negative-residual-values-with-heatmap/m-p/587819#M167911</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2019-09-11T12:53:28Z</dc:date>
    </item>
    <item>
      <title>Re: Negative residual values with heatmap</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Negative-residual-values-with-heatmap/m-p/588441#M168179</link>
      <description>&lt;P&gt;Thanks Ric.&lt;/P&gt;&lt;P&gt;Unfortunately I updated the dataset I am analysing and I'm now getting this message:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;The default number of heatmap bins exceeds the maximum possible number of bins.  The heatmap is not produced.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I haven't increased the number of observations greatly (5565474 to 5723125) so I'm not sure why it is doing this now.&lt;/P&gt;&lt;P&gt;With the smaller dataset, the log was giving me the option of increasing the NXYBINMAX as well as the MAXOBS but it's not doing this now. Maybe I've just hit the limit!&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2019 06:18:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Negative-residual-values-with-heatmap/m-p/588441#M168179</guid>
      <dc:creator>daltonchris7720</dc:creator>
      <dc:date>2019-09-13T06:18:57Z</dc:date>
    </item>
    <item>
      <title>Re: Negative residual values with heatmap</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Negative-residual-values-with-heatmap/m-p/588486#M168197</link>
      <description>&lt;P&gt;What is the goal of your analysis?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The HEATMAP statement approximates the density of the scatter plot. With that many bins, each box shows the count for a very small region. There are other ways to get similar information, as detailed in the article &lt;A href="https://blogs.sas.com/content/iml/2019/08/07/essential-guide-binning-sas.html" target="_self"&gt;"The Essential Guide to Binning in SAS."&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;The section on 2-D binning links to information about PROC KDE and using SAS/IML to compute the counts.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you use PROC KDE, the syntax might look something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc kde data=sashelp.heart;
  bivar cholesterol systolic / bwm=0.5 plots=contour ngrid=250;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you use PROC IML (or even the DATA step) to compute the counts within each bin, you can then create a scatter point where each point is the center of the bin and the color of the marker represents the count.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2019 11:52:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Negative-residual-values-with-heatmap/m-p/588486#M168197</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2019-09-13T11:52:25Z</dc:date>
    </item>
    <item>
      <title>Re: Negative residual values with heatmap</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Negative-residual-values-with-heatmap/m-p/588801#M168336</link>
      <description>&lt;P&gt;Thanks again Rick.&lt;/P&gt;&lt;P&gt;The goal here is just to get a view of the usual residual scatter plots(standardised residuals v.predicted outcome etc.) and a scatter plot of observations v. predicted outcomes.&lt;/P&gt;&lt;P&gt;The outcome is the out of pocket expense I mentioned in another post(trying to use PROC HPFMM), modelled here as a continuous outcome using PROC HPREG(OLS model) and PROC HPGENSELECT (with a Tweedie distribution). I'm also trying to model it as a count outcome with PROC HPGENSELECT and a ZINB distribution.&lt;/P&gt;&lt;P&gt;So I'm looking at the residuals, or trying to, with these models.&lt;/P&gt;&lt;P&gt;Despite the large dataset, these models are not very "accurate", but I guess I don't have the "correct" predictor variables. Like trying to model stock prices, I suspect.&lt;/P&gt;&lt;P&gt;A logistic model seems more useful, modelling the out of pocket expense as binary.&lt;/P&gt;&lt;P&gt;I'll investigate the guide to binning.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Sun, 15 Sep 2019 06:37:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Negative-residual-values-with-heatmap/m-p/588801#M168336</guid>
      <dc:creator>daltonchris7720</dc:creator>
      <dc:date>2019-09-15T06:37:07Z</dc:date>
    </item>
    <item>
      <title>Re: Negative residual values with heatmap</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Negative-residual-values-with-heatmap/m-p/588816#M168341</link>
      <description>&lt;P&gt;If that is your goal, you do not need as many bins as you are using. A typical graph uses about 600 horizontal pixels and 400 vertical pixels for the graph area. To make a heat map on a fine scale, you probably want between 1-5 pixels per bin. It certainly doesn't make sense to use more than (600 X 400) bins!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try using about 200 bins in each direction and see if that enables you to see the density of the data at the scale you are interested in:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=Have;
   heatmap x=x1 y=x2 / nxbins=200 nybins=200;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 15 Sep 2019 09:41:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Negative-residual-values-with-heatmap/m-p/588816#M168341</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2019-09-15T09:41:01Z</dc:date>
    </item>
    <item>
      <title>Re: Negative residual values with heatmap</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Negative-residual-values-with-heatmap/m-p/588916#M168365</link>
      <description>&lt;P&gt;Thanks Rick.&lt;/P&gt;&lt;P&gt;Always simple when you know how.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2019 00:33:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Negative-residual-values-with-heatmap/m-p/588916#M168365</guid>
      <dc:creator>daltonchris7720</dc:creator>
      <dc:date>2019-09-16T00:33:07Z</dc:date>
    </item>
  </channel>
</rss>

