| maxlogLreg | R Documentation |
Function to compute maximum likelihood estimators (MLE) of regression parameters
of any distribution implemented in R with covariates (linear predictors).
maxlogLreg(
formulas,
y_dist,
support = NULL,
data = NULL,
subset = NULL,
fixed = NULL,
link = NULL,
optimizer = "nlminb",
start = NULL,
lower = NULL,
upper = NULL,
inequalities = NULL,
control = NULL,
silent = FALSE,
StdE_method = c("optim", "numDeriv"),
...
)
formulas |
a list of formula objects. Each element must have an |
y_dist |
a formula object that specifies the distribution of the response
variable. On the left side of |
support |
a list with the following entries:
|
data |
an optional data frame containing the variables in the model.
If data is not specified, the variables are taken from the
environment from which |
subset |
an optional vector specifying a subset of observations to be used in the fitting process. |
fixed |
a list with fixed/known parameters of distribution of interest. Fixed parameters must be passed with its name and its value (known). |
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: |
optimizer |
a length-one character vector with the name of optimization
routine. |
start |
a numeric vector with initial values for the parameters to be estimated. Zero is the default value. |
lower |
a numeric vector with lower bounds, with the same lenght of
argument |
upper |
a numeric vector with upper bounds, with the same lenght of
argument |
inequalities |
a character vector with the inequality constrains for the distribution parameters. |
control |
control parameters of the optimization routine. Please, visit documentation of selected optimizer for further information. |
silent |
logical. If TRUE, warnings of |
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 |
... |
Further arguments to be supplied to the optimization routine. |
maxlogLreg computes programmatically the log-likelihood
(log L) function corresponding for the following model:
y_i \stackrel{iid.}{\sim} \mathcal{D}(\theta_{i1},\theta_{i2},\dots,
\theta_{ij}, \dots, \theta_{ik})
g(\boldsymbol{\theta}_{j}) = \boldsymbol{\eta}_{j} = \mathbf{X}_j^\top
\boldsymbol{\beta}_j,
where,
g_k(\cdot) is the k-th link function.
\boldsymbol{\eta}_{j} is the value of the linear predictor for the
j^{th} for all the observations.
\boldsymbol{\beta}_j = (\beta_{0j}, \beta_{1j},\dots,
\beta_{(p_j-1)j})^\top are the fixed effects vector, where p_j
is the number of parameters in linear predictor j and
\mathbf{X}_j is a known design matrix of order n\times p_j.
These terms are specified in formulas argument.
\mathcal{D} is the distribution specified in argument
y_dist.
Then, maxlogLreg maximizes the log L through
optim, nlminb or
DEoptim. maxlogLreg generates an S3 obj.
Estimation with censorship can be handled with Surv objects
(see example 2). The output object stores the corresponding censorship matrix,
defined as r_{il} = 1 if sample unit i has status l, or
r_{il} = 0 in other case. i=1,2,\dots,n and l=1,2,3
(l=1: observation status, l=2: right censorship status,
l=3: left censorship status).
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 additional information. The most important outputs are:
|
The following generic functions can be used with a maxlogL
object: summary, print, logLik, AIC.
Noncentrality parameters must be named as ncp in the
distribution.
Jaime Mosquera GutiƩrrez, jmosquerag@unal.edu.co
Nelder1965EstimationTools
\insertRefFox1978EstimationTools
\insertRefNash1979EstimationTools
\insertRefDennis1981EstimationTools
summary.maxlogL,
optim,
nlminb,
DEoptim,
DEoptim.control,
maxlogL,
bootstrap_maxlogL
Other maxlogL:
cum_hazard.maxlogL(),
expected_value.maxlogL(),
maxlogL()
library(EstimationTools)
#--------------------------------------------------------------------------------
# Example 1: Estimation in simulated normal distribution
n <- 1000
x <- runif(n = n, -5, 6)
y <- rnorm(n = n, mean = -2 + 3 * x, sd = exp(1 + 0.3* x))
norm_data <- data.frame(y = y, x = x)
# It does not matter the order of distribution parameters
formulas <- list(sd.fo = ~ x, mean.fo = ~ x)
support <- list(interval = c(-Inf, Inf), type = 'continuous')
norm_mod <- maxlogLreg(formulas, y_dist = y ~ dnorm, support = support,
data = norm_data,
link = list(over = "sd", fun = "log_link"))
summary(norm_mod)
#--------------------------------------------------------------------------------
# Example 2: Fitting with censorship
# (data from https://www.itl.nist.gov/div898/handbook/apr/section4/apr413.htm)
failures <- c(55, 187, 216, 240, 244, 335, 361, 373, 375, 386)
fails <- c(failures, rep(500, 10))
status <- c(rep(1, length(failures)), rep(0, 10))
Wei_data <- data.frame(fails = fails, status = status)
# Formulas with linear predictors
formulas <- list(scale.fo=~1, shape.fo=~1)
support <- list(interval = c(0, Inf), type = 'continuous')
# Bounds for optimization. Upper bound set with default values (Inf)
start <- list(
scale = list(Intercept = 100),
shape = list(Intercept = 10)
)
lower <- list(
scale = list(Intercept = 0),
shape = list(Intercept = 0)
)
mod_weibull <- maxlogLreg(formulas, y_dist = Surv(fails, status) ~ dweibull,
support = c(0, Inf), start = start,
lower = lower, data = Wei_data)
summary(mod_weibull)
#--------------------------------------------------------------------------------
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.