Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: FindFit for the 4-parameter beta distribution

  • To: mathgroup at smc.vnet.net
  • Subject: [mg124078] Re: FindFit for the 4-parameter beta distribution
  • From: Ray Koopman <koopman at sfu.ca>
  • Date: Sun, 8 Jan 2012 04:23:49 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <je96ic$j4k$1@smc.vnet.net>

On Jan 7, 2:25 am, Anna Kaladze <anna.kala... at gmail.com> wrote:
> Hi all,
>
> I am trying to use FindFit in order to choose p and q parameters of ft
> function (which is actually a 4-parameter beta distribution) to match
> "data". I do not know why I get the Jacobean not being real warning at all
> times and also very poor-looking fitd fits. (If I do not specify starting
> guesses I get p->1 and q->1). Even if I specify starting values for p and
> q, FindFit just returns those very values. Can you please help me to have
> this curve fitting work properly? Maybe I am doing something wrong. The
> code is below.
>
> Thanks a lot.
>
> Anna.
> ------------------------------------------------------------------------------------------------------------------------------------------------
> data = {0.001581328`, 0.00159187`, 0.001865967`, 0.001823798`,
>    0.001918678`, 0.001908135`, 0.001887051`, 0.001960846`,
>    0.001939762`, 0.001908135`, 0.001897593`, 0.001992473`,
>    0.002034642`, 0.002118979`, 0.002245485`, 0.002340365`,
>    0.002435245`, 0.002487956`, 0.002625004`, 0.002962354`,
>    0.003099402`, 0.003152113`, 0.003299704`, 0.003552716`,
>    0.003953319`, 0.004153621`, 0.004712356`, 0.004954827`,
>    0.005439767`, 0.005998503`, 0.006493986`, 0.006905131`,
>    0.007537662`, 0.008465374`, 0.008834351`, 0.009646099`,
>    0.010215377`, 0.011174716`, 0.012429236`, 0.013072309`,
>    0.014274118`, 0.014885565`, 0.01645635`, 0.017099423`,
>    0.019355451`, 0.020304247`, 0.02156931`, 0.023719915`,
>    0.024858471`, 0.025881063`, 0.028010584`, 0.030445829`,
>    0.030772637`, 0.033745533`, 0.033671737`, 0.035411198`,
>    0.035716921`, 0.035822343`, 0.036064813`, 0.035643126`,
>    0.033756075`, 0.033903666`, 0.030677757`, 0.029570828`,
>    0.027009077`, 0.023677747`, 0.020915694`, 0.018375028`,
>    0.016192795`, 0.012671706`, 0.010890077`, 0.00844429`,
>    0.006451817`, 0.004617477`, 0.003700307`, 0.002403618`,
>    0.001634039`, 0.001085845`, 0.000695784`, 0.00043223`,
>    0.000253012`, 0.000147591`, 0.0000843375`, 0.0000421687`,
>    0.0000210844`, 0.0000105422`, 0.0000105422`, 0.`, 0.`, 0.`, 0.`};
>
> a = 10^-9;
>
> b = 90 + a;
>
> Gammap := Gamma[p]
>
> Gammaq := Gamma[q]
>
> Gammaplusq := Gamma[p + q]
>
> Bpq := Gammap*Gammaq/Gammaplusq
>
> ft := (((t - a)^(p - 1))*((b - t)^(q - 1)))/((b - a)^(p + q - 1))/Bpq
>
> par = FindFit[data, ft, {{p, 9}, {q, 6}}, t]
>
> FindFit::nrjnum: The Jacobian is not a matrix of real numbers at {p,q} =
> {9.,6.}. >>
>
> {p -> 9., q -> 6.}

n = Length@data  (* t is 1...n, not 0...n-1 *)
91

eps = 10^-9;
{a,b} = {1-eps, n+eps};
ft := (((t-a)^(p-1))*((b-t)^(q-1)))/((b-a)^(p+q-1))/Beta[p,q]

par = FindFit[data, ft, {{p,9}, {q,6}}, t]
{p -> 9.19343, q -> 6.11004}

You're right -- the fit is poor. In particular,
the left tail of the data does not go to zero as it should.
Are you sure that the distribution is a beta?



  • Prev by Date: Re: ParametricPlot3D vs Reduce
  • Next by Date: Re: Extension to BinLists Function
  • Previous by thread: FindFit for the 4-parameter beta distribution
  • Next by thread: MatrixPower problem