contr.BayesTools | R Documentation |
BayesTools provides several contrast matrix functions for Bayesian factor analysis. These functions create different types of contrast matrices that can be used with factor variables in Bayesian models.
contr.orthonormal(n, contrasts = TRUE)
contr.meandif(n, contrasts = TRUE)
contr.independent(n, contrasts = TRUE)
n |
a vector of levels for a factor, or the number of levels |
contrasts |
logical indicating whether contrasts should be computed |
The package includes the following contrast functions:
contr.orthonormal
Return a matrix of orthonormal contrasts.
Code is based on stanova::contr.bayes
and corresponding to description
by \insertCiterouder2012default;textualBayesTools. Returns a matrix with n rows and
k columns, with k = n - 1 if contrasts = TRUE
and k = n if contrasts = FALSE
.
contr.meandif
Return a matrix of mean difference contrasts.
This is an adjustment to the contr.orthonormal
that ascertains that the prior
distributions on difference between the gran mean and factor level are identical independent
of the number of factor levels (which does not hold for the orthonormal contrast). Furthermore,
the contrast is re-scaled so the specified prior distribution exactly corresponds to the prior
distribution on difference between each factor level and the grand mean – this is approximately
twice the scale of contr.orthonormal
. Returns a matrix with n rows and k columns,
with k = n - 1 if contrasts = TRUE
and k = n if contrasts = FALSE
.
contr.independent
Return a matrix of independent contrasts – a level for each term.
Returns a matrix with n rows and k columns, with k = n if contrasts = TRUE
and k = n
if contrasts = FALSE
.
# Orthonormal contrasts
contr.orthonormal(c(1, 2))
contr.orthonormal(c(1, 2, 3))
# Mean difference contrasts
contr.meandif(c(1, 2))
contr.meandif(c(1, 2, 3))
# Independent contrasts
contr.independent(c(1, 2))
contr.independent(c(1, 2, 3))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.