<?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 Why &amp;quot;Invalid argument to function QUANTILE('TWEEDIE',0.025,1.3080865018,332762.58,245.31436342)&amp;quot;? in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Why-quot-Invalid-argument-to-function-QUANTILE-TWEEDIE-0-025-1/m-p/516004#M26337</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When calculating quantiles with Tweedie distribution for confidence intervals, I very often get errors in the case of lower boundaries (2.5% quantile) like in the subject line, where upper boundary (97.5% quantile) in fact works without problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See the following log file snippet to reproduce - first statements results in error, second works fine (same distribution, different prob):&amp;nbsp;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;26 %put SAS Version: &amp;amp;sysvlong;&lt;BR /&gt;SAS Version: 9.04.01M5P091317&lt;BR /&gt;27 %put Tweedie CI Lower: %sysfunc(QUANTILE(TWEEDIE,0.025,1.3080865018,332762.58,245.3143634));&lt;BR /&gt;WARNING: An argument to the function QUANTILE referenced by the %SYSFUNC or %QSYSFUNC macro function is out of range.&lt;BR /&gt;NOTE: Mathematical operations could not be performed during %SYSFUNC function execution. The result of the operations have been set&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;to a missing value.&lt;BR /&gt;Tweedie CI Lower: .&lt;BR /&gt;28 %put Tweedie CI Upper: %sysfunc(QUANTILE(TWEEDIE,0.975,1.3080865018,332762.58,245.3143634));&lt;BR /&gt;Tweedie CI Upper: 465720.907332802&lt;BR /&gt;...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I see no technical restrictions in the docs, and theoretically, also the first statement should work. Compare with R where the same 2.5% quantile computes just fine:&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&amp;gt; library("tweedie")&lt;/P&gt;&lt;P&gt;Warning message:&lt;/P&gt;&lt;P&gt;package ‘tweedie’ was built under R version 3.5.1&lt;/P&gt;&lt;P&gt;&amp;gt; qtweedie(p=0.025,xi=1.3080865018,mu=332762.58,phi=245.3143634)&lt;/P&gt;&lt;P&gt;[1] 215116.9&lt;/P&gt;&lt;P&gt;&amp;gt; qtweedie(p=0.975,xi=1.3080865018,mu=332762.58,phi=245.3143634)&lt;/P&gt;&lt;P&gt;[1] 465720.9&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone maybe suggest a workaround in SAS?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks and regards&lt;/P&gt;&lt;P&gt;Andreas&lt;/P&gt;</description>
    <pubDate>Mon, 26 Nov 2018 14:58:24 GMT</pubDate>
    <dc:creator>ADoering</dc:creator>
    <dc:date>2018-11-26T14:58:24Z</dc:date>
    <item>
      <title>Why "Invalid argument to function QUANTILE('TWEEDIE',0.025,1.3080865018,332762.58,245.31436342)"?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Why-quot-Invalid-argument-to-function-QUANTILE-TWEEDIE-0-025-1/m-p/516004#M26337</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When calculating quantiles with Tweedie distribution for confidence intervals, I very often get errors in the case of lower boundaries (2.5% quantile) like in the subject line, where upper boundary (97.5% quantile) in fact works without problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See the following log file snippet to reproduce - first statements results in error, second works fine (same distribution, different prob):&amp;nbsp;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;26 %put SAS Version: &amp;amp;sysvlong;&lt;BR /&gt;SAS Version: 9.04.01M5P091317&lt;BR /&gt;27 %put Tweedie CI Lower: %sysfunc(QUANTILE(TWEEDIE,0.025,1.3080865018,332762.58,245.3143634));&lt;BR /&gt;WARNING: An argument to the function QUANTILE referenced by the %SYSFUNC or %QSYSFUNC macro function is out of range.&lt;BR /&gt;NOTE: Mathematical operations could not be performed during %SYSFUNC function execution. The result of the operations have been set&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;to a missing value.&lt;BR /&gt;Tweedie CI Lower: .&lt;BR /&gt;28 %put Tweedie CI Upper: %sysfunc(QUANTILE(TWEEDIE,0.975,1.3080865018,332762.58,245.3143634));&lt;BR /&gt;Tweedie CI Upper: 465720.907332802&lt;BR /&gt;...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I see no technical restrictions in the docs, and theoretically, also the first statement should work. Compare with R where the same 2.5% quantile computes just fine:&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&amp;gt; library("tweedie")&lt;/P&gt;&lt;P&gt;Warning message:&lt;/P&gt;&lt;P&gt;package ‘tweedie’ was built under R version 3.5.1&lt;/P&gt;&lt;P&gt;&amp;gt; qtweedie(p=0.025,xi=1.3080865018,mu=332762.58,phi=245.3143634)&lt;/P&gt;&lt;P&gt;[1] 215116.9&lt;/P&gt;&lt;P&gt;&amp;gt; qtweedie(p=0.975,xi=1.3080865018,mu=332762.58,phi=245.3143634)&lt;/P&gt;&lt;P&gt;[1] 465720.9&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone maybe suggest a workaround in SAS?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks and regards&lt;/P&gt;&lt;P&gt;Andreas&lt;/P&gt;</description>
      <pubDate>Mon, 26 Nov 2018 14:58:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Why-quot-Invalid-argument-to-function-QUANTILE-TWEEDIE-0-025-1/m-p/516004#M26337</guid>
      <dc:creator>ADoering</dc:creator>
      <dc:date>2018-11-26T14:58:24Z</dc:date>
    </item>
    <item>
      <title>Re: Why "Invalid argument to function QUANTILE('TWEEDIE',0.025,1.3080865018,332762.58,245.31436</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Why-quot-Invalid-argument-to-function-QUANTILE-TWEEDIE-0-025-1/m-p/516014#M26338</link>
      <description>&lt;P&gt;Post your actual code.&amp;nbsp; Also, why use %sysfunc()?&amp;nbsp; SAS works on datasets, macro language is there for generating text only.&amp;nbsp; Don't confuse the two.&amp;nbsp; WHat happens when you call the function in a datastep, with proper attributes and such like?&amp;nbsp; E.g:&lt;/P&gt;
