Learn R Programming

EMC2 (version 3.1.0)

hypothesis.emc: Within-Model Hypothesis Testing

Description

Approximates the Bayes factor for parameter effects using the savage-dickey ratio.

Usage

# S3 method for emc
hypothesis(
  emc,
  parameter = NULL,
  H0 = 0,
  fun = NULL,
  selection = "mu",
  do_plot = TRUE,
  use_prior_lim = TRUE,
  N = 10000,
  prior_args = list(),
  ...
)

hypothesis(emc, ...)

Value

The Bayes factor for the hypothesis against H0.

Arguments

emc

An emc object

parameter

A string. A parameter which you want to compare to H0. Will not be used if a FUN is specified.

H0

An integer. The H0 value which you want to compare to

fun

A function. Specifies an operation to be performed on the sampled or mapped parameters.

selection

A Character string. Indicates which parameter type to use (e.g., alpha, mu, sigma2, correlation).

do_plot

Boolean. If FALSE will omit the prior-posterior plot and only return the savage-dickey ratio.

use_prior_lim

Boolean. If TRUE will use xlimits based on prior density, otherwise based on posterior density.

N

Integer. How many prior samples to draw

prior_args

A list. Optional additional arguments to be passed to plot.default for the plotting of the prior density (see par())

...

Optional arguments that can be passed to get_pars, density, or plot.default (see par())

Details

Note this is different to the computation of the marginal deviance in compare since it only considers the group level effect and not the whole model (i.e. subject-level parameters). For details see: Wagenmakers, Lodewyckx, Kuriyal, & Grasman (2010).

Examples

Run this code
# Here the emc object has an effect parameter (e.g. m),
# that maps onto a certain hypothesis.
# The hypothesis here is that m is different from zero.
# We can test whether there's a group-level effect on m:
hypothesis(samples_LNR, parameter = "m")
# Alternatively we can also test whether two parameters differ from each other
mdiff <- function(p)diff(p[c("m","m_lMd")])
hypothesis(samples_LNR,fun=mdiff)

Run the code above in your browser using DataLab