maxLik
package to perform its estimations.
ihs.mle(X.f, mu.f = mu ~ mu, sigma.f = sigma ~ sigma,
lambda.f = lambda ~ lambda, k.f = k ~ k, data = parent.frame(),
start, subset, method = 'BFGS', constraints = NULL,
follow.on = FALSE, iterlim = 5000, ...)
X
should be on the left-hand side and the right-hand side should be the data or function of the data that should be used.mu
, sigma
, lambda
, and k
should be on the left-hand side of these formulas respectively.formula
and weights
. Can also be a list or an environment.NULL
for unconstrained optimization
or a list with two components. The components may be either
eqA
and eqB
for equality-constrained optimization
$A %*% theta + B = 0$; or ineqA
and
ineqB
for inequality constraints $A
%*% theta + B > 0$. More
than one
row in ineqA
and ineqB
corresponds to more than
one linear constraint, in that case all these must be zero
(equality) or positive (inequality constraints).method
, gives the maximum number of iterations or function values for the corresponding method. If a single number is provided, this will be used for all methods.maxLik
package. See below for a non-exhaustive list of some further arguments that can be used.ihs.mle
returns a list of class "MLE"
.
If multiple methods are given, ihs.mle
returns a list of class "mult.MLE"
with each component containing the results of each maximisation procedure. Each component is a list of class "MLE"
.
A list of class "MLE"
has the following components:
start
fn
value at maximum (the last calculated value
if not converged).estimate
evaluated at each observation (only if grad
returns a matrix
or grad
is not specified and fn
returns a vector).steptol
.
code
.code=3
with following components:
fn
value at theta0
NULL
if unconstrained). Includes the following components:
start
. If there is a name of a parameter or some data found on the right-hand side of one of the formulas but not found in data
and not found in start
, then an error is given.
Below is a non-exhaustive list of further arguments that may be passed in to the ihs.mle
function (see maxLik
documentation for more details):
fixed
start
). May not be used in BHHH
algorithm.
print.level
tol
, reltol
optim
). May not be used in BHHH
algorithm.
finalHessian
FALSE
(not calculate), TRUE
(use analytic/numeric
Hessian) or "bhhh"
/"BHHH"
for information equality
approach.
parscale
optim
). May not be used in BHHH
algorithm.
Note that not all arguments may be used for every maximisation algorithm at this time. If multiple methods are supplied (i.e. length(method) > 1
), all arguments are employed for each method (except for iterlim
, which is allowed to vary for different methods).
If multiple methods are supplied, and some methods fail to initialise properly, a warning will be given. If every method fails to initialise, an error is given.
maxLik
package and its documentation. The ihs.mle
simply uses its functions to maximize the inverse hyperbolic sine log-likelihood.
### Showing how to fit a simple vector of data to the inverse
### hyperbolic sine distribution.
require(graphics)
require(stats)
set.seed(123456)
x = rnorm(100)
X.f = X ~ x
start = list(mu = 0, sigma = 2, lambda = 0, k = 1)
result = ihs.mle(X.f = X.f, start = start)
sumResult = summary(result)
print(result)
coef(result)
print(sumResult)
### Comparing the fit
xvals = seq(-5, 5, by = 0.05)
coefs = coef(result)
mu = coefs[1]
sigma = coefs[2]
lambda = coefs[3]
k = coefs[4]
plot(xvals, dnorm(xvals), type = "l", col = "blue")
lines(xvals, dihs(xvals, mu = mu, sigma = sigma,
lambda = lambda, k = k), col = "red")
Run the code above in your browser using DataLab