lin_comb: Perform a linear combination of posterior samples

Description Usage Arguments Value Examples

View source: R/lin_comb.R

Description

Perform a linear combination of posterior samples

Usage

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# data
Y <- BGGM::ptsd

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

# estimate model
est <- BGGM::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

josue-rodriguez/bayeslincom documentation built on March 19, 2021, 6:52 p.m.