maxlogL: Maximum Likelihood Estimation for parametric distributions

Description Usage Arguments Details Value Note Author(s) References See Also Examples

View source: R/maxlogL.R

Description

Function to compute maximum likelihood estimators (MLE) of any distribution implemented in R.

Usage

1
2
3
maxlogL(x, dist = "dnorm", fixed = NULL, link = NULL, start = NULL,
  lower = NULL, upper = NULL, optimizer = "nlminb", control = NULL,
  ...)

Arguments

x

a vector with data to be fitted. This argument must be a matrix with hierarchical distributions.

dist

a length-one character vector with the name of density/mass function of interest. The default value is "dnorm", to compute maximum likelihood estimators of normal distribution.

fixed

a list with fixed/known parameters of distribution of interest. Fixed parameters must be passed with its name.

link

a list with names of parameters to be linked, and names of the link function object. For names of parameters, please visit documentation of density/mass function. There are three link functions available: log_link, logit_link and NegInv_link.

start

a numeric vector with initial values for the parameters to be estimated.

lower

a numeric vector with lower bounds, with the same lenght of argument 'start' (for box-constrained optimization).

upper

a numeric vector with upper bounds, with the same lenght of argument 'start' (for box-constrained optimization).

optimizer

a lenght-one character vector with the name of optimization routine. nlminb, optim and DEoptim are available; nlminb is the default routine.

control

control parameters of the optimization routine. Please, visit documentation of selected optimizer for further information.

...

Further arguments to be supplied to the optimizer.

Details

maxlogL calculates computationally the likelihood function corresponding to the distribution specified in argument dist and maximizes it through optim, nlminb or DEoptim. maxlogL generates an S3 object of class maxlogL.

Value

A list with class "maxlogL" containing the following lists:

fit

A list with output information about estimation and method used.

inputs

A list with all input arguments.

outputs

A list with some output additional information:

  • Number of parameters.

  • Sample size

  • Standard error computation method.

Note

The following generic functions can be used with a maxlogL object: summary, print.

Author(s)

Jaime Mosquera Gutiérrez, [email protected]

References

\insertRef

Nelder1965EstimationTools

\insertRef

Fox1978EstimationTools

\insertRef

Nash1979EstimationTools

\insertRef

Dennis1981EstimationTools

See Also

summary.maxlogL, optim, nlminb, DEoptim, DEoptim.control

Other maxlogL: maxlogLreg

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#--------------------------------------------------------------------------------
# Estimation with one fixed parameter
x <- rnorm(n = 10000, mean = 160, sd = 6)
theta_1 <- maxlogL(x = x, dist = 'dnorm', control = list(trace = 1),
                 link = list(over = "sd", fun = "log_link"),
                 fixed = list(mean = 160))
summary(theta_1)


#--------------------------------------------------------------------------------
# Both parameters of normal distribution mapped with logarithmic function
theta_2 <- maxlogL( x = x, dist = "dnorm",
                    link = list(over = c("mean","sd"),
                                fun = c("log_link","log_link")) )
summary(theta_2)


#--------------------------------------------------------------------------------
# Parameter estimation in ZIP distribution
library(gamlss.dist)
z <- rZIP(n=10000, mu=6, sigma=0.08)
theta_3  <- maxlogL( x = z, dist='dZIP', start = c(0, 0), lower = c(-Inf, -Inf),
                     upper = c(Inf, Inf), optimizer = 'optim',
                     link = list(over=c("mu", "sigma"),
                     fun = c("log_link", "logit_link")) )
summary(theta_3)


#--------------------------------------------------------------------------------

Jaimemosg/EstimationTools documentation built on Nov. 8, 2019, 9:40 a.m.