File: lmBF.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 (96 lines) | stat: -rw-r--r-- 3,504 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
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/lmBF.R
\name{lmBF}
\alias{lmBF}
\title{Function to compute Bayes factors for specific linear models}
\usage{
lmBF(
  formula,
  data,
  whichRandom = NULL,
  rscaleFixed = "medium",
  rscaleRandom = "nuisance",
  rscaleCont = "medium",
  rscaleEffects = NULL,
  posterior = FALSE,
  progress = getOption("BFprogress", interactive()),
  ...
)
}
\arguments{
\item{formula}{a formula containing all factors to include in the analysis
(see Examples)}

\item{data}{a data frame containing data for all factors in the formula}

\item{whichRandom}{a character vector specifying which factors are random}

\item{rscaleFixed}{prior scale for standardized, reduced fixed effects. A
number of preset values can be given as strings; see Details.}

\item{rscaleRandom}{prior scale for standardized random effects}

\item{rscaleCont}{prior scale for standardized slopes. A
number of preset values can be given as strings; see Details.}

\item{rscaleEffects}{A named vector of prior settings for individual factors,
overriding rscaleFixed and rscaleRandom. Values are scales, names are factor names.}

\item{posterior}{if \code{TRUE}, return samples from the posterior
distribution instead of the Bayes factor}

\item{progress}{if \code{TRUE}, show progress with a text progress bar}

\item{...}{further arguments to be passed to or from methods.}
}
\value{
If \code{posterior} is \code{FALSE}, an object of class
  \code{BFBayesFactor}, containing the computed model comparisons is
  returned. Otherwise, an object of class \code{BFmcmc}, containing MCMC
  samples from the posterior is returned.
}
\description{
This function computes Bayes factors, or samples from the posterior, of
specific linear models (either ANOVA or regression).
}
\details{
This function provides an interface for computing Bayes factors  for
specific linear models against the intercept-only null; other tests may be
obtained by computing two models and dividing their Bayes factors. Specifics
about the priors for regression models -- and possible settings for
\code{rscaleCont} -- can be found in the help for \code{\link{regressionBF}};
likewise, details for ANOVA models -- and settings for \code{rscaleFixed}
and \code{rscaleRandom} -- can be found in the help for \code{\link{anovaBF}}.

Currently, the function does not allow for general linear models, containing
both continuous and categorical predcitors, but this support will be added
in the future.
}
\examples{
## Puzzles data; see ?puzzles for details
data(puzzles)
## Bayes factor of full model against null
bfFull = lmBF(RT ~ shape + color + shape:color + ID, data = puzzles, whichRandom = "ID")

## Bayes factor of main effects only against null
bfMain = lmBF(RT ~ shape + color + ID, data = puzzles, whichRandom = "ID")

## Compare the main-effects only model to the full model
bfMain / bfFull

## sample from the posterior of the full model
samples = lmBF(RT ~ shape + color + shape:color + ID,
           data = puzzles, whichRandom = "ID", posterior = TRUE,
           iterations = 1000)

## Aother way to sample from the posterior of the full model
samples2 = posterior(bfFull, iterations = 1000)
}
\seealso{
\code{\link{regressionBF}} and \code{anovaBF} for
testing many regression or ANOVA models simultaneously.
}
\author{
Richard D. Morey (\email{richarddmorey@gmail.com})
}
\keyword{htest}