Learn R Programming

bayeslincom (version 1.3.0)

lin_comb: Perform a linear combination of posterior samples

Description

Perform a linear combination of posterior samples

Usage

lin_comb(lin_comb, obj, ci = 0.9, rope = NULL, contrast = NULL)

Arguments

lin_comb

A string specifying a linear combination of variables, or a list of variable names if using contrast.

obj

An object of class BGGM, bbcor, or a data.frame of posterior samples.

ci

The level for which a credible interval should be computed.

rope

Specify a ROPE. Optional.

contrast

A contrast matrix specifying which combinations to test.

Value

An object of class lin_comb

Examples

Run this code
# NOT RUN {
# data
if (require(BGGM)) library(BGGM)
Y <- ptsd

# names
colnames(Y) <- letters[1:20]

# estimate model
est <- estimate(Y)

# test
bggm_comb <- lin_comb("a--c + a--d > b--c + b--d",
                       obj = est,
                       ci = 0.90,
                       rope = c(-0.1, 0.1))

# print
bggm_comb

# Using a contrast matrix to test pairwise differences
vars <- c("a--c", "a--d", "b--c")

contrast_mat <- matrix(c(1, -1, 0,
                         1, 0, -1,
                         0, 1, -1), nrow = 3, byrow = TRUE)

bggm_comb <- lin_comb(vars,
                      obj = est,
                      ci = 0.90,
                      contrast = contrast_mat)
# print
bggm_comb

# }

Run the code above in your browser using DataLab