<?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: Log Likelihood for BETA distribution in Proc NLMIXED in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Log-Likelihood-for-BETA-distribution-in-Proc-NLMIXED/m-p/851882#M42167</link>
    <description>&lt;P&gt;If you want to fit a model to a response variable that is distributed as beta, then you can use the FMM or GLIMMIX procedure. Specify DIST=BETA in the MODEL statement. If your goal is to estimate the parameters of the beta distribution for one population, you can use the HISTOGRAM statement in PROC UNIVARIATE as mentioned in &lt;A href="http://support.sas.com/kb/23135" target="_self"&gt;this note&lt;/A&gt;.&lt;/P&gt;</description>
    <pubDate>Tue, 03 Jan 2023 03:15:13 GMT</pubDate>
    <dc:creator>StatDave</dc:creator>
    <dc:date>2023-01-03T03:15:13Z</dc:date>
    <item>
      <title>Log Likelihood for BETA distribution in Proc NLMIXED</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Log-Likelihood-for-BETA-distribution-in-Proc-NLMIXED/m-p/851880#M42166</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm trying to estimate the beta distribution parameters (alpha, beta) using Proc NLMIXED. Because beta is not one of the distributions with built-in log likelihood, I used the general statement as follows:&lt;/P&gt;&lt;PRE&gt;proc nlmixed data=test;&lt;BR /&gt;  parms a=5 b=5;&lt;BR /&gt;  *s=beta(a,b);&lt;BR /&gt;  s=gamma(a*b)/(gamma(a)*gamma(b));&lt;BR /&gt;  ll=(1-a)*xbeta+(1-b)*(1-xbeta)-log(s);&lt;BR /&gt;  model xbeta~general(ll);&lt;BR /&gt;run;&lt;/PRE&gt;&lt;P&gt;I tried using the beta function directly and with gamma function. Both gave me the 'QUANEW optimization cannot be completed' error.&lt;/P&gt;&lt;P&gt;The test data is just 1000 beta variates with alpha=beta=5. I even set the initial values to 5, but still got this error.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anne&lt;/P&gt;</description>
      <pubDate>Tue, 03 Jan 2023 02:30:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Log-Likelihood-for-BETA-distribution-in-Proc-NLMIXED/m-p/851880#M42166</guid>
      <dc:creator>LadyIDO</dc:creator>
      <dc:date>2023-01-03T02:30:15Z</dc:date>
    </item>
    <item>
      <title>Re: Log Likelihood for BETA distribution in Proc NLMIXED</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Log-Likelihood-for-BETA-distribution-in-Proc-NLMIXED/m-p/851882#M42167</link>
      <description>&lt;P&gt;If you want to fit a model to a response variable that is distributed as beta, then you can use the FMM or GLIMMIX procedure. Specify DIST=BETA in the MODEL statement. If your goal is to estimate the parameters of the beta distribution for one population, you can use the HISTOGRAM statement in PROC UNIVARIATE as mentioned in &lt;A href="http://support.sas.com/kb/23135" target="_self"&gt;this note&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Jan 2023 03:15:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Log-Likelihood-for-BETA-distribution-in-Proc-NLMIXED/m-p/851882#M42167</guid>
      <dc:creator>StatDave</dc:creator>
      <dc:date>2023-01-03T03:15:13Z</dc:date>
    </item>
    <item>
      <title>Re: Log Likelihood for BETA distribution in Proc NLMIXED</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Log-Likelihood-for-BETA-distribution-in-Proc-NLMIXED/m-p/851965#M42170</link>
      <description>&lt;P&gt;First, the beta function is&amp;nbsp;&lt;/P&gt;
&lt;P&gt;s=gamma(&lt;FONT color="#FF0000"&gt;a+b&lt;/FONT&gt;)/(gamma(a)*gamma(b));&lt;/P&gt;
&lt;P&gt;not&lt;/P&gt;
&lt;P&gt;s=gamma(&lt;FONT color="#FF0000"&gt;a*b&lt;/FONT&gt;)/(gamma(a)*gamma(b));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, the beta distribution when a=b is somewhat degenerate, in the sense that the mean is exactly 1/2. This might be relevant for your nonconvergence issues. I'm not sure.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But if you want to use PROC NLMIXED, the easiest way is to specify the LOGPDF of the beta distribution directly:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
call streaminit(54321);
do i = 1 to 1000;
   xbeta = rand("Beta", 5, 5);
   output;
end;
run;

proc nlmixed data=test;
  parms a=4 b=5.5;
  ll= logpdf("Beta", xbeta, a, b);;
  model xbeta~general(ll);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 03 Jan 2023 14:18:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Log-Likelihood-for-BETA-distribution-in-Proc-NLMIXED/m-p/851965#M42170</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2023-01-03T14:18:31Z</dc:date>
    </item>
    <item>
      <title>Re: Log Likelihood for BETA distribution in Proc NLMIXED</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Log-Likelihood-for-BETA-distribution-in-Proc-NLMIXED/m-p/851986#M42171</link>
      <description>&lt;P&gt;Thank you so much Rick! Using logpdf did it! I didn't know about logpdf function. This would really help with future work needing log likelihood.&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;P&gt;Anne&lt;/P&gt;</description>
      <pubDate>Tue, 03 Jan 2023 15:32:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Log-Likelihood-for-BETA-distribution-in-Proc-NLMIXED/m-p/851986#M42171</guid>
      <dc:creator>LadyIDO</dc:creator>
      <dc:date>2023-01-03T15:32:46Z</dc:date>
    </item>
    <item>
      <title>Re: Log Likelihood for BETA distribution in Proc NLMIXED</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Log-Likelihood-for-BETA-distribution-in-Proc-NLMIXED/m-p/851988#M42172</link>
      <description>&lt;PRE&gt;I was trying to understand how to use nlmixed to estimate parameters of &lt;BR /&gt;less common distribution like the following for beta-binomial. I didn't know about&lt;BR /&gt;FMM before. I'll check it out. Thanks.&lt;BR /&gt;&lt;BR /&gt;proc nlmixed data=&amp;amp;data fconv=1E-14 df=&amp;amp;rdf alpha=0.05 ecov cov;&lt;BR /&gt;  parms mu=0.5 gamma=0.5;&lt;BR /&gt;  bounds mu&amp;gt;=0, mu&amp;lt;=1, gamma&amp;gt;0, gamma&amp;lt;1;&lt;BR /&gt;  ll=0;&lt;BR /&gt;  theta=gamma/(1-gamma);&lt;BR /&gt;  do i=1 to &amp;amp;ntrials;&lt;BR /&gt;    if i&amp;lt;=&amp;amp;nsucc&lt;BR /&gt;      then ll=ll+log(mu+(i-1)*theta);&lt;BR /&gt;        else ll=ll+log((1-mu)+(i-&amp;amp;nsucc-1)*theta);&lt;BR /&gt;    ll=ll-log(1+(i-1)*theta);&lt;BR /&gt;  end;&lt;BR /&gt;  alpha=mu/theta;&lt;BR /&gt;  beta=(1-mu)/theta;&lt;BR /&gt;  model &amp;amp;nsucc~general(ll);&lt;BR /&gt;run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 03 Jan 2023 15:39:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Log-Likelihood-for-BETA-distribution-in-Proc-NLMIXED/m-p/851988#M42172</guid>
      <dc:creator>LadyIDO</dc:creator>
      <dc:date>2023-01-03T15:39:58Z</dc:date>
    </item>
  </channel>
</rss>

