R:从 class 'mle' 的对象中提取参数估计值

R: extract parameter estmates from object of class 'mle'

我想知道如何提取存储在 class mle-class.

的 R 对象中的估计参数

这是一个例子:

x <- matrix(rnorm(300), ncol = 3)
x[x > 1] <- 1
require(tmvtnorm)
fit1 <- mle.tmvnorm(X = x, lower = rep(-Inf, 3), upper = rep(1, 3))

现在,fit1 是 class 的一个对象:

class(fit1)
[1] "mle"
attr(,"package")
[1] "stats4

” fit1 本身给了我:

fit1

Call:
mle(minuslogl = function (mu_1 = 0, mu_2 = 0, mu_3 = 0, sigma_1.1 = 1, 
    sigma_1.2 = 0, sigma_1.3 = 0, sigma_2.2 = 1, sigma_2.3 = 0, 
    sigma_3.3 = 1) 
{
    nf <- names(formals())
    theta <- sapply(nf, function(x) {
        eval(parse(text = x))
    })
    mean <- theta[1:n]
    if (cholesky) {
        L <- inv_vech(theta[-(1:n)])
        L[lower.tri(L, diag = FALSE)] <- 0
        sigma <- t(L) %*% L
    }
    else {
        sigma <- inv_vech(theta[-(1:n)])
    }
    if (det(sigma) <= 0 || any(diag(sigma) < 0)) {
        return(.Machine$integer.max)
    }
    f <- -(sum(dmvnorm(X, mean, sigma, log = TRUE)) - nrow(X) * 
        log(pmvnorm(lower = lower, upper = upper, mean = mean, 
            sigma = sigma)))
    if (is.infinite(f) || is.na(f)) {
        return(.Machine$integer.max)
    }
    f
}, start = as.list(c(0, 0, 0, 1, 0, 0, 1, 0, 1)), method = "BFGS", 
    fixed = list())

Coefficients:
       mu_1        mu_2        mu_3   sigma_1.1   sigma_1.2   sigma_1.3 
 0.64218198  1.51720543  0.97047201  1.73395947 -0.03889188  0.14627774 
  sigma_2.2   sigma_2.3   sigma_3.3 
 2.18020597  0.38822509  1.49854600 

我的问题是:如何从对象 fit1 中提取这些系数?

再次感谢您抽出时间,感谢您帮助回答这个问题!

对于这个愚蠢的问题深表歉意:我会保留它以防万一有人找到了。

fit1@coef
       mu_1        mu_2        mu_3   sigma_1.1   sigma_1.2   sigma_1.3 
 0.64218198  1.51720543  0.97047201  1.73395947 -0.03889188  0.14627774 
  sigma_2.2   sigma_2.3   sigma_3.3 
 2.18020597  0.38822509  1.49854600 

解决查询。呸!

coef 是一个通用函数,它从建模函数返回的对象中提取模型 coefficientscoefficients 是它的 别名

用法

coef(object, ...)
coefficients(object, ...)

所以,fit1@coef 应该可以。

https://stat.ethz.ch/R-manual/R-devel/library/stats/html/coef.html