<?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: Maximum likelihood estimation: Inverse Gamma Distribution in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Maximum-likelihood-estimation-Inverse-Gamma-Distribution/m-p/290043#M2930</link>
    <description>&lt;P&gt;Thank you very much Rick. I change the way to generate random variate from the inverse gamma distribution. Now I'm using this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;start rinvgama(n,alpha,beta);
	aux	= j(n,1);                
	call randgen(aux, "Gamma", alpha, 1/beta);
	rg	= 1/aux; 		
	return(rg);
finish;&lt;/PRE&gt;</description>
    <pubDate>Sun, 07 Aug 2016 19:38:48 GMT</pubDate>
    <dc:creator>AndreMenezes</dc:creator>
    <dc:date>2016-08-07T19:38:48Z</dc:date>
    <item>
      <title>Maximum likelihood estimation: Inverse Gamma Distribution</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Maximum-likelihood-estimation-Inverse-Gamma-Distribution/m-p/290026#M2928</link>
      <description>&lt;P&gt;I'm tryng to find MLE from inverse gamma distribution using SAS/IML, however when I run optmization appear an error. I suposse the error is because the function '&lt;EM&gt;l'&lt;/EM&gt; underflow. I have seen the Rick's blog about MLE (&lt;A href="http://blogs.sas.com/content/iml/2011/10/12/maximum-likelihood-estimation-in-sasiml.html" target="_blank"&gt;http://blogs.sas.com/content/iml/2011/10/12/maximum-likelihood-estimation-in-sasiml.html&lt;/A&gt;) and write this code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc iml;
/*Quantile*/
start qinvgama(p,alpha,beta);
    qf = 1/quantile("GAMMA",1-p,alpha,beta);
    return(qf);
finish;
/*Variate*/
start rinvgama(n,alpha,beta);
    u  = j(n,1);                
    call randgen(u, "Uniform");
    rg     = qinvgama(u,alpha,beta);
    return(rg);
finish;

start MLE(par) global (x);
   alpha    =     par[1];
   beta     =     par[2];
   n        =    nrow(x);
   l        = n#(alpha#log(beta) - log(gamma(alpha))) - beta#sum(1/x) - (alpha + 1)#sum(log(x));
   return (l);
finish;

x = rinvgama(100,2,3);
sup = { 0   0,  
        .   .};
ini = {1.2 3};
opt = {1, 4};
call nlpnra(it, resmle, "MLE", ini, opt, sup);

print resmle;

quit;


&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;ERROR: (execution) Invalid argument to function.&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 07 Aug 2016 13:04:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Maximum-likelihood-estimation-Inverse-Gamma-Distribution/m-p/290026#M2928</guid>
      <dc:creator>AndreMenezes</dc:creator>
      <dc:date>2016-08-07T13:04:27Z</dc:date>
    </item>
    <item>
      <title>Re: Maximum likelihood estimation: Inverse Gamma Distribution</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Maximum-likelihood-estimation-Inverse-Gamma-Distribution/m-p/290034#M2929</link>
      <description>&lt;P&gt;I think the error message is telling you that the parameters need to be strictly positive. Try&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;sup = { 1e-8 1e-8, 
         .    .};&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also, there is an easier way to generate from the inverse gamma:&lt;/P&gt;
&lt;P&gt;If X ~ gamma(a, b) then 1/X ~ inverse-gamma(a, 1/b)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Some other facts about the inverse gamma distribution is available in the MCMC documentation:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/statug/68162/HTML/default/viewer.htm#statug_mcmc_details17.htm" target="_self"&gt;- Definition&lt;/A&gt;&amp;nbsp;(search for igamma)&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/statug/68162/HTML/default/viewer.htm#statug_mcmc_details51.htm" target="_self"&gt;- Potential confusion of parameters&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 07 Aug 2016 17:28:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Maximum-likelihood-estimation-Inverse-Gamma-Distribution/m-p/290034#M2929</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-08-07T17:28:49Z</dc:date>
    </item>
    <item>
      <title>Re: Maximum likelihood estimation: Inverse Gamma Distribution</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Maximum-likelihood-estimation-Inverse-Gamma-Distribution/m-p/290043#M2930</link>
      <description>&lt;P&gt;Thank you very much Rick. I change the way to generate random variate from the inverse gamma distribution. Now I'm using this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;start rinvgama(n,alpha,beta);
	aux	= j(n,1);                
	call randgen(aux, "Gamma", alpha, 1/beta);
	rg	= 1/aux; 		
	return(rg);
finish;&lt;/PRE&gt;</description>
      <pubDate>Sun, 07 Aug 2016 19:38:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Maximum-likelihood-estimation-Inverse-Gamma-Distribution/m-p/290043#M2930</guid>
      <dc:creator>AndreMenezes</dc:creator>
      <dc:date>2016-08-07T19:38:48Z</dc:date>
    </item>
    <item>
      <title>Re: Maximum likelihood estimation: Inverse Gamma Distribution</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Maximum-likelihood-estimation-Inverse-Gamma-Distribution/m-p/291797#M2948</link>
      <description>&lt;P&gt;While searching my blog for something, I realized that I blogged about how to simulate from the inverse gamma distriution in 2014:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.sas.com/content/iml/2014/04/30/simulating-from-the-inverse-gamma-distribution-in-sas.html" target="_self"&gt;"Simulating from the Inverse Gamma Distribution in SAS"&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2016 00:51:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Maximum-likelihood-estimation-Inverse-Gamma-Distribution/m-p/291797#M2948</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-08-16T00:51:22Z</dc:date>
    </item>
  </channel>
</rss>

