distributionFits {fBasics} | R Documentation |
A collection of maximum likelihood estimators to fit the
parameters of a distribution and to compute basic statistical
properties. Included are estimators for the Student-t, the
hyperbolic and the normal inverse Gaussian distributions.
The functions are:
1 | tFit | MLE parameter fit for a Student t-distribution, |
2 | hypFit | MLE parameter fit for a hyperbolic distribution, |
3 | hypStats | Computes Mean and Variance for a hyperbolic dist, |
4 | nigFit | MLE parameter fit for a normal inverse Gaussian distribution. |
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), ...) hypStats(alpha = 1, beta = 0, delta = 1, mu = 0)
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 .
|
The function nlm
is used to minimize the "negative" maximum
log-likelihood function. nlm
carries out a minimization using
a Newton-type algorithm.
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. |
The function hypStats
returns a list with two elements: the
mean, mean
, and the variance, var
.
Diethelm Wuertz for this R-port.
## 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)