DistributionFits           package:fBasics           R Documentation

_P_a_r_a_m_e_t_e_r _F_i_t _o_f _a _D_i_s_t_r_i_b_u_t_i_o_n

_D_e_s_c_r_i_p_t_i_o_n:

     A collection and description of maximum likelihood  estimators to
     fit the parameters of a distribution.  Included are estimators for
     the Student-t, the  hyperbolic and the normal inverse Gaussian
     distributions.  

     The functions are:

       'tFit'    MLE parameter fit for a Student t-distribution,
       'hypFit'  MLE parameter fit for a hyperbolic distribution,
       'nigFit'  MLE parameter fit for a normal inverse Gaussian distribution.

_U_s_a_g_e:

     tFit(x, df, doplot = TRUE, 
         span = seq(from = -10, to = 10, by = 0.1), ...)
     hypFit(x, alpha = 1, beta = 0, delta = 1, mu = 0, doplot = TRUE, 
         span = seq(from = -10, to = 10, by = 0.1), ...)
     nigFit(x, alpha = 1, beta = 0, delta = 1, mu = 0, doplot = TRUE, 
         span = seq(from = -10, to = 10, by = 0.1), ...)

_A_r_g_u_m_e_n_t_s:

alpha, beta, delta, mu: [hypFit][nigFit][hypStats] - shape parameter
          'alpha';  skewness parameter 'beta' with '0 < |beta| <
          alpha'; scale parameter 'delta' with 'delta <= 0';  location
          parameter 'mu'. 

      df: [tFit] - the number of degrees of freedom for the Student
          distribution,  'df > 2', maybe non-integer. 

  doplot: a logical. Should a plot be displayed? 

    span: x-coordinates for the plot, by default 201 values  ranging
          between -10 and +10. 

       x: a numeric vector. 

     ...: parameters parsed to the function 'density'. 

_D_e_t_a_i_l_s:

     The function 'nlm' is used to minimize the "negative" maximum 
     log-likelihood function. 'nlm' carries out a minimization using  a
     Newton-type algorithm.

_V_a_l_u_e:

     The functions '*Fit' return a list with the following components:

estimate: the point at which the maximum value of the log liklihood 
          function is obtained. 

objective: the value of the estimated maximum, i.e. the value of the
          log liklihood function. 

 message: an integer indicating why the optimization process
          terminated. 

    code: an integer indicating why the optimization process
          terminated.
           1: relative gradient is close to zero, current iterate is
          probably  solution; 
           2: successive iterates within tolerance, current iterate is
          probably  solution; 
           3: last global step failed to locate a point lower than
          'estimate'.  Either 'estimate' is an approximate local
          minimum of the  function or 'steptol' is too small; 
           4: iteration limit exceeded; 
           5: maximum step size 'stepmax' exceeded five consecutive
          times.  Either the function is unbounded below, becomes
          asymptotic to a  finite value from above in some direction or
          'stepmax'  is too small. 

gradient: the gradient at the estimated maximum. 

   steps: number of function calls. 

_A_u_t_h_o_r(_s):

     Diethelm Wuertz for the Rmetrics R-port.

_S_e_e _A_l_s_o:

     'dt', 'dhyp',  'dnig',  'nlm'.

_E_x_a_m_p_l_e_s:

     ## tFit -
        xmpBasics("\nStart: MLE Fit to Student's t Density > ")
        par(mfrow = c(2,2), cex = 0.7, err = -1)
        options(warn = -1)
        # Simulated random variates t(4):
        s = rt(n = 10000, df = 4) 
        # Note, this may take some time.
        # Starting vector:
        df.startvalue = 2*var(s)/(var(s)-1)
        tFit(s, df.startvalue, doplot = TRUE)
        
     ## hypFit -
        xmpBasics("\nNext: MLE Fit to Hyperbolic Density > ")
        # Simulated random variates HYP(1, 0.3, 1, -1):
        s = rhyp(n = 1000, alpha = 1.5, beta = 0.3, delta = 0.5, mu = -1) 
        # Note, this may take some time.
        # Starting vector (1, 0, 1, mean(s)):
        hypFit(s, alpha = 1, beta = 0, delta = 1, mu = mean(s), 
          doplot = TRUE, width = 0.5)
        
     ## nigFit -
        xmpBasics("\nNext: MLE Fit to Normal Inverse Gaussian Density > ")
        # Simulated random variates HYP(1.5, 0.3, 0.5, -1.0):
        s = rnig(n = 10000, alpha = 1.5, beta = 0.3, delta = 0.5, mu = -1.0) 
        # Note, this may take some time.
        # Starting vector (1, 0, 1, mean(s)):
        nigFit(s, alpha = 1, beta = 0, delta = 1, mu = mean(s), doplot = TRUE)

