| maxlogL | R Documentation |
Wrapper function to compute maximum likelihood estimators (MLE)
of any distribution implemented in R.
maxlogL(
x,
dist = "dnorm",
fixed = NULL,
link = NULL,
start = NULL,
lower = NULL,
upper = NULL,
optimizer = "nlminb",
control = NULL,
StdE_method = c("optim", "numDeriv"),
silent = FALSE,
...
)
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 |
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:
|
start |
a numeric vector with initial values for the parameters to be estimated. |
lower |
a numeric vector with lower bounds, with the same length of argument
|
upper |
a numeric vector with upper bounds, with the same length of argument
|
optimizer |
a length-one character vector with the name of optimization routine.
|
control |
control parameters of the optimization routine. See, e.g.,
|
StdE_method |
a length-one character vector with the routine for Hessian matrix
computation. The This is needed for standard error estimation. The
options available are |
silent |
logical. If TRUE, warnings of |
... |
further arguments to be supplied to the optimizer. |
maxlogL computes 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.
Noncentrality parameters must be named as ncp in the distribution.
A list with class "maxlogL" containing the following lists:
fit |
A list with output information about estimation. |
inputs |
A list with all input arguments. |
outputs |
A list with some output additional information:
|
The following generic functions can be used with a maxlogL object:
summary, print, AIC, BIC, logLik.
Jaime Mosquera GutiƩrrez, jmosquerag@unal.edu.co
Nelder1965EstimationTools
\insertRefFox1978EstimationTools
\insertRefNash1979EstimationTools
\insertRefDennis1981EstimationTools
summary.maxlogL, optim, nlminb,
DEoptim, DEoptim.control,
maxlogLreg, bootstrap_maxlogL
Other maxlogL:
cum_hazard.maxlogL(),
expected_value.maxlogL(),
maxlogLreg()
library(EstimationTools)
#----------------------------------------------------------------------------
# Example 1: 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)
#----------------------------------------------------------------------------
# Example 2: 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)
#--------------------------------------------------------------------------------
# Example 3: parameter estimation in ZIP distribution
if (!require('gamlss.dist')) install.packages('gamlss.dist')
library(gamlss.dist)
z <- rZIP(n=1000, 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)
#--------------------------------------------------------------------------------
# Example 4: parameter estimation with fixed noncentrality parameter.
y_2 <- rbeta(n = 1000, shape1 = 2, shape2 = 3)
theta_41 <- maxlogL(x = y_2, dist = "dbeta",
link = list(over = c("shape1", "shape2"),
fun = c("log_link","log_link")))
summary(theta_41)
# It is also possible define 'ncp' as fixed parameter
theta_42 <- maxlogL(x = y_2, dist = "dbeta", fixed = list(ncp = 0),
link = list(over = c("shape1", "shape2"),
fun = c("log_link","log_link")) )
summary(theta_42)
#--------------------------------------------------------------------------------
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.