coef.maxlogL: Extract Model Coefficients in a 'maxlogL' Fits

View source: R/coef.maxlogL.R

coef.maxlogLR Documentation

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 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.

Author(s)

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

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,
                       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)


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

Jaimemosg/EstimationTools documentation built on Oct. 23, 2023, 10 a.m.