Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

contrasts.bayes

Contrast Matrices


Description

Return a matrix of contrasts used in bayesglm.

Usage

contr.bayes.unordered(n, base = 1, contrasts = TRUE)
contr.bayes.ordered (n, scores = 1:n, contrasts = TRUE)

Arguments

n

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

base

an integer specifying which group is considered the baseline group. Ignored if contrasts is FALSE.

contrasts

a logical indicating whether contrasts should be computed.

scores

the set of values over which orthogonal polynomials are to be computed.

Details

These functions are adapted from contr.treatment and contr.poly in stats package. The purpose for these functions are to keep the baseline levels of categorical variables and thus to suit the use of bayesglm.

contr.bayes.unordered is equivalent to contr.treatment whereas contr.bayes.ordered is equivalent to contr.poly.

Author(s)

See Also

Examples

cat.var <- rep(1:3, 5)
 dim(contr.bayes.unordered(cat.var))
 # 15*15 baseline level kept!
 dim(contr.treatment(cat.var))
 # 15*14

arm

Data Analysis Using Regression and Multilevel/Hierarchical Models

v1.11-2
GPL (> 2)
Authors
Andrew Gelman [aut], Yu-Sung Su [aut, cre], Masanao Yajima [ctb], Jennifer Hill [ctb], Maria Grazia Pittau [ctb], Jouni Kerman [ctb], Tian Zheng [ctb], Vincent Dorie [ctb]
Initial release
2020-7-27

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.