File: posterior-methods.Rd

package info (click to toggle)
r-cran-bayesfactor 0.9.12-4.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,512 kB
  • sloc: cpp: 1,555; sh: 16; makefile: 7
file content (100 lines) | stat: -rw-r--r-- 4,520 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/aaGenerics.R, R/methods-BFmodelSample.R
\docType{methods}
\name{posterior}
\alias{posterior}
\alias{posterior,BFmodel,missing,data.frame,missing-method}
\alias{posterior,BFBayesFactor,missing,missing,missing-method}
\alias{posterior,BFBayesFactor,numeric,missing,numeric-method}
\alias{posterior,BFBayesFactor,missing,missing,numeric-method}
\alias{posterior,BFlinearModel,missing,data.frame,numeric-method}
\alias{posterior,BFindepSample,missing,data.frame,numeric-method}
\alias{posterior,BFcontingencyTable,missing,data.frame,numeric-method}
\alias{posterior,BFoneSample,missing,data.frame,numeric-method}
\alias{posterior,BFmetat,missing,data.frame,numeric-method}
\alias{posterior,BFproportion,missing,data.frame,numeric-method}
\alias{posterior,BFcorrelation,missing,data.frame,numeric-method}
\title{Sample from the posterior distribution of one of several models.}
\usage{
posterior(model, index, data, iterations, ...)

\S4method{posterior}{BFmodel,missing,data.frame,missing}(model, index, data, iterations, ...)

\S4method{posterior}{BFBayesFactor,missing,missing,missing}(model, index, data, iterations, ...)

\S4method{posterior}{BFBayesFactor,numeric,missing,numeric}(model, index, data, iterations, ...)

\S4method{posterior}{BFBayesFactor,missing,missing,numeric}(model, index = NULL, data, iterations, ...)

\S4method{posterior}{BFlinearModel,missing,data.frame,numeric}(model, index = NULL, data, iterations, ...)

\S4method{posterior}{BFindepSample,missing,data.frame,numeric}(model, index = NULL, data, iterations, ...)

\S4method{posterior}{BFcontingencyTable,missing,data.frame,numeric}(model, index = NULL, data, iterations, ...)

\S4method{posterior}{BFoneSample,missing,data.frame,numeric}(model, index = NULL, data, iterations, ...)

\S4method{posterior}{BFmetat,missing,data.frame,numeric}(model, index = NULL, data, iterations, ...)

\S4method{posterior}{BFproportion,missing,data.frame,numeric}(model, index = NULL, data, iterations, ...)

\S4method{posterior}{BFcorrelation,missing,data.frame,numeric}(model, index = NULL, data, iterations, ...)
}
\arguments{
\item{model}{or set of models from which to sample}

\item{index}{the index within the set of models giving the desired model}

\item{data}{the data to be conditioned on}

\item{iterations}{the number of iterations to sample}

\item{...}{arguments passed to and from related methods}
}
\value{
Returns an object containing samples from the posterior distribution
  of the specified model
}
\description{
This function samples from the posterior distribution of a \code{BFmodel},
which can be obtained from a \code{BFBayesFactor} object. If there is more
than one numerator in the \code{BFBayesFactor} object, the \code{index}
argument can be passed to select one numerator.
}
\details{
The data argument is used internally, and will y not be needed by
end-users.

Note that if there are fixed effects in the model, the reduced
parameterzation used internally (see help for \code{\link{anovaBF}}) is
unreduced. For a factor with two levels, the chain will contain two effect
estimates that sum to 0.

Two useful arguments that can be passed to related methods are \code{thin}
and \code{columnFilter}, currently implemented for methods using
\code{nWayAOV} (models with more than one categorical covariate, or a mix of
categorical and continuous covariates). \code{thin}, an integer, will keep
only every \code{thin} iterations. The default is \code{thin=1}, which keeps
all iterations. Argument \code{columnFilter} is either \code{NULL} (for no
filtering) or a character vector of extended regular expressions (see
\link{regex} help for details). Any column from an effect that matches one of
the filters will not be saved.
}
\examples{
## Sample from the posteriors for two models
data(sleep)

bf = lmBF(extra ~ group + ID, data = sleep, whichRandom="ID", progress=FALSE)

## sample from the posterior of the numerator model
## data argument not needed - it is included in the Bayes factor object
chains = posterior(bf, iterations = 1000, progress = FALSE)

plot(chains)

## demonstrate column filtering by filtering out participant effects
data(puzzles)
bf = lmBF(RT ~ shape + color + shape:color + ID, data=puzzles)
chains = posterior(bf, iterations = 1000, progress = FALSE, columnFilter="^ID$")
colnames(chains) # Contains no participant effects
}