Commit f04ec37e authored by Jonathon Love's avatar Jonathon Love

Imported Upstream version 0.9.12-2

parents
Makefile
BayesFactor-intro.Rnw
\ No newline at end of file
Package: BayesFactor
Type: Package
Title: Computation of Bayes Factors for Common Designs
Version: 0.9.12-2
Date: 2015-09-19
Authors@R: c(person("Richard D.", "Morey", role = c("aut", "cre"), email =
"richarddmorey@gmail.com"), person("Jeffrey N.", "Rouder", role = "aut",
email = "rouderj@missouri.edu"), person("Tahira", "Jamil", role = "ctb",
email = "tahjamil@gmail.com"))
Description: A suite of functions for computing
various Bayes factors for simple designs, including contingency tables,
one- and two-sample designs, one-way designs, general ANOVA designs, and
linear regression.
License: GPL-2
VignetteBuilder: knitr
Depends: R (>= 3.0.2), coda, Matrix (>= 1.1-1)
Imports: pbapply, mvtnorm, stringr, utils, graphics, gtools,
MatrixModels, Rcpp (>= 0.11.2), methods
Suggests: doMC, foreach, testthat, knitr, markdown, arm, lme4, xtable,
languageR
URL: http://bayesfactorpcl.r-forge.r-project.org/
BugReports: https://github.com/richarddmorey/BayesFactor/issues
LazyLoad: yes
LinkingTo: Rcpp (>= 0.11.2), RcppEigen (>= 0.3.2.2.0)
NeedsCompilation: yes
Packaged: 2015-09-19 10:57:22 UTC; richard
Author: Richard D. Morey [aut, cre],
Jeffrey N. Rouder [aut],
Tahira Jamil [ctb]
Maintainer: Richard D. Morey <richarddmorey@gmail.com>
Repository: CRAN
Date/Publication: 2015-09-19 19:50:23
This diff is collapsed.
useDynLib(BayesFactor)
export(logMeanExpLogs,
logCumMeanExpLogs,
BFInfo,
ttest.tstat,
oneWayAOV.Fstat,
linearReg.R2stat,
nWayAOV,
ttestBF,
lmBF,
regressionBF,
anovaBF,
BFManual,
as.BFBayesFactor,
as.BFprobability,
generalTestBF,
meta.ttestBF,
proportionBF,
contingencyTableBF,
enumerateGeneralModels,
logSummaryStats,
newPriorOdds,
"priorOdds<-",
"priorLogodds<-")
importFrom(methods, show)
importFrom(utils, head)
importFrom(utils, tail)
importFrom(graphics, plot)
importFrom(utils, packageDescription)
importFrom(Rcpp, evalCpp)
importFrom(gtools, rdirichlet)
importFrom(MatrixModels, model.Matrix)
import(mvtnorm, pbapply, stringr, coda, Matrix)
importFrom("graphics", "abline", "axis", "barplot", "par", "segments",
"text")
importFrom("methods", ".hasSlot", "S3Part", "S3Part<-", "as", "is",
"new", "slot", "slot<-", "slotNames")
importFrom("stats", "aov", "dbinom", "dnorm", "dt", "formula",
"integrate", "lm", "nlm", "optim", "pcauchy", "plogis",
"pt", "qlogis", "rgamma", "sd", "t.test", "terms", "var")
importFrom("utils", "combn", "setTxtProgressBar", "txtProgressBar",
"vignette")
exportClasses("BFmodel", "BFBayesFactor","BFlinearModel", "BFodds")
exportClasses("BFBayesFactorList", "BFoneSample","BFindepSample","BFcontingencyTable")
exportMethods("extractBF","compare","t","recompute","posterior","which.min","which.max","is.na","model.matrix")
exportMethods("extractOdds", "extractProbabilities","filterBF")
S3method("is.na","BFBayesFactor")
S3method("c","BFBayesFactor")
S3method("plot","BFBayesFactor")
S3method("head","BFBayesFactor")
S3method("tail","BFBayesFactor")
S3method("min","BFBayesFactor")
S3method("max","BFBayesFactor")
S3method("which.min","BFBayesFactor")
S3method("which.max","BFBayesFactor")
S3method("sort","BFBayesFactor")
S3method("as.data.frame","BFBayesFactor")
S3method("as.vector","BFBayesFactor")
S3method("names","BFBayesFactor")
S3method("length","BFBayesFactor")
S3method("t","BFBayesFactor")
S3method("as.matrix", "BFBayesFactorList")
S3method("as.vector", "BFBayesFactorList")
S3method("as.mcmc", "BFmcmc")
S3method("as.matrix", "BFmcmc")
S3method("as.data.frame", "BFmcmc")
S3method("as.BFBayesFactor", "BFBayesFactorTop")
S3method("plot","BFBayesFactorTop")
S3method("sort","BFBayesFactorTop")
S3method("length","BFBayesFactorTop")
S3method("as.BFBayesFactor", "BFodds")
S3method("as.BFprobability", "BFodds")
S3method("c","BFodds")
S3method("length","BFodds")
S3method("head","BFodds")
S3method("tail","BFodds")
S3method("min","BFodds")
S3method("max","BFodds")
S3method("which.min","BFodds")
S3method("which.max","BFodds")
S3method("sort","BFodds")
S3method("as.data.frame","BFodds")
S3method("as.vector","BFodds")
S3method("names","BFodds")
S3method("head","BFprobability")
S3method("tail","BFprobability")
S3method("min","BFprobability")
S3method("max","BFprobability")
S3method("which.min","BFprobability")
S3method("which.max","BFprobability")
S3method("sort","BFprobability")
S3method("as.data.frame","BFprobability")
S3method("as.vector","BFprobability")
S3method("names","BFprobability")
S3method("length","BFprobability")
S3method("sum","BFprobability")
CHANGES IN BayesFactor VERSION 0.9.12-2
CHANGES
* Added feature allowing fine-tuning of priors on a per-effect basis: see new argument
rscaleEffects of lmBF, anovaBF, and generalTestBF
* Fixed bug that disallowed logical indexing of probability objects
* Fixed minor typos in documentation
* Fixed bug causing regression Bayes factors to fail for very small R^2
* Fixed bug disallowing expansion of dot (.) in generalTestBF model specifications
* Fixed bug preventing cancelling of all analyses with interrupt
* Restricted contingency prior to values >=1
* All BFmodel objects have additional "analysis" slot giving details of analysis
CHANGES IN BayesFactor VERSION 0.9.11-1
CHANGES
* Fixed memory bug causing importance sampling to fail.
CHANGES IN BayesFactor VERSION 0.9.11
CHANGES
* Added support for prior/posterior odds and probabilities. See the new vignette for details.
* Added approximation for t test in case of large t
* Made some error messages clearer
* Use callbacks at least once in all cases
* Fix bug preventing continuous interactions from showing in regression Gibbs sampler
* Removed unexported function oneWayAOV.Gibbs(), and related C functions, due to redundancy
* gMap from model.matrix is now 0-indexed vector (for compatibility with C functions)
* substantial changes to backend, to Rcpp and RcppEigen for speed
* removed redundant struc argument from nWayAOV (use gMap instead)
CHANGES IN BayesFactor VERSION 0.9.10-2
CHANGES
* Removed "see also" to package BAS, due to its being archived
CHANGES IN BayesFactor VERSION 0.9.10-1
CHANGES
* Fixed issue causing Solaris build to fail
CHANGES IN BayesFactor VERSION 0.9.10
CHANGES
* Fixed bug in model enumeration code in generalTestBF (affected "withmain" analyses with neverExclude argument)
* Various bug fixes
* Analyses are more error tolerant (problem analyses will yield NA in BayesFactor object)
* Fixed some typos in citation information
* Improved numerical stability of proportional error estimates
CHANGES IN BayesFactor VERSION 0.9.9
CHANGES
* Added "simple" argument to ttest.tstat, oneWayAOV.Fstat, and linearReg.R2stat; when TRUE, return only the Bayes factor (not the log BF and error)
* When sampling Bayes factors, recompute() now increases the precision of BayesFactor objects, rather than simply recomputing them. Precision from new samples is added
* Added test for single proportion; see proportionBF()
* Added support for contingency tables; see contingencyBF()
* Added Hraba and Grant (1970) data set; see ?raceDolls
* Added model.matrix method for BayesFactor objects; allows for extracting the design matrix used for an analysis
* recompute() now has multicore and callback support, as intended
* Refactored t test and meta-t test code
* Moved many backend functions to Rcpp from R C API
* t test samplers now sample from interval null hypotheses and point null hypotheses where appropriate
* fixed bug in in meta t test sampler which wouldn't allow sampling small numbers of MCMC samples
CHANGES IN BayesFactor VERSION 0.9.8
CHANGES
* Fixed bugs in model enumeration code
* Fixed bug leading to wrong computation of number of covariate when interactions between continuous variables were included
* Corrected typos/old information in the documentation
* Fixed a memory allocation bug that affected computing Bayes factors with lots of data
* Added meta-analytic Bayes factor for t tests (see meta.ttestBF)
* Fixed bug in ttestBF that yielded Bayes factor of NaN for very extreme posterior interval probabilities
* Fixed several bugs causing infinite integrals; generally improved integration
* Added check to ensure no missing data before analyses
* Added callbacks for access by third-party interfaces
CHANGES IN BayesFactor VERSION 0.9.7
CHANGES
* Fixed a bug causing posterior sampling of t test to fail when data was defined as integer type
* Fixed a bug causing a two-way interaction to sometimes not be included in 3-way ANOVA analyses
* Reworked model enumeration code to be more efficient and faster; 4-way analyses no longer take a long time to build
* Moved 'methods' to Depends so that Rscript will work without the user having to explicitly load the package methods
CHANGES IN BayesFactor VERSION 0.9.6
CHANGES
* Fixed a bug causing Bayes factors to evaluate to NA when matrix inversion fails (very rare)
* Fixed a bug causing computation to fail if importance sampling fails in nWayAOV. Uses method="simple" as a fallback.
* Fixed a bug where quadrature failed for large F values in unbalanced one-way ANOVA designs
* Data frame for linear model analyses now get modified: character columns are converted to factors, and factors are re-factor()ed to get rid of levels with no observations
* Increased prior scales in one-sample t test by a factor of sqrt(2), in order to be consistent with the two-sample t test for the same effect size and effective sample size
* Added vignette with prior checks to show consistency across methods
* Added vignette with comparisons of BayesFactor results to arm/lme4
CHANGES IN BayesFactor VERSION 0.9.5
CHANGES
* Minor bug fixes
* Changed back to new R 3.0 vignette building (and moved files to vignettes directory)
* Restricted to R >= 3.0.0
CHANGES IN BayesFactor VERSION 0.9.4
CHANGES
* Fixed bug in sampling of posteriors in linear models
* Fixed bug computing the Bayes factor of unbalanced one-way ANOVA with two levels - caused function to fail
* Fixed occasional problem where optimization for the importance sampler would fail, giving a numerically singular matrix
* Fixed problem where extremely rare large or small g values from the sampler would cause the Bayes factor to be NA (again, creating a singular numerically singular matrix). These very rare samples are now disregarded.
* Added global option to turn progress bars on or off; use options(BFprogress = TRUE) or options(BFprogress = FALSE)
* Added MCMC chain thinning to nWayAOV - to use, pass "thin" argument to posterior() or lmBF()
* Added MCMC chain column filtering, useful for low memory systems. To use, pass "columnFilter" argument to posterior() or lmBF(). See the help for posterior() for more details.
* Added function generalTestBF(), which allows testing of restrictions on a full model in a manner similar to regressionBF() and anovaBF().
* Added "noSample" argument to many functions. These will disable time-consuming sampling, and return an object of the same structure as if sampling had been done. This allows for the culling of BayesFactor objects and preplanning chain analyses before sampling
* Added is.na() method for BFBayesFactor objects. When combined with recompute() and noSample (see above), this allows one to create lists of models with missing Bayes factors, remove uninteresting models, then recompute only the missing ones
CHANGES IN BayesFactor VERSION 0.9.3
CHANGES
* Restricted to R 3.0.0 (due to vignette compilation).
CHANGES IN BayesFactor VERSION 0.9.2
CHANGES
* Full support for linear models: continuous and categorical covariates can now be included in the same model using lmBF()
* Minor changes to the BayesFactor output to make it clearer
* Fixed display of very large and very small Bayes factors; no longer will display read something like "Inf (2%)" or the like
* Clearer labels on MCMC output
* When error is missing from the BayesFactor object, plot prints "?" next to the bar to indicate no error estimate is available
* Default prior scale setting changed for continuous covariates; scale now defaults to sqrt(2)/4, which corresponds to the ANOVA "medium" setting (and will give the same Bayes factor in special cases where they should)
* Default prior scale setting in one-sample t changed to 1/2 (it was erroneously changed to sqrt(2)/2). Two-sample t test default setting remains the same, at sqrt(2)/2
* Added new prior scale settings for random effects; default to "nuisance", which is the same as the old default (r=1)
* New prior scale setting: "ultrawide"
* Fixed bug with BFManual() which caused it not to start if dynamic help had not been started yet
* When doing an Bayes factor analysis that requires sampling, the new default setting (method="auto") will automatically try to select the best sampler for you so that you get the most efficient samples.
CHANGES IN BayesFactor VERSION 0.9.1
CHANGES
* Vignette compilation changed for compatibility with R 3.0.0
CHANGES IN BayesFactor VERSION 0.9.0
CHANGES
* New S4 classes representing Bayes factors, models, and MCMC chains. The output of all functions will now be objects of these classes
* Error estimates are now given for all Bayes factor outputs
* To accomodate the new system for creating and manipulating Bayes factors, the main function names have all changed. ANOVA is done via anovaBF(), multiple regression is done via regressionBF() and both can be done through lmBF()
* Posterior sampling is supported by calling the new posterior() method on Bayes factor objects. The result is an BayesFactor MCMC object, which inherits methods for for mcmc objects from the coda class
* New recompute() method will allow the reestimation of Bayes factors (for Bayes factor objects) and restimation of posteriors (for BayesFactor MCMC objects)
* New cleaned-up code base
#'Functions to compute Bayes factor hypothesis tests for common research designs
#'and hypotheses.
#'
#'This package contains function to compute Bayes factors for a number of
#'research designs and hypotheses, including t tests, ANOVA, and linear
#'regression, and contingency tables.
#'
#'\tabular{ll}{ Package: \tab BayesFactor\cr Type: \tab Package\cr Version: \tab
#'0.9.12\cr Date: \tab 2015-4-20\cr License: \tab GPL 2.0\cr LazyLoad: \tab
#'yes\cr } The following methods are currently implemented, with more to follow:
#'
#'general linear models (including linear mixed effects models): \code{\link{generalTestBF}}, \code{\link{lmBF}}
#'
#'linear regression: \code{\link{regressionBF}}, \code{\link{lmBF}},
#'\code{\link{linearReg.R2stat}};
#'
#'t tests: \code{\link{ttestBF}}, \code{\link{ttest.tstat}};
#'
#'meta-analytic t tests: \code{\link{meta.ttestBF}}
#'
#'ANOVA: \code{\link{anovaBF}}, \code{\link{lmBF}}, \code{\link{oneWayAOV.Fstat}};
#'
#'contingency tables: \code{\link{contingencyTableBF}};
#'
#'single proportions: \code{\link{proportionBF}};
#'
#'Other useful functions: \code{\link{posterior}}, for sampling from posterior
#'distributions; \code{\link{recompute}}, for re-estimating a Bayes factor or
#'posterior distribution; \code{\link{compare}}, to compare two model
#'posteriors; and \code{\link{plot.BFBayesFactor}}, for plotting Bayes factor
#'objects.
#'
#'@name BayesFactor-package
#'@aliases BayesFactor-package BayesFactor
#'@docType package
#'@author Richard D. Morey and Jeffrey N. Rouder (with contributions from Tahira Jamil)
#'
#' Maintainer: Richard D. Morey <richarddmorey@@gmail.com>
#'@references Liang, F. and Paulo, R. and Molina, G. and Clyde, M. A. and
#' Berger, J. O. (2008). Mixtures of g-priors for Bayesian Variable Selection.
#' Journal of the American Statistical Association, 103, pp. 410-423
#'
#' Rouder, J. N., Speckman, P. L., Sun, D., Morey, R. D., \& Iverson, G.
#' (2009). Bayesian t-tests for accepting and rejecting the null hypothesis.
#' Psychonomic Bulletin & Review, 16, 225-237
#'
#' Rouder, J. N., Morey, R. D., Speckman, P. L., Province, J. M., (2012)
#' Default Bayes Factors for ANOVA Designs. Journal of Mathematical Psychology.
#' 56. p. 356-374.
#'
#' Perception and Cognition Lab (University of Missouri): Bayes factor
#' calculators. \url{http://pcl.missouri.edu/bayesfactor}
#'@keywords htest
#'@examples
#'
#'## See specific functions for examples.
#'
#'@useDynLib BayesFactor
NULL
#'Puzzle completion times from Hays (1994)
#'
#'Puzzle completion time example data from Hays (1994).
#'
#'Hays (1994; section 13.21, table 13.21.2, p. 570) describes a experiment
#'wherein 12 participants complete four puzzles each. Puzzles could be either
#'square or round, and either monochromatic or in color. Each participant
#'completed every combination of the two factors.
#'
#'@name puzzles
#'@docType data
#'@format A data frame with 48 observations on 3 variables. \describe{
#'\item{RT}{Puzzle completion time, in minutes} \item{ID}{the
#'subject identifier} \item{shape}{shape of the puzzle (round or
#'square)} \item{color}{color content of the puzzle (monochromatic or
#'color)} }
#'@source Hays, W. L. (1994), Statistics (5th edition), Harcourt Brace, Fort
#'Worth, Texas
#'@keywords datasets
#'@examples
#'
#'data(puzzles)
#'
#'## classical ANOVA
#'## Both color and shape are significant, interaction is not
#'classical <- aov(RT ~ shape*color + Error(ID/(shape*color)), data=puzzles)
#'summary(classical)
#'
#'## Bayes Factor
#'## Best model is main effects model, no interaction
#' anovaBF(RT ~ shape*color + ID, data = puzzles, whichRandom = "ID", progress=FALSE)
#'
#'
NULL
#'Hraba and Grant (1970) children's doll preference data
#'
#'Hraba and Grant (1970) describe a replication of Clark and Clark (1947) in which
#'black and white children from Lincoln, Nebraska were shown dolls that were either black
#'or white. They were then asked a series of questions, including "Give me the doll that is
#'a nice doll." This data set contains the frequency of children giving the same-race or different race doll in
#'response to this question.
#'@name raceDolls
#'@docType data
#'@format A matrix with 2 rows and 2 columns. Rows give doll preference; colums give the
#'race of the child.
#'@source Hraba, J. and Grant, G. (1970). Black is Beautiful: A reexamination of
#'racial preference and identification. Journal of Personality and Social Psychology, 16, 398-402.
#'
#'@keywords datasets
#'@examples
#'
#'data(raceDolls)
#'
#'## chi-square test
#'## Barely significant with continuity correction
#'chisq.test(raceDolls)
#'
#'## Bayes factor test (assuming independent binomial sampling plan)
#'## Very little evidence for the alternative of lack of independence
#'bf = contingencyTableBF(raceDolls, sampleType = "indepMulti", fixedMargin = "cols")
#'bf
NULL
# This file was generated by Rcpp::compileAttributes
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
dinvgamma1_Rcpp <- function(x, a, b) {
.Call('BayesFactor_dinvgamma1_Rcpp', PACKAGE = 'BayesFactor', x, a, b)
}
dinvgamma1_logx_Rcpp <- function(x, a, b) {
.Call('BayesFactor_dinvgamma1_logx_Rcpp', PACKAGE = 'BayesFactor', x, a, b)
}
ddinvgamma1_Rcpp <- function(x, a, b) {
.Call('BayesFactor_ddinvgamma1_Rcpp', PACKAGE = 'BayesFactor', x, a, b)
}
d2dinvgamma1_Rcpp <- function(x, a, b) {
.Call('BayesFactor_d2dinvgamma1_Rcpp', PACKAGE = 'BayesFactor', x, a, b)
}
jzs_sampler <- function(iterations, y, X, rscale, gMap, incCont, importanceMu, importanceSig, progress, callback, callbackInterval, which) {
.Call('BayesFactor_jzs_sampler', PACKAGE = 'BayesFactor', iterations, y, X, rscale, gMap, incCont, importanceMu, importanceSig, progress, callback, callbackInterval, which)
}
jzs_log_marginal_posterior_logg <- function(q, sumSq, N, XtCnX0, CnytCnX0, rscale, gMap, gMapCounts, priorX, incCont, limit, limits, which) {
.Call('BayesFactor_jzs_log_marginal_posterior_logg', PACKAGE = 'BayesFactor', q, sumSq, N, XtCnX0, CnytCnX0, rscale, gMap, gMapCounts, priorX, incCont, limit, limits, which)
}
jzs_Gibbs <- function(iterations, y, X, rscale, sig2start, gMap, gMapCounts, incCont, nullModel, ignoreCols, thin, progress, callback, callbackInterval) {
.Call('BayesFactor_jzs_Gibbs', PACKAGE = 'BayesFactor', iterations, y, X, rscale, sig2start, gMap, gMapCounts, incCont, nullModel, ignoreCols, thin, progress, callback, callbackInterval)
}
GibbsLinearRegRcpp <- function(iterations, y, X, r, sig2start, nullModel, progress, callback, callbackInterval) {
.Call('BayesFactor_GibbsLinearRegRcpp', PACKAGE = 'BayesFactor', iterations, y, X, r, sig2start, nullModel, progress, callback, callbackInterval)
}
log_determinant_pos_def <- function(A) {
.Call('BayesFactor_log_determinant_pos_def', PACKAGE = 'BayesFactor', A)
}
logSummaryStats <- function(x) {
.Call('BayesFactor_logSummaryStats', PACKAGE = 'BayesFactor', x)
}
log1pExp <- function(x) {
.Call('BayesFactor_log1pExp', PACKAGE = 'BayesFactor', x)
}
logExpXplusExpY <- function(x, y) {
.Call('BayesFactor_logExpXplusExpY', PACKAGE = 'BayesFactor', x, y)
}
logExpXminusExpY <- function(x, y) {
.Call('BayesFactor_logExpXminusExpY', PACKAGE = 'BayesFactor', x, y)
}
metropMetaTRcpp <- function(t, n1, n2, twoSample, rscale, iterations, doInterval, interval, intervalCompl, nullModel, progress, callback, callbackInterval) {
.Call('BayesFactor_metropMetaTRcpp', PACKAGE = 'BayesFactor', t, n1, n2, twoSample, rscale, iterations, doInterval, interval, intervalCompl, nullModel, progress, callback, callbackInterval)
}
metropProportionRcpp <- function(y, n, p0, rscale, iterations, doInterval, interval, intervalCompl, nullModel, progress, callback, callbackInterval) {
.Call('BayesFactor_metropProportionRcpp', PACKAGE = 'BayesFactor', y, n, p0, rscale, iterations, doInterval, interval, intervalCompl, nullModel, progress, callback, callbackInterval)
}
gibbsTwoSampleRcpp <- function(ybar, s2, N, rscale, iterations, doInterval, interval, intervalCompl, nullModel, progress, callback, callbackInterval) {
.Call('BayesFactor_gibbsTwoSampleRcpp', PACKAGE = 'BayesFactor', ybar, s2, N, rscale, iterations, doInterval, interval, intervalCompl, nullModel, progress, callback, callbackInterval)
}
gibbsOneSampleRcpp <- function(ybar, s2, N, rscale, iterations, doInterval, interval, intervalCompl, nullModel, progress, callback, callbackInterval) {
.Call('BayesFactor_gibbsOneSampleRcpp', PACKAGE = 'BayesFactor', ybar, s2, N, rscale, iterations, doInterval, interval, intervalCompl, nullModel, progress, callback, callbackInterval)
}
# https://stat.ethz.ch/pipermail/r-devel/2010-May/057506.html
## for 'i' in x[i] or A[i,] : (numeric = {double, integer})
# setClassUnion("index", members = c("numeric", "logical", "character"))
#' General S4 classes for representing models for comparison
#'
#' The \code{BFmodel} is a general S4 class for representing models for comparison. The more classes
#' \code{BFlinearModel}, \code{BFindepSample}, and \code{BFoneSample} inherit directly from \code{BFmodel}.
#'
#' \describe{
#' These model classes all have the following slots defined:
#' \item{type}{Model type}
#' \item{identifier}{a list uniquely identifying the model from other models of the same type}
#' \item{prior}{list giving appropriate prior settings for the model}
#' \item{dataTypes}{a character vector whose names are possible columns in the data; elements specify the corresponding data type, currently one of c("fixed","random","continuous")}
#' \item{shortName}{a short, readable identifying string}
#' \item{longName}{a longer, readable identifying string}
#' \item{analysis}{object storing information about a previous analysis of this model}
#' \item{version}{character string giving the version and revision number of the package that the model was created in}
#' }
#' @name BFmodel-class
#' @rdname model-classes
#' @export
setClass("BFmodel", representation(
type = "character",
identifier = "list",
prior = "list",
dataTypes = "character",
shortName = "character",
longName = "character",
analysis = "list",
version = "character"
))
#' @name BFcontingencyTable-class
#' @rdname model-classes
setClass("BFproportion", contains = "BFmodel")
#' @name BFcontingencyTable-class
#' @rdname model-classes
setClass("BFcontingencyTable", contains = "BFmodel")
#' @name BFlinearModel-class
#' @rdname model-classes
setClass("BFlinearModel", contains = "BFmodel")
#' @name BFoneSample-class
#' @rdname model-classes
setClass("BFoneSample", contains = "BFlinearModel")
#' @name BFoneSample-class
#' @rdname model-classes
setClass("BFmetat", contains = "BFmodel")
#' @name BFindepSample-class
#' @rdname model-classes
setClass("BFindepSample", contains = "BFlinearModel")
#' General S4 class for representing multiple Bayes factor model comparisons, all against the same model
#'
#' The \code{BFBayesFactor} class is a general S4 class for representing models model comparison via Bayes factor.
#'
#' \code{BFBayesFactor} objects can be inverted by taking the reciprocal and can
#' be divided by one another, provided both objects have the same denominator. In addition,
#' the \code{t} (transpose) method can be used to invert Bayes factor objects.
#' \describe{
#' The \code{BFBayesFactor} class has the following slots defined:
#' \item{numerator}{a list of models all inheriting \code{BFmodel}, each providing a single denominator}
#' \item{denominator}{a single \code{BFmodel} object serving as the denominator for all model comparisons}
#' \item{bayesFactor}{a data frame containing information about the comparison between each numerator and the denominator}
#' \item{data}{a data frame containing the data used for the comparison}
#' \item{version}{character string giving the version and revision number of the package that the model was created in}
#' }
#' @name BFBayesFactor-class
#' @export
#' @examples
#' ## Compute some Bayes factors to demonstrate division and indexing
#' data(puzzles)
#' bfs <- anovaBF(RT ~ shape*color + ID, data = puzzles, whichRandom = "ID", progress=FALSE)
#'
#' ## First and second models can be separated; they remain BFBayesFactor objects
#' b1 = bfs[1]
#' b2 = bfs[2]
#' b1
#'
#' ## We can invert them, or divide them to obtain new model comparisons
#' 1/b1
#' b1 / b2
#'
#' ## Use transpose to create a BFBayesFactorList
#' t(bfs)
setClass("BFBayesFactor", representation(
numerator = "list",
denominator = "BFmodel",
bayesFactor = "data.frame",
data = "data.frame",
version = "character"
))
#' General S4 class for representing a collection of Bayes factor model
#' comprisons, each against a different denominator
#'
#' The \code{BFBayesFactorList} class is a general S4 class for representing
#' models model comparison via Bayes factor. See the examples for demonstrations
#' of BFBayesFactorList methods.
#'
#' \describe{ \code{BFBayesFactorList} objects inherit from lists, and contain a
#' single slot:
#'
#' \item{version}{character string giving the version and revision number of the
#' package that the model was created in}
#'
#' Each element of the list contains a single
#' \code{"\link[=BFBayesFactor-class]{BFBayesFactor}"} object. Each element of
#' the list must have the same numerators, in the same order, as all the others.
#' The list object is displayed as a matrix of Bayes factors. }
#' @name BFBayesFactorList-class
#' @export
#' @examples
#' ## Compute some Bayes factors to demonstrate Bayes factor lists
#' data(puzzles)
#' bfs <- anovaBF(RT ~ shape*color + ID, data = puzzles, whichRandom = "ID", progress=FALSE)
#'
#' ## Create a matrix of Bayes factors
#' bfList <- bfs / bfs
#' bfList
#'
#' ## Use indexing to select parts of the 'matrix'
#' bfList[1,]
#' bfList[,1]
#'
#' ## We can use the t (transpose) function as well, to get back a BFBayesFactor
#' t(bfList[2,])
#'
#' ## Or transpose the whole matrix
#' t(bfList)
setClass("BFBayesFactorList", contains = "list", representation(version="character"))
#' @name BFBayesFactorTop-class
#' @rdname BFBayesFactor-class
setClass("BFBayesFactorTop", contains = "BFBayesFactor")
setOldClass("mcmc")
setClass("BFmcmc", contains = "mcmc", representation(model="BFmodel",data = "data.frame"))
setClassUnion("BFOrNULL", members = c("BFBayesFactor", "NULL"))
#' General S4 class for representing multiple odds model comparisons, all against the same model
#'
#' The \code{BFodds} class is a general S4 class for representing models model comparison via prior or posterior odds.
#'
#' \code{BFodds} objects can be inverted by taking the reciprocal and can