Find the approximated variance covariance matrix of the parameters.
compute_vcov(obj)
The same object, with added vcov entry.
This function computes the numerical Hessian of the likelihood at the optimal value
using function hessian
, and then uses its inverse
to approximate the variance covariance matrix.
It can be used to compute confidence intervals with functions confint.cauphylm
or confint.cauphyfit
.
confint.cauphylm
and confint.cauphyfit
internally call compute_vcov
, but do not save the result.
This function can be used to save the vcov matrix.
# Simulate tree and data
set.seed(1289)
phy <- ape::rphylo(20, 0.1, 0)
dat <- rTraitCauchy(n = 1, phy = phy, model = "cauchy",
parameters = list(root.value = 10, disp = 0.1))
# Fit the data, without computing the Hessian at the estimated parameters.
fit <- fitCauchy(phy, dat, model = "cauchy", method = "reml", hessian = FALSE)
# Precompute the vcov matrix
fit <- compute_vcov(fit)
# Approximate confidence intervals
confint(fit)
#> Approximated asymptotic confidence interval using the Hessian.
#> 2.5 % 97.5 %
#> disp 0.0240104 0.1010921