Learn R Programming

bayesics (version 2.0.2)

vcov: Calculate Posterior Variance-Covariance Matrix for a Bayesian Fitted Model Object

Description

Returns the posterior covariance matrix of the main parameters of a fitted bayesics object

Usage

# S3 method for aov_b
vcov(object, ...)

# S3 method for lm_b vcov(object, ...)

# S3 method for glm_b vcov(object, ...)

# S3 method for np_glm_b vcov(object, ...)

Value

A matrix of the covariance matrix for the regression coefficients. If the posterior is a multivariate t distribution (or consists of independent t's in the case of heteroscedastic 1-way ANOVA), the degrees of freedom are returned as the df attribute of the matrix. Note that for lm_b and aov_b objects, this function already takes into account the uncertainty around the residual variance.

Arguments

object

a fitted model object from bayesics.

...

Passed to methods.

Examples

Run this code
# \donttest{
set.seed(2025)
N = 500
test_data <-
  data.frame(x1 = rnorm(N),
             x2 = rnorm(N),
             x3 = letters[1:5])
test_data$outcome <-
  rnorm(N,-1 + test_data$x1 + 2 * (test_data$x3 %in% c("d","e")) )
fit1 <-
  lm_b(outcome ~ x1 + x2 + x3,
       data = test_data)
vcov(fit1)
# }

Run the code above in your browser using DataLab