| Title: | Algebraic Maximum Likelihood Estimators |
|---|---|
| Description: | The maximum likelihood estimator (MLE) is a technology: under regularity conditions, any MLE is asymptotically normal with variance given by the inverse Fisher information. This package exploits that structure by defining an algebra over MLEs. Compose independent estimators into joint MLEs via block-diagonal covariance ('joint'), optimally combine repeated estimates via inverse-variance weighting ('combine'), propagate transformations via the delta method ('rmap'), and bridge to distribution algebra via conversion to normal or multivariate normal objects ('as_dist'). Supports asymptotic ('mle', 'mle_numerical') and bootstrap ('mle_boot') estimators with a unified interface for inference: confidence intervals, standard errors, AIC, Fisher information, and predictive intervals. For background on maximum likelihood estimation, see Casella and Berger (2002, ISBN:978-0534243128). For the delta method and variance estimation, see Lehmann and Casella (1998, ISBN:978-0387985022). |
| Authors: | Alexander Towell [aut, cre] (ORCID: <https://orcid.org/0000-0001-6443-9897>) |
| Maintainer: | Alexander Towell <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 2.0.2 |
| Built: | 2026-05-16 08:39:43 UTC |
| Source: | https://github.com/queelius/algebraic.mle |
Converts an mle_fit object to its asymptotic
normal or mvn
distribution. The MLE must have a variance-covariance matrix available.
## S3 method for class 'mle_fit' as_dist(x, ...)## S3 method for class 'mle_fit' as_dist(x, ...)
x |
An |
... |
Additional arguments (not used). |
A normal (univariate) or mvn (multivariate) distribution.
fit <- mle(theta.hat = c(mu = 5), sigma = matrix(0.25)) d <- as_dist(fit) mean(d) # 5 vcov(d) # 0.25 fit2 <- mle(theta.hat = c(a = 1, b = 2), sigma = diag(c(0.1, 0.2))) d2 <- as_dist(fit2) mean(d2) # c(1, 2)fit <- mle(theta.hat = c(mu = 5), sigma = matrix(0.25)) d <- as_dist(fit) mean(d) # 5 vcov(d) # 0.25 fit2 <- mle(theta.hat = c(a = 1, b = 2), sigma = diag(c(0.1, 0.2))) d2 <- as_dist(fit2) mean(d2) # c(1, 2)
Converts an mle_fit_boot object to an
empirical_dist built from the bootstrap
replicates.
## S3 method for class 'mle_fit_boot' as_dist(x, ...)## S3 method for class 'mle_fit_boot' as_dist(x, ...)
x |
An |
... |
Additional arguments (not used). |
An empirical_dist object.
set.seed(123) x <- rexp(50, rate = 2) rate_mle <- function(data, indices) 1 / mean(data[indices]) boot_result <- boot::boot(data = x, statistic = rate_mle, R = 200) fit <- mle_boot(boot_result) d <- as_dist(fit) mean(d)set.seed(123) x <- rexp(50, rate = 2) rate_mle <- function(data, indices) 1 / mean(data[indices]) boot_result <- boot::boot(data = x, statistic = rate_mle, R = 200) fit <- mle_boot(boot_result) d <- as_dist(fit) mean(d)
Generic method for computing the bias of an estimator object.
bias(x, theta = NULL, ...)bias(x, theta = NULL, ...)
x |
the object to compute the bias of. |
theta |
true parameter value. usually, this is unknown (NULL), in which case we estimate the bias |
... |
pass additional arguments |
The bias of the estimator. The return type depends on the specific method.
fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) bias(fit, theta = c(mu = 5, sigma2 = 4))fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) bias(fit, theta = c(mu = 5, sigma2 = 4))
This is not a good estimate of the bias in general, but it's arguably better than returning 'NULL'.
## S3 method for class 'mle_fit' bias(x, theta = NULL, ...)## S3 method for class 'mle_fit' bias(x, theta = NULL, ...)
x |
the 'mle_fit' object to compute the bias of. |
theta |
true parameter value. normally, unknown (NULL), in which case we estimate the bias (say, using bootstrap) |
... |
additional arguments to pass |
Numeric vector of zeros (asymptotic bias is zero under regularity conditions).
fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) bias(fit)fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) bias(fit)
Computes the estimate of the bias of a 'mle_fit_boot' object.
## S3 method for class 'mle_fit_boot' bias(x, theta = NULL, ...)## S3 method for class 'mle_fit_boot' bias(x, theta = NULL, ...)
x |
the 'mle_fit_boot' object to compute the bias of. |
theta |
true parameter value (not used for 'mle_fit_boot'). |
... |
pass additional arguments (not used) |
Numeric vector of estimated bias (mean of bootstrap replicates minus original estimate).
set.seed(1) b <- boot::boot(rexp(50, 2), function(d, i) 1/mean(d[i]), R = 99) fit <- mle_boot(b) bias(fit)set.seed(1) b <- boot::boot(rexp(50, 2), function(d, i) 1/mean(d[i]), R = 99) fit <- mle_boot(b) bias(fit)
CDF of the asymptotic distribution of an MLE.
## S3 method for class 'mle_fit' cdf(x, ...)## S3 method for class 'mle_fit' cdf(x, ...)
x |
An |
... |
Additional arguments (not used). |
A function computing the CDF at given points.
fit <- mle(theta.hat = c(mu = 5), sigma = matrix(0.1)) F <- cdf(fit) F(5)fit <- mle(theta.hat = c(mu = 5), sigma = matrix(0.1)) F <- cdf(fit) F(5)
mle_fit object.Delegates to params().
## S3 method for class 'mle_fit' coef(object, ...)## S3 method for class 'mle_fit' coef(object, ...)
object |
the |
... |
additional arguments (not used) |
Named numeric vector of parameter estimates.
fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) coef(fit)fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) coef(fit)
Given multiple independent MLEs that estimate the same parameter ,
produces an optimally weighted combination using inverse-variance (Fisher
information) weighting.
combine(x, ...) ## S3 method for class 'list' combine(x, ...) ## S3 method for class 'mle_fit' combine(x, ...)combine(x, ...) ## S3 method for class 'list' combine(x, ...) ## S3 method for class 'mle_fit' combine(x, ...)
x |
An |
... |
Additional |
The combined estimator has:
theta.hat:
sigma:
info:
nobs: sum of individual sample sizes
When the Fisher information matrix is not directly available but the
variance-covariance matrix is, the FIM is computed as ginv(vcov).
An mle_fit object representing the optimally weighted combination.
# Three independent estimates of the same rate fit1 <- mle(theta.hat = c(lambda = 2.1), sigma = matrix(0.04), nobs = 50L) fit2 <- mle(theta.hat = c(lambda = 1.9), sigma = matrix(0.02), nobs = 100L) fit3 <- mle(theta.hat = c(lambda = 2.0), sigma = matrix(0.03), nobs = 70L) comb <- combine(fit1, fit2, fit3) params(comb) se(comb)# Three independent estimates of the same rate fit1 <- mle(theta.hat = c(lambda = 2.1), sigma = matrix(0.04), nobs = 50L) fit2 <- mle(theta.hat = c(lambda = 1.9), sigma = matrix(0.02), nobs = 100L) fit3 <- mle(theta.hat = c(lambda = 2.0), sigma = matrix(0.03), nobs = 70L) comb <- combine(fit1, fit2, fit3) params(comb) se(comb)
Computes the conditional distribution of a subset of parameters given
observed values for other parameters. Uses the closed-form Schur complement
for the multivariate normal. Returns a dist object (not an mle_fit),
since conditioning loses the MLE context.
## S3 method for class 'mle_fit' conditional(x, P = NULL, ..., given_indices = NULL, given_values = NULL)## S3 method for class 'mle_fit' conditional(x, P = NULL, ..., given_indices = NULL, given_values = NULL)
x |
An |
P |
Optional predicate function for Monte Carlo fallback. |
... |
Additional arguments forwarded to |
given_indices |
Integer vector of conditioned parameter indices. |
given_values |
Numeric vector of observed values. |
A normal, mvn, or empirical_dist object.
fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) conditional(fit, given_indices = 2, given_values = 4)fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) conditional(fit, given_indices = 2, given_values = 4)
Function to compute the confidence intervals from a variance-covariance matrix
confint_from_sigma(sigma, theta, level = 0.95)confint_from_sigma(sigma, theta, level = 0.95)
sigma |
either the variance-covariance matrix or the vector of variances of the parameter estimator |
theta |
the point estimate |
level |
confidence level, defaults to 0.95 (alpha=.05) |
Matrix of confidence intervals with rows for each parameter and columns for lower and upper bounds.
# Compute CI for a bivariate parameter theta <- c(mu = 5.2, sigma2 = 4.1) vcov_matrix <- diag(c(0.1, 0.5)) # Variance of estimators confint_from_sigma(vcov_matrix, theta) confint_from_sigma(vcov_matrix, theta, level = 0.99)# Compute CI for a bivariate parameter theta <- c(mu = 5.2, sigma2 = 4.1) vcov_matrix <- diag(c(0.1, 0.5)) # Variance of estimators confint_from_sigma(vcov_matrix, theta) confint_from_sigma(vcov_matrix, theta, level = 0.99)
Function to compute the confidence intervals of 'mle_fit' objects.
## S3 method for class 'mle_fit' confint(object, parm = NULL, level = 0.95, use_t_dist = FALSE, ...)## S3 method for class 'mle_fit' confint(object, parm = NULL, level = 0.95, use_t_dist = FALSE, ...)
object |
the 'mle_fit' object to compute the confidence intervals for |
parm |
character or integer vector of parameters to return intervals for. If NULL (default), all parameters are returned. |
level |
confidence level, defaults to 0.95 (alpha=.05) |
use_t_dist |
logical, whether to use the t-distribution to compute the confidence intervals. |
... |
additional arguments to pass |
Matrix of confidence intervals with columns for lower and upper bounds.
fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) confint(fit)fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) confint(fit)
Method for obtained the confidence interval of an 'mle_fit_boot' object. Note: This impelements the 'vcov' method defined in 'stats'.
## S3 method for class 'mle_fit_boot' confint( object, parm = NULL, level = 0.95, type = c("norm", "basic", "perc", "bca"), ... )## S3 method for class 'mle_fit_boot' confint( object, parm = NULL, level = 0.95, type = c("norm", "basic", "perc", "bca"), ... )
object |
the 'mle_fit_boot' object to obtain the confidence interval of |
parm |
character or integer vector of parameters to return intervals for. If NULL (default), all parameters are returned. |
level |
the confidence level |
type |
the type of confidence interval to compute |
... |
additional arguments to pass into 'boot.ci' |
Matrix of bootstrap confidence intervals with columns for lower and upper bounds.
set.seed(1) b <- boot::boot(rexp(50, 2), function(d, i) 1/mean(d[i]), R = 99) fit <- mle_boot(b) confint(fit)set.seed(1) b <- boot::boot(rexp(50, 2), function(d, i) 1/mean(d[i]), R = 99) fit <- mle_boot(b) confint(fit)
Returns a closure computing the probability density function of the asymptotic normal (univariate) or multivariate normal (multivariate) distribution of the MLE.
## S3 method for class 'mle_fit' density(x, ...)## S3 method for class 'mle_fit' density(x, ...)
x |
An |
... |
Additional arguments (not used). |
A function computing the PDF at given points.
fit <- mle(theta.hat = c(mu = 5), sigma = matrix(0.1)) f <- density(fit) f(5)fit <- mle(theta.hat = c(mu = 5), sigma = matrix(0.1)) f <- density(fit) f(5)
PDF of the empirical distribution of bootstrap replicates.
## S3 method for class 'mle_fit_boot' density(x, ...)## S3 method for class 'mle_fit_boot' density(x, ...)
x |
An |
... |
Additional arguments (not used). |
A function computing the empirical PMF at given points.
set.seed(1) b <- boot::boot(rexp(50, 2), function(d, i) 1/mean(d[i]), R = 99) fit <- mle_boot(b) density(fit)set.seed(1) b <- boot::boot(rexp(50, 2), function(d, i) 1/mean(d[i]), R = 99) fit <- mle_boot(b) density(fit)
Dimension (number of parameters) of an MLE.
## S3 method for class 'mle_fit' dim(x)## S3 method for class 'mle_fit' dim(x)
x |
An |
Integer; the number of parameters.
fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) dim(fit)fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) dim(fit)
Dimension (number of parameters) of a bootstrap MLE.
## S3 method for class 'mle_fit_boot' dim(x)## S3 method for class 'mle_fit_boot' dim(x)
x |
An |
Integer; the number of parameters.
set.seed(1) b <- boot::boot(rexp(50, 2), function(d, i) 1/mean(d[i]), R = 99) fit <- mle_boot(b) dim(fit)set.seed(1) b <- boot::boot(rexp(50, 2), function(d, i) 1/mean(d[i]), R = 99) fit <- mle_boot(b) dim(fit)
Optionally, we use the CLT to construct a CI('alpha') for the estimate of the expectation. That is, we estimate 'E(g(x))' with the sample mean and Var(g(x)) with the sigma^2/n, where sigma^2 is the sample variance of g(x) and n is the number of samples. From these, we construct the CI.
## S3 method for class 'mle_fit' expectation(x, g = function(t) t, ..., control = list())## S3 method for class 'mle_fit' expectation(x, g = function(t) t, ..., control = list())
x |
'mle_fit' object |
g |
characteristic function of interest, defaults to identity |
... |
additional arguments to pass to 'g' |
control |
a list of control parameters: compute_stats - Whether to compute CIs for the expectations, defaults to FALSE n - The number of samples to use for the MC estimate, defaults to 10000 alpha - The significance level for the confidence interval, defaults to 0.05 |
If 'compute_stats' is FALSE, then the estimate of the expectation, otherwise a list with the following components: value - The estimate of the expectation ci - The confidence intervals for each component of the expectation n - The number of samples
fit <- mle(theta.hat = c(mu = 5), sigma = matrix(0.1), nobs = 100L) expectation(fit)fit <- mle(theta.hat = c(mu = 5), sigma = matrix(0.1), nobs = 100L) expectation(fit)
Quantile function of the asymptotic distribution of an MLE.
## S3 method for class 'mle_fit' inv_cdf(x, ...)## S3 method for class 'mle_fit' inv_cdf(x, ...)
x |
An |
... |
Additional arguments (not used). |
A function computing quantiles for given probabilities.
fit <- mle(theta.hat = c(mu = 5), sigma = matrix(0.1)) q <- inv_cdf(fit) q(0.975)fit <- mle(theta.hat = c(mu = 5), sigma = matrix(0.1)) q <- inv_cdf(fit) q(0.975)
Determine if an object 'x' is an 'mle_fit' object.
is_mle(x)is_mle(x)
x |
the object to test |
Logical TRUE if x is an mle_fit object, FALSE otherwise.
fit <- mle(theta.hat = c(mu = 5), sigma = matrix(0.1)) is_mle(fit) # TRUE is_mle(list(a=1)) # FALSEfit <- mle(theta.hat = c(mu = 5), sigma = matrix(0.1)) is_mle(fit) # TRUE is_mle(list(a=1)) # FALSE
Determine if an object is an 'mle_fit_boot' object.
is_mle_boot(x)is_mle_boot(x)
x |
the object to test |
Logical TRUE if x is an mle_fit_boot object, FALSE otherwise.
# Create a simple mle_fit object (not bootstrap) fit_mle <- mle(theta.hat = 5, sigma = matrix(0.1)) is_mle_boot(fit_mle) # FALSE # Bootstrap example would return TRUE# Create a simple mle_fit object (not bootstrap) fit_mle <- mle(theta.hat = 5, sigma = matrix(0.1)) is_mle_boot(fit_mle) # FALSE # Bootstrap example would return TRUE
Given two or more independent MLEs with disjoint parameter sets, produces a joint MLE with block-diagonal variance-covariance structure.
joint(x, ...) ## S3 method for class 'mle_fit' joint(x, ...)joint(x, ...) ## S3 method for class 'mle_fit' joint(x, ...)
x |
An |
... |
Additional |
The joint MLE has:
theta.hat: concatenation of all parameter vectors
sigma: block-diagonal from individual vcov matrices
loglike: sum of log-likelihoods (when all available)
info: block-diagonal from individual FIMs (when all available)
score: concatenation of score vectors (when all available)
nobs: NULL (different experiments have no shared sample size)
An mle_fit object representing the joint MLE.
# Two independent experiments fit_rate <- mle(theta.hat = c(lambda = 2.1), sigma = matrix(0.04), nobs = 50L) fit_shape <- mle(theta.hat = c(k = 1.5, s = 3.2), sigma = matrix(c(0.1, 0.02, 0.02, 0.3), 2, 2), nobs = 100L) # Joint MLE: 3 params, block-diagonal covariance j <- joint(fit_rate, fit_shape) params(j) # c(lambda = 2.1, k = 1.5, s = 3.2) vcov(j) # 3x3 block-diagonal # Existing algebra works on the joint: marginal(j, 2:3) # recover shape params as_dist(j) # MVN for distribution algebra# Two independent experiments fit_rate <- mle(theta.hat = c(lambda = 2.1), sigma = matrix(0.04), nobs = 50L) fit_shape <- mle(theta.hat = c(k = 1.5, s = 3.2), sigma = matrix(c(0.1, 0.02, 0.02, 0.3), 2, 2), nobs = 100L) # Joint MLE: 3 params, block-diagonal covariance j <- joint(fit_rate, fit_shape) params(j) # c(lambda = 2.1, k = 1.5, s = 3.2) vcov(j) # 3x3 block-diagonal # Existing algebra works on the joint: marginal(j, 2:3) # recover shape params as_dist(j) # MVN for distribution algebra
mle_fit object.Returns a "logLik" object with df (number of parameters) and
nobs attributes, enabling AIC() and BIC() via
stats::AIC.default.
## S3 method for class 'mle_fit' logLik(object, ...)## S3 method for class 'mle_fit' logLik(object, ...)
object |
the |
... |
additional arguments (not used) |
A "logLik" object.
fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) logLik(fit)fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) logLik(fit)
'x ~ MVN(params(x), inv(H)(x))'
## S3 method for class 'mle_fit' marginal(x, indices)## S3 method for class 'mle_fit' marginal(x, indices)
x |
The distribution object. |
indices |
The indices of the marginal distribution to obtain. |
where H is the (observed or expecation) Fisher information matrix.
An mle_fit object representing the marginal distribution for the
selected parameter indices.
fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) marginal(fit, 1)fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) marginal(fit, 1)
Returns the parameter estimates, which are the mean of the asymptotic distribution.
## S3 method for class 'mle_fit' mean(x, ...)## S3 method for class 'mle_fit' mean(x, ...)
x |
An |
... |
Additional arguments (not used). |
Numeric vector of parameter estimates.
fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) mean(fit)fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) mean(fit)
Returns the empirical mean of the bootstrap replicates (which includes
bootstrap bias). For the bias-corrected point estimate, use params().
## S3 method for class 'mle_fit_boot' mean(x, ...)## S3 method for class 'mle_fit_boot' mean(x, ...)
x |
An |
... |
Additional arguments (not used). |
Numeric vector of column means of bootstrap replicates.
set.seed(1) b <- boot::boot(rexp(50, 2), function(d, i) 1/mean(d[i]), R = 99) fit <- mle_boot(b) mean(fit)set.seed(1) b <- boot::boot(rexp(50, 2), function(d, i) 1/mean(d[i]), R = 99) fit <- mle_boot(b) mean(fit)
This MLE makes the asymptotic assumption by default. Other MLEs, like 'mle_fit_boot', may not make this assumption.
mle( theta.hat, loglike = NULL, score = NULL, sigma = NULL, info = NULL, obs = NULL, nobs = NULL, superclasses = NULL )mle( theta.hat, loglike = NULL, score = NULL, sigma = NULL, info = NULL, obs = NULL, nobs = NULL, superclasses = NULL )
theta.hat |
the MLE |
loglike |
the log-likelihood of 'theta.hat' given the data |
score |
the score function evaluated at 'theta.hat' |
sigma |
the variance-covariance matrix of 'theta.hat' given that data |
info |
the information matrix of 'theta.hat' given the data |
obs |
observation (sample) data |
nobs |
number of observations in 'obs' |
superclasses |
class (or classes) with 'mle_fit' as base |
An object of class mle_fit.
# MLE for normal distribution (mean and variance) set.seed(123) x <- rnorm(100, mean = 5, sd = 2) n <- length(x) mu_hat <- mean(x) var_hat <- mean((x - mu_hat)^2) # MLE of variance # Asymptotic variance-covariance of MLE # For normal: Var(mu_hat) = sigma^2/n, Var(var_hat) = 2*sigma^4/n sigma_matrix <- diag(c(var_hat/n, 2*var_hat^2/n)) fit <- mle( theta.hat = c(mu = mu_hat, var = var_hat), sigma = sigma_matrix, loglike = sum(dnorm(x, mu_hat, sqrt(var_hat), log = TRUE)), nobs = n ) params(fit) vcov(fit) confint(fit)# MLE for normal distribution (mean and variance) set.seed(123) x <- rnorm(100, mean = 5, sd = 2) n <- length(x) mu_hat <- mean(x) var_hat <- mean((x - mu_hat)^2) # MLE of variance # Asymptotic variance-covariance of MLE # For normal: Var(mu_hat) = sigma^2/n, Var(var_hat) = 2*sigma^4/n sigma_matrix <- diag(c(var_hat/n, 2*var_hat^2/n)) fit <- mle( theta.hat = c(mu = mu_hat, var = var_hat), sigma = sigma_matrix, loglike = sum(dnorm(x, mu_hat, sqrt(var_hat), log = TRUE)), nobs = n ) params(fit) vcov(fit) confint(fit)
Sometimes, the large sample asymptotic theory of MLEs is not applicable. In such cases, we can use the bootstrap to estimate the sampling distribution of the MLE.
mle_boot(x)mle_boot(x)
x |
the 'boot' return value |
This takes an approach similiar to the 'mle_fit_numerical' object, which is a wrapper for a 'stats::optim' return value, or something that is compatible with the 'optim' return value. Here, we take a 'boot' object, which is the sampling distribution of an MLE, and wrap it in an 'mle_fit_boot' object and then provide a number of methods for the 'mle_fit_boot' object that satisfies the concept of an 'mle_fit' object.
Look up the 'boot' package for more information on the bootstrap.
An mle_fit_boot object (wrapper for boot object).
# Bootstrap MLE for mean of exponential distribution set.seed(123) x <- rexp(50, rate = 2) # Statistic function: MLE of rate parameter rate_mle <- function(data, indices) { d <- data[indices] 1 / mean(d) # MLE of rate is 1/mean } # Run bootstrap boot_result <- boot::boot(data = x, statistic = rate_mle, R = 200) # Wrap in mle_boot fit <- mle_boot(boot_result) params(fit) bias(fit) confint(fit)# Bootstrap MLE for mean of exponential distribution set.seed(123) x <- rexp(50, rate = 2) # Statistic function: MLE of rate parameter rate_mle <- function(data, indices) { d <- data[indices] 1 / mean(d) # MLE of rate is 1/mean } # Run bootstrap boot_result <- boot::boot(data = x, statistic = rate_mle, R = 200) # Wrap in mle_boot fit <- mle_boot(boot_result) params(fit) bias(fit) confint(fit)
This function takes the output of 'optim', 'newton_raphson', or 'sim_anneal' and turns it into an 'mle_fit_numerical' (subclass of 'mle_fit') object.
mle_numerical(sol, options = list(), superclasses = NULL)mle_numerical(sol, options = list(), superclasses = NULL)
sol |
the output of 'optim' or 'newton_raphson' |
options |
list, options for things like sigma and FIM |
superclasses |
list, superclasses to add to the 'mle_fit_numerical' object |
An object of class mle_fit_numerical (subclass of mle_fit).
# Fit exponential distribution using optim set.seed(123) x <- rexp(100, rate = 2) # Log-likelihood for exponential distribution loglik <- function(rate) { if (rate <= 0) return(-Inf) sum(dexp(x, rate = rate, log = TRUE)) } # Optimize (maximize by setting fnscale = -1) result <- optim( par = 1, fn = loglik, method = "Brent", lower = 0.01, upper = 10, hessian = TRUE, control = list(fnscale = -1) ) # Wrap in mle_numerical fit <- mle_numerical(result, options = list(nobs = length(x))) params(fit) se(fit)# Fit exponential distribution using optim set.seed(123) x <- rexp(100, rate = 2) # Log-likelihood for exponential distribution loglik <- function(rate) { if (rate <= 0) return(-Inf) sum(dexp(x, rate = rate, log = TRUE)) } # Optimize (maximize by setting fnscale = -1) result <- optim( par = 1, fn = loglik, method = "Brent", lower = 0.01, upper = 10, hessian = TRUE, control = list(fnscale = -1) ) # Wrap in mle_numerical fit <- mle_numerical(result, options = list(nobs = length(x))) params(fit) se(fit)
Generic method for computing the mean squared error (MSE) of an estimator, 'mse(x) = E[(x-mu)^2]' where 'mu' is the true parameter value.
mse(x, theta, ...)mse(x, theta, ...)
x |
the object to compute the MSE of |
theta |
the true parameter value |
... |
additional arguments passed to methods |
The mean squared error (matrix or scalar).
fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) mse(fit, theta = c(mu = 5, sigma2 = 4))fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) mse(fit, theta = c(mu = 5, sigma2 = 4))
The MSE of an estimator is just the expected sum of squared differences, e.g., if the true parameter value is 'x' and we have an estimator 'x.hat', then the MSE is “' mse(x.hat) = E[(x.hat-x) vcov(x.hat) + bias(x.hat, x) “'
## S3 method for class 'mle_fit' mse(x, theta = NULL, ...)## S3 method for class 'mle_fit' mse(x, theta = NULL, ...)
x |
the 'mle_fit' object to compute the MSE of. |
theta |
true parameter value, defaults to 'NULL' for unknown. If 'NULL', then we let the bias method deal with it. Maybe it has a nice way of estimating the bias. |
... |
additional arguments (not used) |
Since 'x' is not typically known, we normally must estimate the bias. Asymptotically, assuming the regularity conditions, the bias of an MLE is zero, so we can estimate the MSE as 'mse(x.hat) = vcov(x.hat)', but for small samples, this is not generally the case. If we can estimate the bias, then we can replace the bias with an estimate of the bias.
Sometimes, we can estimate the bias analytically, but if not, we can use something like the bootstrap. For example, if we have a sample of size 'n', we can bootstrap the bias by sampling 'n' observations with replacement, computing the MLE, and then computing the difference between the bootstrapped MLE and the MLE. We can repeat this process 'B' times, and then average the differences to get an estimate of the bias.
The MSE as a scalar (univariate) or matrix (multivariate).
fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) mse(fit)fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) mse(fit)
Computes the estimate of the MSE of a 'boot' object.
## S3 method for class 'mle_fit_boot' mse(x, theta = NULL, ...)## S3 method for class 'mle_fit_boot' mse(x, theta = NULL, ...)
x |
the 'boot' object to compute the MSE of. |
theta |
true parameter value (not used for 'mle_boot') |
... |
pass additional arguments into 'vcov' |
The MSE matrix estimated from bootstrap variance and bias.
set.seed(1) b <- boot::boot(rexp(50, 2), function(d, i) 1/mean(d[i]), R = 99) fit <- mle_boot(b) mse(fit)set.seed(1) b <- boot::boot(rexp(50, 2), function(d, i) 1/mean(d[i]), R = 99) fit <- mle_boot(b) mse(fit)
Method for obtaining the number of observations in the sample used by an 'mle_fit'.
## S3 method for class 'mle_fit' nobs(object, ...)## S3 method for class 'mle_fit' nobs(object, ...)
object |
the 'mle_fit' object to obtain the number of observations for |
... |
additional arguments to pass (not used) |
Integer number of observations, or NULL if not available.
fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) nobs(fit)fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) nobs(fit)
Method for obtaining the number of observations in the sample used by an 'mle_fit_boot'.
## S3 method for class 'mle_fit_boot' nobs(object, ...)## S3 method for class 'mle_fit_boot' nobs(object, ...)
object |
the 'mle_fit_boot' object to obtain the number of observations for |
... |
additional arguments to pass (not used) |
Integer number of observations in the original sample.
set.seed(1) b <- boot::boot(rexp(50, 2), function(d, i) 1/mean(d[i]), R = 99) fit <- mle_boot(b) nobs(fit)set.seed(1) b <- boot::boot(rexp(50, 2), function(d, i) 1/mean(d[i]), R = 99) fit <- mle_boot(b) nobs(fit)
Method for obtaining the number of parameters of an 'mle_fit' object.
## S3 method for class 'mle_fit' nparams(x)## S3 method for class 'mle_fit' nparams(x)
x |
the 'mle_fit' object to obtain the number of parameters of |
Integer number of parameters.
fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) nparams(fit)fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) nparams(fit)
Method for obtaining the number of parameters of an 'boot' object.
## S3 method for class 'mle_fit_boot' nparams(x)## S3 method for class 'mle_fit_boot' nparams(x)
x |
the 'boot' object to obtain the number of parameters of |
Integer number of parameters.
set.seed(1) b <- boot::boot(rexp(50, 2), function(d, i) 1/mean(d[i]), R = 99) fit <- mle_boot(b) nparams(fit)set.seed(1) b <- boot::boot(rexp(50, 2), function(d, i) 1/mean(d[i]), R = 99) fit <- mle_boot(b) nparams(fit)
Method for obtaining the observations used by the 'mle_fit' object 'x'.
## S3 method for class 'mle_fit' obs(x)## S3 method for class 'mle_fit' obs(x)
x |
the 'mle_fit' object to obtain the number of observations for |
The observation data used to fit the MLE, or NULL if not stored.
fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), obs = rnorm(100), nobs = 100L) head(obs(fit))fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), obs = rnorm(100), nobs = 100L) head(obs(fit))
Method for obtaining the observations used by the 'mle_fit_boot'.
## S3 method for class 'mle_fit_boot' obs(x)## S3 method for class 'mle_fit_boot' obs(x)
x |
the 'mle_fit_boot' object to obtain the number of observations for |
The original data used for bootstrapping.
set.seed(1) b <- boot::boot(rexp(50, 2), function(d, i) 1/mean(d[i]), R = 99) fit <- mle_boot(b) head(obs(fit))set.seed(1) b <- boot::boot(rexp(50, 2), function(d, i) 1/mean(d[i]), R = 99) fit <- mle_boot(b) head(obs(fit))
Fisher information is a way of measuring the amount of information that an observable random variable 'X' carries about an unknown parameter 'theta' upon which the probability of 'X' depends.
observed_fim(x, ...)observed_fim(x, ...)
x |
the object to obtain the fisher information of |
... |
additional arguments to pass |
The inverse of the Fisher information matrix is the variance-covariance of the MLE for 'theta'.
Some MLE objects do not have an observed FIM, e.g., if the MLE's sampling distribution was bootstrapped.
The observed Fisher Information Matrix.
fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), info = solve(diag(c(0.04, 0.32))), loglike = -120, nobs = 100L) observed_fim(fit)fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), info = solve(diag(c(0.04, 0.32))), loglike = -120, nobs = 100L) observed_fim(fit)
Function for obtaining the observed FIM of an 'mle_fit' object.
## S3 method for class 'mle_fit' observed_fim(x, ...)## S3 method for class 'mle_fit' observed_fim(x, ...)
x |
the 'mle_fit' object to obtain the FIM of. |
... |
pass additional arguments |
The observed Fisher Information Matrix, or NULL if not available.
fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), info = solve(diag(c(0.04, 0.32))), nobs = 100L) observed_fim(fit)fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), info = solve(diag(c(0.04, 0.32))), nobs = 100L) observed_fim(fit)
Generic method for determining the orthogonal parameters of an estimator.
orthogonal(x, tol, ...)orthogonal(x, tol, ...)
x |
the estimator |
tol |
the tolerance for determining if a number is close enough to zero |
... |
additional arguments to pass |
Logical vector or matrix indicating which parameters are orthogonal.
fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), info = solve(diag(c(0.04, 0.32))), loglike = -120, nobs = 100L) orthogonal(fit)fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), info = solve(diag(c(0.04, 0.32))), loglike = -120, nobs = 100L) orthogonal(fit)
Method for determining the orthogonal components of an 'mle_fit' object 'x'.
## S3 method for class 'mle_fit' orthogonal(x, tol = sqrt(.Machine$double.eps), ...)## S3 method for class 'mle_fit' orthogonal(x, tol = sqrt(.Machine$double.eps), ...)
x |
the 'mle_fit' object |
tol |
the tolerance for determining if a number is close enough to zero |
... |
pass additional arguments |
Logical matrix indicating which off-diagonal FIM elements are approximately zero (orthogonal parameters), or NULL if FIM unavailable.
fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), info = solve(diag(c(0.04, 0.32))), nobs = 100L) orthogonal(fit)fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), info = solve(diag(c(0.04, 0.32))), nobs = 100L) orthogonal(fit)
Method for obtaining the parameters of an 'mle_fit' object.
## S3 method for class 'mle_fit' params(x)## S3 method for class 'mle_fit' params(x)
x |
the 'mle_fit' object to obtain the parameters of |
Numeric vector of parameter estimates.
fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) params(fit)fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) params(fit)
Method for obtaining the parameters of an 'boot' object.
## S3 method for class 'mle_fit_boot' params(x)## S3 method for class 'mle_fit_boot' params(x)
x |
the 'boot' object to obtain the parameters of. |
Numeric vector of parameter estimates (the original MLE).
set.seed(1) b <- boot::boot(rexp(50, 2), function(d, i) 1/mean(d[i]), R = 99) fit <- mle_boot(b) params(fit)set.seed(1) b <- boot::boot(rexp(50, 2), function(d, i) 1/mean(d[i]), R = 99) fit <- mle_boot(b) params(fit)
Generic method for computing the predictive confidence interval given an estimator object 'x'.
pred(x, samp = NULL, alpha = 0.05, ...)pred(x, samp = NULL, alpha = 0.05, ...)
x |
the estimator object |
samp |
a sampler for random variable that is parameterized by mle 'x' |
alpha |
(1-alpha)/2 confidence interval |
... |
additional arguments to pass |
Matrix of predictive confidence intervals.
fit <- mle(theta.hat = c(mu = 5), sigma = matrix(0.1), nobs = 100L) pred(fit, samp = function(n, theta) rnorm(n, theta[1], 1))fit <- mle(theta.hat = c(mu = 5), sigma = matrix(0.1), nobs = 100L) pred(fit, samp = function(n, theta) rnorm(n, theta[1], 1))
Let 'T|x ~ f(t|x)“ be the pdf of vector 'T' given MLE 'x' and 'x ~ MVN(params(x),vcov(x))“ be the estimate of the sampling distribution of the MLE for the parameters of 'T'. Then, '(T,x) ~ f(t,x) = f(t|x) f(x) is the joint distribution of '(T,x)'. To find 'f(t)' for a fixed 't', we integrate 'f(t,x)' over 'x' using Monte Carlo integration to find the marginal distribution of 'T'. That is, we:
## S3 method for class 'mle_fit' pred(x, samp, alpha = 0.05, R = 50000, ...)## S3 method for class 'mle_fit' pred(x, samp, alpha = 0.05, R = 50000, ...)
x |
an 'mle_fit' object. |
samp |
The sampler for the distribution that is parameterized by the MLE 'x', i.e., 'T|x'. |
alpha |
(1-alpha)-predictive interval for 'T|x'. Defaults to 0.05. |
R |
number of samples to draw from the sampling distribution of 'x'. Defaults to 50000. |
... |
additional arguments to pass into 'samp'. |
1. Sample from MVN 'x' 2. Compute 'f(t,x)' for each sample 3. Take the mean of the 'f(t,x)' values asn an estimate of 'f(t)'.
The 'samp' function is used to sample from the distribution of 'T|x'. It should be designed to take
Matrix with columns for mean, lower, and upper bounds of the predictive interval.
fit <- mle(theta.hat = c(mu = 5), sigma = matrix(0.1), nobs = 100L) pred(fit, samp = function(n, theta) rnorm(n, theta[1], 1))fit <- mle(theta.hat = c(mu = 5), sigma = matrix(0.1), nobs = 100L) pred(fit, samp = function(n, theta) rnorm(n, theta[1], 1))
Print method for 'mle_fit' objects.
## S3 method for class 'mle_fit' print(x, ...)## S3 method for class 'mle_fit' print(x, ...)
x |
the 'mle_fit' object to print |
... |
additional arguments to pass |
Invisibly returns x.
fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) print(fit)fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) print(fit)
Function for printing a 'summary' object for an 'mle_fit' object.
## S3 method for class 'summary_mle_fit' print(x, ...)## S3 method for class 'summary_mle_fit' print(x, ...)
x |
the 'summary_mle_fit' object |
... |
pass additional arguments |
Invisibly returns x.
fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) print(summary(fit))fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) print(summary(fit))
By the invariance property of the MLE, if 'x' is an 'mle_fit' object, then under the right conditions, asymptotically, 'g(x)' is normally distributed, g(x) ~ normal(g(params(x)),sigma) where 'sigma' is the variance-covariance of 'f(x)'
## S3 method for class 'mle_fit' rmap(x, g, ..., n = 1000, method = c("mc", "delta"))## S3 method for class 'mle_fit' rmap(x, g, ..., n = 1000, method = c("mc", "delta"))
x |
an 'mle_fit' object |
g |
a deterministic, differentiable function mapping a numeric parameter
vector to a numeric vector. The Jacobian is computed numerically via
|
... |
additional arguments to pass to the 'g' function |
n |
number of samples to take to estimate distribution of 'g(x)' if 'method == "mc"'. |
method |
method to use to estimate distribution of 'g(x)', "delta" or "mc". |
We provide two different methods for estimating the variance-covariance of 'f(x)': method = "delta" -> delta method method = "mc" -> monte carlo method
An mle_fit object of class mle_fit_rmap representing the
transformed MLE with variance estimated by the specified method.
# MLE for normal distribution set.seed(123) x <- rnorm(100, mean = 5, sd = 2) n <- length(x) fit <- mle( theta.hat = c(mu = mean(x), var = var(x)), sigma = diag(c(var(x)/n, 2*var(x)^2/n)), nobs = n ) # Transform: compute MLE of standard deviation (sqrt of variance) # Using delta method g <- function(theta) sqrt(theta[2]) sd_mle <- rmap(fit, g, method = "delta") params(sd_mle) se(sd_mle)# MLE for normal distribution set.seed(123) x <- rnorm(100, mean = 5, sd = 2) n <- length(x) fit <- mle( theta.hat = c(mu = mean(x), var = var(x)), sigma = diag(c(var(x)/n, 2*var(x)^2/n)), nobs = n ) # Transform: compute MLE of standard deviation (sqrt of variance) # Using delta method g <- function(theta) sqrt(theta[2]) sd_mle <- rmap(fit, g, method = "delta") params(sd_mle) se(sd_mle)
It creates a sampler for the 'mle_fit' object. It returns a function that accepts a single parameter 'n' denoting the number of samples to draw from the 'mle_fit' object.
## S3 method for class 'mle_fit' sampler(x, ...)## S3 method for class 'mle_fit' sampler(x, ...)
x |
the 'mle_fit' object to create sampler for |
... |
additional arguments to pass |
A function that takes parameter n and returns n samples
from the asymptotic distribution of the MLE.
fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) s <- sampler(fit) head(s(10))fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) s <- sampler(fit) head(s(10))
It creates a sampler for the 'mle_fit_boot' object. It returns a function that accepts a single parameter 'n' denoting the number of samples to draw from the 'mle_fit_boot' object.
## S3 method for class 'mle_fit_boot' sampler(x, ...)## S3 method for class 'mle_fit_boot' sampler(x, ...)
x |
the 'mle_fit_boot' object to create sampler for |
... |
additional arguments to pass (not used) |
Unlike the 'sampler' method for the more general 'mle_fit' objects, for 'mle_fit_boot' objects, we sample from the bootstrap replicates, which are more representative of the sampling distribution, particularly for small samples.
A function that takes parameter n and returns n samples
drawn from the bootstrap replicates.
set.seed(1) b <- boot::boot(rexp(50, 2), function(d, i) 1/mean(d[i]), R = 99) fit <- mle_boot(b) sampler(fit)(5)set.seed(1) b <- boot::boot(rexp(50, 2), function(d, i) 1/mean(d[i]), R = 99) fit <- mle_boot(b) sampler(fit)(5)
Generic method for computing the score of an estimator object (gradient of its log-likelihood function evaluated at the MLE).
score_val(x, ...)score_val(x, ...)
x |
the object to compute the score of. |
... |
pass additional arguments |
The score vector evaluated at the MLE.
fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), score = c(0.001, -0.002), loglike = -120, nobs = 100L) score_val(fit)fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), score = c(0.001, -0.002), loglike = -120, nobs = 100L) score_val(fit)
If reguarlity conditions are satisfied, it should be zero (or approximately, if rounding errors occur).
## S3 method for class 'mle_fit' score_val(x, ...)## S3 method for class 'mle_fit' score_val(x, ...)
x |
the 'mle_fit' object to compute the score of. |
... |
additional arguments to pass (not used) |
The score vector evaluated at the MLE, or NULL if not available.
fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), score = c(0.001, -0.002), nobs = 100L) score_val(fit)fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), score = c(0.001, -0.002), nobs = 100L) score_val(fit)
Generic method for obtaining the standard errors of an estimator.
se(x, ...)se(x, ...)
x |
the estimator |
... |
additional arguments to pass |
Vector of standard errors for each parameter.
fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) se(fit)fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) se(fit)
Function for obtaining an estimate of the standard error of the MLE object 'x'.
## S3 method for class 'mle_fit' se(x, se.matrix = FALSE, ...)## S3 method for class 'mle_fit' se(x, se.matrix = FALSE, ...)
x |
the MLE object |
se.matrix |
if 'TRUE', return the square root of the variance-covariance |
... |
additional arguments to pass (not used) |
Vector of standard errors, or matrix if se.matrix = TRUE, or
NULL if variance-covariance is not available.
fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) se(fit)fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) se(fit)
Function for obtaining a summary of 'object', which is a fitted 'mle_fit' object.
## S3 method for class 'mle_fit' summary(object, ...)## S3 method for class 'mle_fit' summary(object, ...)
object |
the 'mle_fit' object |
... |
pass additional arguments |
An object of class summary_mle_fit.
fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) summary(fit)fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) summary(fit)
Support of the asymptotic distribution of an MLE.
## S3 method for class 'mle_fit' sup(x)## S3 method for class 'mle_fit' sup(x)
x |
An |
A support object (interval for normal distributions).
fit <- mle(theta.hat = c(mu = 5), sigma = matrix(0.1)) sup(fit)fit <- mle(theta.hat = c(mu = 5), sigma = matrix(0.1)) sup(fit)
Computes the variance-covariance matrix of 'mle_fit' object.
## S3 method for class 'mle_fit' vcov(object, ...)## S3 method for class 'mle_fit' vcov(object, ...)
object |
the 'mle_fit' object to obtain the variance-covariance of |
... |
additional arguments to pass (not used) |
the variance-covariance matrix
fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) vcov(fit)fit <- mle(theta.hat = c(mu = 5, sigma2 = 4), sigma = diag(c(0.04, 0.32)), loglike = -120, nobs = 100L) vcov(fit)
Computes the variance-covariance matrix of 'boot' object. Note: This impelements the 'vcov' method defined in 'stats'.
## S3 method for class 'mle_fit_boot' vcov(object, ...)## S3 method for class 'mle_fit_boot' vcov(object, ...)
object |
the 'boot' object to obtain the variance-covariance of |
... |
additional arguments to pass into 'stats::cov' |
The variance-covariance matrix estimated from bootstrap replicates.
set.seed(1) b <- boot::boot(rexp(50, 2), function(d, i) 1/mean(d[i]), R = 99) fit <- mle_boot(b) vcov(fit)set.seed(1) b <- boot::boot(rexp(50, 2), function(d, i) 1/mean(d[i]), R = 99) fit <- mle_boot(b) vcov(fit)