Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
content badge
swh:1:cnt:16c452a0e4a2b6e19369db30b48dcb92eac1869d

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/contr.bayes.R
\name{contr.bayes}
\alias{contr.bayes}
\title{Orthonormal Contrast Matrices for Bayesian Estimation}
\usage{
contr.bayes(n, contrasts = TRUE)
}
\arguments{
\item{n}{a vector of levels for a factor, or the number of levels.}

\item{contrasts}{logical indicating whether contrasts should be computed.}
}
\value{
A \code{matrix} with n rows and k columns, with k=n-1 if contrasts is
  \code{TRUE} and k=n if contrasts is \code{FALSE}.
}
\description{
Returns a design or model matrix of orthonormal contrasts such that the
marginal prior on all effects is identical. Implementation from Singmann
\& Gronau's \href{https://github.com/bayesstuff/bfrms/}{\code{bfrms}},
following the description in Rouder, Morey, Speckman, \& Province (2012, p. 363).
}
\details{
Though using this factor coding scheme might obscure the interpretation of
parameters, it is essential for correct estimation of Bayes factors for
contrasts and multi-level order restrictions. See info on specifying correct
priors for factors with more than 2 levels in
\href{https://easystats.github.io/bayestestR/articles/bayes_factors.html}{the Bayes factors vignette}.
}
\examples{
\dontrun{
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)
#            [,1]       [,2]       [,3]       [,4]
# [1,]  0.0000000  0.8944272  0.0000000  0.0000000
# [2,]  0.0000000 -0.2236068 -0.5000000  0.7071068
# [3,]  0.7071068 -0.2236068 -0.1666667 -0.4714045
# [4,] -0.7071068 -0.2236068 -0.1666667 -0.4714045
# [5,]  0.0000000 -0.2236068  0.8333333  0.2357023

## check decomposition
Q3 <- contr.bayes(3)
Q3 \%*\% t(Q3)
#            [,1]       [,2]       [,3]
# [1,]  0.6666667 -0.3333333 -0.3333333
# [2,] -0.3333333  0.6666667 -0.3333333
# [3,] -0.3333333 -0.3333333  0.6666667
## 2/3 on diagonal and -1/3 on off-diagonal elements
}
}
\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
}

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API