coef.maxlogL {EstimationTools} R Documentation

## Extract Model Coefficients in a maxlogL Fits

### Description

coef.maxlogL is the specific method for the generic function coef which extracts model coefficients from objects returned by maxlogLreg. coefficients is an alias for coef.

### Usage

## S3 method for class 'maxlogL'
coef(object, parameter = object$outputs$par_names, ...)

coefMany(object, parameter = NULL, ...)


### Arguments

 object an object of maxlogL class generated by maxlogLreg function. parameter a character which specifies the parameter is required. In coefMany this argument can be an atomic vector with two or more names of parameters. ... other arguments.

### Value

A named vector with coefficients of the specified distribution parameter.

### Examples

library(EstimationTools)

#--------------------------------------------------------------------------------
# Example 1: coefficients from a model using a 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)

norm_mod <- maxlogLreg(formulas, y_dist = y ~ dnorm, data = norm_data,
coef(norm_mod)
coef(norm_mod, parameter = 'sd')
a <- coefMany(norm_mod, parameter = c('mean', 'sd'))
b <- coefMany(norm_mod)
identical(a, b)

#--------------------------------------------------------------------------------
# Example 2: Parameters in estimation with one fixed parameter
x <- rnorm(n = 10000, mean = 160, sd = 6)
theta_1 <- maxlogL(x = x, dist = 'dnorm', control = list(trace = 1),