Learn R Programming

EstimationTools (version 4.0.0)

coef.maxlogL: Extract Model Coefficients in a maxlogL Fits

Description

[Maturing]

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 maxlogL
coef(object, parameter = object$outputs$par_names, ...)

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

Value

A named vector with coefficients of the specified distribution parameter.

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.

Author

Jaime Mosquera Gutiérrez, jmosquerag@unal.edu.co

Examples

Run this code
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,
                       link = list(over = "sd", fun = "log_link"))
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),
                 link = list(over = "sd", fun = "log_link"),
                 fixed = list(mean = 160))
coef(theta_1)


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

Run the code above in your browser using DataLab