Learn R Programming

fBasics (version 200.10058)

DistributionFits: Parameter Fit of a Distribution

Description

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: ll{ 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. }

Usage

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), ...)

Arguments

alpha, beta, delta, mu
[hypFit][nigFit][hypStats] - shape parameter alpha; skewness parameter beta with 0 < |beta| < alpha; scale parameter delta with delta <= 0<="" code="">; location par
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.

Value

  • The functions *Fit return a list with the following components:
  • estimatethe point at which the maximum value of the log liklihood function is obtained.
  • objectivethe value of the estimated maximum, i.e. the value of the log liklihood function.
  • messagean integer indicating why the optimization process terminated.
  • codean 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.
  • gradientthe gradient at the estimated maximum.
  • stepsnumber of function calls.

Details

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

See Also

dt, dhyp, dnig, nlm.

Examples

Run this code
## tFit -
   xmpBasics("Start: 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("Next: 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("Next: 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)

Run the code above in your browser using DataLab