&lt;PRE&gt;data want;
  want=quantile("Tweedie",0.25,1.3080865018,332762.58,245.3143634);
run;&lt;/PRE&gt;
&lt;P&gt;This works, not sure what your trying to achieve, but isn't 0.025 a bit small?&lt;/P&gt;</description>
      <pubDate>Mon, 26 Nov 2018 15:21:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Why-quot-Invalid-argument-to-function-QUANTILE-TWEEDIE-0-025-1/m-p/516014#M26338</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-11-26T15:21:13Z</dc:date>
    </item>
    <item>
      <title>Re: Why "Invalid argument to function QUANTILE('TWEEDIE',0.025,1.3080865018,332762.58,245.31436</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Why-quot-Invalid-argument-to-function-QUANTILE-TWEEDIE-0-025-1/m-p/516020#M26339</link>
      <description>&lt;P&gt;@RW9As I said, I want to calculate Confidence Intervalls, so I need 0.025, not 0.25, even if it seems small to you... &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; If you prefer data step, I'll post what happens if I put 0.025 in your data step, makes no difference obviously:&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;27 data want;&lt;BR /&gt;28 want=quantile("Tweedie",0.025,1.3080865018,332762.58,245.3143634);&lt;BR /&gt;29 run;&lt;/P&gt;&lt;P&gt;NOTE: Compression was disabled for data set WORK.WANT because compression overhead would increase the size of the data set.&lt;BR /&gt;NOTE: Invalid argument to function QUANTILE('Tweedie',0.025,1.3080865018,332762.58,245.3143634) at line 28 column 8.&lt;BR /&gt;want=. _ERROR_=1 _N_=1&lt;BR /&gt;NOTE: Mathematical operations could not be performed at the following places. The results of the operations have been set to&lt;BR /&gt;missing values.&lt;BR /&gt;Each place is given by: (Number of times) at (Line):(Column).&lt;BR /&gt;1 at 28:8&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Nov 2018 15:38:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Why-quot-Invalid-argument-to-function-QUANTILE-TWEEDIE-0-025-1/m-p/516020#M26339</guid>
      <dc:creator>ADoering</dc:creator>
      <dc:date>2018-11-26T15:38:05Z</dc:date>
    </item>
    <item>
      <title>Re: Why "Invalid argument to function QUANTILE('TWEEDIE',0.025,1.3080865018,332762.58,245.31436</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Why-quot-Invalid-argument-to-function-QUANTILE-TWEEDIE-0-025-1/m-p/516021#M26340</link>
      <description>&lt;P&gt;Confidence intervals can mean anything, we normally use 95% for instance which is alpha=0.5.&lt;/P&gt;
