contr.bayes: Orthonormal Contrast Matrices for Bayesian Estimation

Description Usage Arguments Value References Examples

View source: R/contr.bayes.R

Description

Returns a design or model matrix of orthonormal contrasts such that the marginal prior on all effects is identical. Implementation follows the description in Rouder, Morey, Speckman, & Province (2012, p. 363).

Usage

1

Arguments

n

a vector of levels for a factor, or the number of levels.

contrasts

logical indicating whether contrasts should be computed.

Value

A matrix with n rows and k columns, with k=n-1 if contrasts is TRUE`` and k=n if contrasts is FALSE'.

References

Rouder, J. N., Morey, R. D., Speckman, P. L., & Province, J. M. (2012). Default Bayes factors for ANOVA designs. Journal of Mathematical Psychology, 56(5), 356-374. https://doi.org/10.1016/j.jmp.2012.08.001

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
contr.bayes(2)  ## Q_2 in Rouder et al. (2012, p. 363)
#            [,1]
# [1,] -0.7071068
# [2,]  0.7071068

contr.bayes(5)  ## equivalent to Q_5 in Rouder et al. (2012, p. 363)

## check decomposition
Q3 <- contr.bayes(3)
Q3 %*% diag(2) %*% t(Q3)
## 2/3 on diagonal and -1/3 on off-diagonal elements

bayesstuff/stanova documentation built on June 9, 2021, 6:18 p.m.