&lt;P&gt;Anyways, not much more I can do for you, simply put the tweedie model stops working at 0.56 - you can try it, works with 0.56 for instance.&amp;nbsp; I am not a stato so I can't tell you why.&amp;nbsp; I will move this into the statistical section, perhaps one of them can explain the model.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Nov 2018 15:44:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Why-quot-Invalid-argument-to-function-QUANTILE-TWEEDIE-0-025-1/m-p/516021#M26340</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-11-26T15:44:55Z</dc:date>
    </item>
    <item>
      <title>Re: Why "Invalid argument to function QUANTILE('TWEEDIE',0.025,1.3080865018,332762.58,245.31436</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Why-quot-Invalid-argument-to-function-QUANTILE-TWEEDIE-0-025-1/m-p/516034#M26341</link>
      <description>&lt;P&gt;I suspect that the large values of mu and phi are leading to numerical instabilities during the quantile computation. I am not an expert in the Tweedie distribution, but you can try rescaling the parameters. The following DATA step gives the same answers as your R program, so empirically&amp;nbsp;it seems to be a good workaround.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Q;
xi = 1.3080865018;
mu = 332762.58;
phi = 245.3143634;
c = 100; /* scaling factor */
do prob = 0.01 to 0.5 by 0.005;
   x = QUANTILE('TWEEDIE', prob, xi, mu, phi);
   xScaled = c * QUANTILE('TWEEDIE', prob, xi, mu/c, phi/c**(2-xi));
   relDiff = (x - xScaled) / xScaled;
   output;
end;
label diff = "x - xScaled";
label relDiff = "(x - xScaled)/xScaled";
run;

/* scaled call produces quantiles for small probabilities */
proc print data=Q;
where x=.;
var prob x xScaled;
run;

/* when both methods produce answers, the relative difference is tiny */
proc means data=Q;
var relDiff;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Nov 2018 16:13:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Why-quot-Invalid-argument-to-function-QUANTILE-TWEEDIE-0-025-1/m-p/516034#M26341</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2018-11-26T16:13:56Z</dc:date>
    </item>
    <item>
      <title>Re: Why "Invalid argument to function QUANTILE('TWEEDIE',0.025,1.3080865018,332762.58,245.31436</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Why-quot-Invalid-argument-to-function-QUANTILE-TWEEDIE-0-025-1/m-p/516268#M26344</link>
      <description>&lt;P&gt;Great work, thanks. That was exactly what I was looking for. Saves my day.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Andreas&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2018 10:17:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Why-quot-Invalid-argument-to-function-QUANTILE-TWEEDIE-0-025-1/m-p/516268#M26344</guid>
      <dc:creator>ADoering</dc:creator>
      <dc:date>2018-11-27T10:17:41Z</dc:date>
    </item>
    <item>
      <title>Re: Why "Invalid argument to function QUANTILE('TWEEDIE',0.025,1.3080865018,332762.58,245.31436</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Why-quot-Invalid-argument-to-function-QUANTILE-TWEEDIE-0-025-1/m-p/516279#M26345</link>
      <description>&lt;P&gt;Glad to hear! I also contacted the person that&amp;nbsp;supports the Tweedie distribution, He has made changes so that this workaround will not be necessary in the next release of SAS. Unfortunately, SAS 940M6 shipped last week, but the fix should be in the 2019&amp;nbsp;release.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2018 11:16:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Why-quot-Invalid-argument-to-function-QUANTILE-TWEEDIE-0-025-1/m-p/516279#M26345</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2018-11-27T11:16:51Z</dc:date>
    </item>
  </channel>
</rss>

