Package 'BFpack'

Title: Flexible Bayes Factor Testing of Scientific Expectations
Description: Implementation of default Bayes factors for testing statistical hypotheses under various statistical models. The package is intended for applied quantitative researchers in the social and behavioral sciences, medical research, and related fields. The Bayes factor tests can be executed for statistical models such as univariate and multivariate normal linear models, correlation analysis, generalized linear models, special cases of linear mixed models, survival models, relational event models. Parameters that can be tested are location parameters (e.g., group means, regression coefficients), variances (e.g., group variances), and measures of association (e.g,. polychoric/polyserial/biserial/tetrachoric/product moments correlations), among others. The statistical underpinnings are described in Mulder and Xin (2019) <DOI:10.1080/00273171.2021.1904809>, Mulder and Gelissen (2019) <DOI:10.1080/02664763.2021.1992360>, Mulder (2016) <DOI:10.1016/j.jmp.2014.09.004>, Mulder and Fox (2019) <DOI:10.1214/18-BA1115>, Mulder and Fox (2013) <DOI:10.1007/s11222-011-9295-3>, Boeing-Messing, van Assen, Hofman, Hoijtink, and Mulder (2017) <DOI:10.1037/met0000116>, Hoijtink, Mulder, van Lissa, and Gu, (2018) <DOI:10.31234/osf.io/v3shc>, Gu, Mulder, and Hoijtink, (2018) <DOI:10.1111/bmsp.12110>, Hoijtink, Gu, and Mulder, (2018) <DOI:10.1111/bmsp.12145>, and Hoijtink, Gu, Mulder, and Rosseel, (2018) <DOI:10.1037/met0000187>. When using the packages, please refer to Mulder et al. (2021) <DOI:10.18637/jss.v100.i18>.
Authors: Joris Mulder [aut, cre], Caspar van Lissa [aut, ctb], Donald R. Williams [aut, ctb], Xin Gu [aut, ctb], Anton Olsson-Collentine [aut, ctb], Florian Boeing-Messing [aut, ctb], Jean-Paul Fox [aut, ctb], Janosch Menke [ctb], Robbie van Aert [ctb], Barry Brown [ctb], James Lovato [ctb], Kathy Russell [ctb], Lapack 3.8 [ctb], Jack Dongarra [ctb], Jim Bunch [ctb], Cleve Moler [ctb], Gilbert Stewart [ctb], John Burkandt [ctb], Ashwith Rego [ctb], Alexander Godunov [ctb], Alan Miller [ctb], Jean-Pierre Moreau [ctb], The R Core Team [cph]
Maintainer: Joris Mulder <[email protected]>
License: GPL (>= 3)
Version: 1.3.0
Built: 2024-11-11 07:30:11 UTC
Source: CRAN

Help Index


BFpack: Flexible Bayes factor testing of scientific expectations

Description

The R package BFpack provides tools for exploratory and confirmatory Bayesian hypothesis testing using Bayes factors and posterior probabilities under common statistical models. The main function 'BF' needs a fitted model 'x' as input argument. Depending on the class of the fitted model, a standard hypothesis test is executed by default. For example, if 'x' is a fitted regression model of class 'lm' then posterior probabilities are computed of whether each separate coefficient is zero, negative, or positive (assuming equal prior probabilities). If one has specific hypotheses with equality and/or order constraints on the parameters under the fitted model 'x' then these can be formulated using the 'hypothesis' argument (a character string), possibly together prior probabilities for the hypotheses via the 'prior' argument (default all hypotheses are equally likely a priori), and the 'complement' argument which is a logical stating whether the complement hypotheses should be included in the case ('TRUE' by default).

Use compilation for Fortran functions

Author(s)

Maintainer: Joris Mulder [email protected]

Authors:

Other contributors:

  • Janosch Menke [email protected] [contributor]

  • Robbie van Aert [email protected] [contributor]

  • Barry Brown [contributor]

  • James Lovato [contributor]

  • Kathy Russell [contributor]

  • Lapack 3.8 [contributor]

  • Jack Dongarra [contributor]

  • Jim Bunch [contributor]

  • Cleve Moler [contributor]

  • Gilbert Stewart [contributor]

  • John Burkandt [contributor]

  • Ashwith Rego [contributor]

  • Alexander Godunov [contributor]

  • Alan Miller [contributor]

  • Jean-Pierre Moreau [contributor]

  • The R Core Team [copyright holder]

References

Mulder, J., D.R. Williams, Gu, X., A. Tomarken, F. Böing-Messing, J.A.O.C. Olsson-Collentine, Marlyne Meyerink, J. Menke, J.-P. Fox, Y. Rosseel, E.J. Wagenmakers, H. Hoijtink., and van Lissa, C. (submitted). BFpack: Flexible Bayes Factor Testing of Scientific Theories in R. https://arxiv.org/abs/1911.07728

Mulder, J., van Lissa, C., Gu, X., Olsson-Collentine, A., Boeing-Messing, F., Williams, D. R., Fox, J.-P., Menke, J., et al. (2019). BFpack: Flexible Bayes Factor Testing of Scientific Expectations. (Version 0.2.1) https://CRAN.R-project.org/package=BFpack

See Also

Useful links:

Examples

## Not run: 
# EXAMPLE 1. One-sample t test
ttest1 <- t_test(therapeutic, mu = 5)
print(ttest1)
# confirmatory Bayesian one sample t test
BF1 <- BF(ttest1, hypothesis = "mu = 5")
summary(BF1)
# exploratory Bayesian one sample t test
BF(ttest1)

# EXAMPLE 2. ANOVA
aov1 <- aov(price ~ anchor * motivation,data = tvprices)
BF1 <- BF(aov1, hypothesis = "anchorrounded = motivationlow;
                              anchorrounded < motivationlow")
summary(BF1)

# EXAMPLE 3. Logistic regression
fit <- glm(sent ~ ztrust + zfWHR + zAfro + glasses + attract + maturity +
   tattoos, family = binomial(), data = wilson)
BF1 <- BF(fit, hypothesis = "ztrust > zfWHR > 0;
                             ztrust > 0 & zfWHR = 0")
summary(BF1)

# EXAMPLE 4. Correlation analysis
set.seed(123)
cor1 <- cor_test(memory[1:20,1:3])
BF1 <- BF(cor1)
summary(BF1)
BF2 <- BF(cor1, hypothesis = "Wmn_with_Im > Wmn_with_Del > 0;
                              Wmn_with_Im = Wmn_with_Del = 0")
summary(BF2)

## End(Not run)

Actors from a small hypothetical network

Description

The related data files 'events', 'same_location', 'same_culture' contain information on the event sequence and the two event statistics respectively.

Usage

data(actors)

Format

dataframe (25 rows, 4 columns)

actors$id integer ID of the employee, corresponding to the sender and receiver IDs in the events dataframe
actors$location numeric Location of the actor, ranging from 1-4
actors$culture character Categorical variable, indicating the culture of the employee

Multiple Sources of Attentional Dysfunction in Adults With Tourette's Syndrome

Description

Data from a psychological study comparing attentional performances of Tourette's syndrome (TS) patients, ADHD patients, and controls. These data were simulated using the sufficient statistics from Silverstein, Como, Palumbo, West, and Osborn (1995).

Usage

data(attention)

Format

A data.frame with 51 rows and 2 columns.

Details

accuracy numeric Participant's accuracy in the attentional task
group factor Participant's group membership (TS patient, ADHD patient, or control)

References

Silverstein, S. M., Como, P. G., Palumbo, D. R., West, L. L., & Osborn, L. M. (1995). Multiple sources of attentional dysfunction in adults with Tourette's syndrome: Comparison with attention deficit-hyperactivity disorder. Neuropsychology, 9(2), 157-164. doi:10.1037/0894-4105.9.2.157


Bartlett Test of Homogeneity of Variances

Description

Performs Bartlett's test of the null that the variances in each of the groups (samples) are the same.

Usage

bartlett_test(x, g, ...)

## Default S3 method:
bartlett_test(x, g, ...)

Arguments

x

a numeric vector of data values, or a list of numeric data vectors representing the respective samples, or fitted linear model objects (inheriting from class "lm").

g

a vector or factor object giving the group for the corresponding elements of x. Ignored if x is a list.

...

further arguments to be passed to or from methods.

Details

x must be a numeric data vector, and g must be a vector or factor object of the same length as x giving the group for the corresponding elements of x.

Value

A list with class "bartlett_htest" containing the following components:

statistic

Bartlett's K-squared test statistic.

parameter

the degrees of freedom of the approximate chi-squared distribution of the test statistic.

p.value

the p-value of the test.

conf.int

a confidence interval for the mean appropriate to the specified alternative hypothesis.

method

the character string "Bartlett test of homogeneity of variances".

data.name

a character string giving the names of the data.

vars

the sample variances across groups (samples).

n

the number of observations per group (sample)

Bain t_test

In order to allow users to enjoy the functionality of bain with the familiar stats-function bartlett.test, we have had to make minor changes to the function bartlett.test.default. All rights to, and credit for, the function bartlett.test.default belong to the R Core Team, as indicated in the original license below. We make no claims to copyright and incur no liability with regard to the changes implemented in bartlett_test.

This the original copyright notice by the R core team: File src/library/stats/R/bartlett_test.R Part of the R package, https://www.R-project.org

Copyright (C) 1995-2015 The R Core Team

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

A copy of the GNU General Public License is available at https://www.R-project.org/Licenses/

References

Bartlett, M. S. (1937). Properties of sufficiency and statistical tests. Proceedings of the Royal Society of London Series A 160, 268–282. DOI: 10.1098/rspa.1937.0109.

Examples

require(graphics)

plot(count ~ spray, data = InsectSprays)
bartlett_test(InsectSprays$count, InsectSprays$spray)

Bayes factors for Bayesian exploratory and confirmatory hypothesis testing

Description

The BF function can be used for hypothesis testing and model selection using the Bayes factor. By default exploratory hypothesis tests are performed of whether each model parameter equals zero, is negative, or is positive. Confirmatory hypothesis tests can be executed by specifying hypotheses with equality and/or order constraints on the parameters of interest. Depending on the class of the fitted model different Bayes factors are used as described in the output.

Usage

## Default S3 method:
BF(
  x,
  hypothesis = NULL,
  prior.hyp.explo = NULL,
  prior.hyp.conf = NULL,
  prior.hyp = NULL,
  complement = TRUE,
  log = FALSE,
  Sigma,
  n,
  ...
)

## S3 method for class 'lm'
BF(
  x,
  hypothesis = NULL,
  prior.hyp.explo = NULL,
  prior.hyp.conf = NULL,
  prior.hyp = NULL,
  complement = TRUE,
  log = FALSE,
  BF.type = 2,
  iter = 10000,
  ...
)

## S3 method for class 't_test'
BF(
  x,
  hypothesis = NULL,
  prior.hyp.explo = NULL,
  prior.hyp.conf = NULL,
  prior.hyp = NULL,
  complement = TRUE,
  log = FALSE,
  BF.type = 2,
  iter = 1e+06,
  ...
)

Arguments

x

An R object containing the outcome of a statistical analysis. An R object containing the outcome of a statistical analysis. Currently, the following objects can be processed: t_test(), bartlett_test(), lm(), aov(), manova(), cor_test(), lmer() (only for testing random intercep variances), glm(), coxph(), survreg(), polr(), zeroinfl(), rma(), ergm(), bergm(), or named vector objects. In the case x is a named vector, the arguments Sigma and n are also needed. See vignettes for elaborations.

hypothesis

A character string containing the constrained (informative) hypotheses to evaluate in a confirmatory test. The default is NULL, which will result in standard exploratory testing under the model x.

prior.hyp.explo

The prior probabilities of the hypotheses in the exploratory tests. Except for objects of class aov (for (M)ANOVA, etc.), this argument should be a vector with three elements reflecting the prior probability of a zero effect, a negative effect, and a positive effect, respectively. For objects of class aov, the argument should be a list where the first element should be a vector of length 3 specifying the prior probabilities of each parameter being zero, negative, or positive, the second element should be a vector of length 2 specifying the prior probabilities of a model where is no main effect for a factor and the full model, and the third element should be a vector of length 2 specifying the prior probabilities of a model where is no interaction effect (if present) for two factors and the full model. The default (NULL) specifies equal prior probabilities for each hypothesis per exploratory test.

prior.hyp.conf

The prior probabilities of the constrained hypotheses in the confirmatory test.

prior.hyp

Deprecated. Please use the argument prior.hyp.conf.

complement

a logical specifying whether the complement should be added to the tested hypothesis under hypothesis.

log

a logical specifying whether the Bayes factors should be computed on a log scale. Default is FALSE.

Sigma

An approximate posterior covariance matrix (e.g,. error covariance matrix) of the parameters of interest. This argument is only required when x is a named vector.

n

The (effective) sample size that was used to acquire the estimates in the named vector x and the error covariance matrix Sigma. This argument is only required when x is a named vector.

...

Parameters passed to and from other functions.

BF.type

An integer that specified the type of Bayes factor (or prior) that is used for the test. Currently, this argument is only used for models of class 'lm' and 't_test', where BF.type=2 implies an adjusted fractional Bayes factor with a 'fractional prior mean' at the null value (Mulder, 2014), and BF.type=1 implies a regular fractional Bayes factor (based on O'Hagan (1995)) with a 'fractional prior mean' at the MLE.

iter

Number of iterations that are used to compute the Monte Carlo estimates (only used for certain hypotheses under multivariate models and when testing group variances).

Details

The function requires a fitted modeling object. Current analyses that are supported: t_test, bartlett_test, aov, manova, lm, mlm, glm, hetcor, lmer, coxph, survreg, ergm, bergm, zeroinfl, rma and polr.

For testing parameters from the results of t_test(), lm(), aov(), manova(), and bartlett_test(), hypothesis testing is done using adjusted fractional Bayes factors are computed (using minimal fractions). For testing measures of association (e.g., correlations) via cor_test(), Bayes factors are computed using joint uniform priors under the correlation matrices. For testing intraclass correlations (random intercept variances) via lmer(), Bayes factors are computed using uniform priors for the intraclass correlations. For all other tests, approximate adjusted fractional Bayes factors (with minimal fractions) are computed using Gaussian approximations, similar as a classical Wald test.

Value

The output is an object of class BF. The object has elements:

  • BFtu_exploratory: The Bayes factors of the constrained hypotheses against the unconstrained hypothesis in the exploratory test.

  • BFtu_main (only for aov objects with predictors of class factor): The Bayes factors of a constrained model where all levels of a factor are assumed to have the same effect on the outcome variable versus an unconstrained (full) model with no constraints.

  • BFtu_interaction (only for aov objects with interaction effects with predictors of class factor): The Bayes factors of a constrained model where the effect of the dummy variables corresponding to an interaction effects are assumed to be zero versus an unconstrained (full) model with no constraints.

  • PHP_exploratory: The posterior probabilities of the constrained hypotheses in the exploratory test.

  • PHP_main (only for aov objects with predictors of class factor): The posterior probabilities a constrained model where all levels of a factor are assumed to have the same effect on the outcome variable versus an unconstrained (full) model with no constraints.

  • PHP_interaction (only for aov objects with interaction effects with predictors of class factor): The posterior probabilities of a constrained model where the effect of the dummy variables corresponding to an interaction effects are assumed to be zero versus an unconstrained (full) model with no constraints.

  • BFtu_confirmatory: The Bayes factors of the constrained hypotheses against the unconstrained hypothesis in the confirmatory test using the hypothesis argument.

  • PHP_confirmatory: The posterior probabilities of the constrained hypotheses in the confirmatory test using the hypothesis argument.

  • BFmatrix_confirmatory: The evidence matrix which contains the Bayes factors between all possible pairs of hypotheses in the confirmatory test.

  • BFtable_confirmatory: The Specification table (output when printing the summary of a BF for a confirmatory test) which contains the different elements of the extended Savage Dickey density ratio where

    • The first column 'complex=' quantifies the relative complexity of the equality constraints of a hypothesis (the prior density at the equality constraints in the extended Savage Dickey density ratio).

    • The second column 'complex>' quantifies the relative complexity of the order constraints of a hypothesis (the prior probability of the order constraints in the extended Savage Dickey density ratio).

    • The third column 'fit=' quantifies the relative fit of the equality constraints of a hypothesis (the posterior density at the equality constraints in the extended Savage Dickey density ratio).

    • The fourth column 'fit>' quantifies the relative fit of the order constraints of a hypothesis (the posterior probability of the order constraints in the extended Savage Dickey density ratio)

    • The fifth column 'BF=' contains the Bayes factor of the equality constraints against the unconstrained hypothesis.

    • The sixth column 'BF>' contains the Bayes factor of the order constraints against the unconstrained hypothesis.

    • The seventh column 'BF' contains the Bayes factor of the constrained hypothesis against the unconstrained hypothesis.

    • The eighth column 'PHP' contains the posterior probabilities of the hypotheses.

  • prior.hyp.explo: The prior probabilities of the constrained hypotheses in the exploratory tests.

  • prior.hyp.conf: The prior probabilities of the constrained hypotheses in the confirmatory test.

  • hypotheses: The tested constrained hypotheses in a confirmatory test.

  • estimates: The unconstrained estimates.

  • model: The input model x.

  • bayesfactor: The type of Bayes factor that is used for this model.

  • parameter: The type of parameter that is tested.

  • log: logical whether the Bayes factors were reported on a log scale.

  • fraction_number_groupIDs (only for objects of class lm): The number of 'group identifiers' that were identified based on the number of unique combinations of levels of predictor variables of class factor in the data. These group identifiers are used to automatically specify the minimal fractions that are used to compute (adjusted) fractional Bayes factors.

  • fraction_groupID_observations (only for objects of class lm): A vector that specifies to which 'group identifier' an observation belongs. The group identifiers are constructed based on the unique combination of the levels based on the predictor variables of class factor of the observations.

  • call: The call of the BF function.

Methods (by class)

  • BF(default): S3 method for a named vector 'x'

  • BF(lm): S3 method for an object of class 'lm'

  • BF(t_test): BF S3 method for an object of class 't_test'

References

Mulder, J., D.R. Williams, Gu, X., A. Tomarken, F. Böing-Messing, J.A.O.C. Olsson-Collentine, Marlyne Meyerink, J. Menke, J.-P. Fox, Y. Rosseel, E.J. Wagenmakers, H. Hoijtink., and van Lissa, C. (2021). BFpack: Flexible Bayes Factor Testing of Scientific Theories in R. Journal of Statistical Software. <https://doi.org/10.18637/jss.v100.i18>

Examples

# EXAMPLE 1. One-sample t test
ttest1 <- t_test(therapeutic, mu = 5)
print(ttest1)
# confirmatory Bayesian one sample t test
BF1 <- BF(ttest1, hypothesis = "mu = 5")
summary(BF1)
# exploratory Bayesian one sample t test
BF(ttest1)

# EXAMPLE 2. ANOVA
aov1 <- aov(price ~ anchor * motivation,data = tvprices)
BF1 <- BF(aov1, hypothesis = "anchorrounded = motivationlow;
                              anchorrounded < motivationlow")
summary(BF1)

# EXAMPLE 3. linear regression
lm1 <- lm(mpg ~ cyl + hp + wt, data = mtcars)
BF(lm1, hypothesis = "wt < cyl < hp = 0")

# EXAMPLE 4. Logistic regression
fit <- glm(sent ~ ztrust + zfWHR + zAfro + glasses + attract + maturity +
   tattoos, family = binomial(), data = wilson)
BF1 <- BF(fit, hypothesis = "ztrust > zfWHR > 0;
                             ztrust > 0 & zfWHR = 0")
summary(BF1)

# EXAMPLE 5. Correlation analysis
set.seed(123)
cor1 <- cor_test(memory[1:20,c(1,2,6)])
BF1 <- BF(cor1)
summary(BF1)
BF2 <- BF(cor1, hypothesis = "Rat_with_Im > Rat_with_Del > 0;
                             Rat_with_Im = Rat_with_Del = 0")
summary(BF2)
# correlations can also be computed between continuous/ordinal variables
memory_test <- memory[1:20,c(1,2,6)]
memory_test[,3] <- as.ordered(memory_test[,3])
cor2 <- cor_test(memory_test)
BF(cor2)

# EXAMPLE 6. Bayes factor testing on a named vector
# A Poisson regression model is used to illustrate the computation
# of Bayes factors with a named vector as input
poisson1 <- glm(formula = breaks ~ wool + tension,
  data = datasets::warpbreaks, family = poisson)
# extract estimates, error covariance matrix, and sample size:
estimates <- poisson1$coefficients
covmatrix <- vcov(poisson1)
samplesize <- nobs(poisson1)
# compute Bayes factors on equal/order constrained hypotheses on coefficients
BF1 <- BF(estimates, Sigma = covmatrix, n = samplesize, hypothesis =
"woolB > tensionM > tensionH; woolB = tensionM = tensionH")
summary(BF1)

Bayesian correlation analysis

Description

Estimate the unconstrained posterior for the correlations using a joint uniform prior.

Usage

cor_test(..., formula = NULL, iter = 5000, burnin = 3000, nugget.scale = 0.995)

Arguments

...

matrices (or data frames) of dimensions n (observations) by p (variables) for different groups (in case of multiple matrices or data frames).

formula

an object of class formula. This allows for including control variables in the model (e.g., ~ education).

iter

number of iterations from posterior (default is 5000).

burnin

number of iterations for burnin (default is 3000).

nugget.scale

a scalar which serves to avoid violations of positive definite correlation matrices. It should be very close to 1 (the default is .995).

Value

list of class cor_test:

  • meanF posterior means of Fisher transform correlations

  • covmF posterior covariance matrix of Fisher transformed correlations

  • correstimates posterior estimates of correlation coefficients

  • corrdraws list of posterior draws of correlation matrices per group

  • corrnames names of all correlations

Examples

# Bayesian correlation analysis of the 6 variables in 'memory' object
# we consider a correlation analysis of the first three variable of the memory data.
#fit <- cor_test(BFpack::memory[,1:3])

# Bayesian correlation of variables in memory object in BFpack while controlling
# for the Cat variable
#fit <- cor_test(BFpack::memory[,c(1:4)],formula = ~ Cat)

# Example of Bayesian estimation of polyserial correlations
#memory_example <- memory[,c("Im","Rat")]
#memory_example$Rat <- as.ordered(memory_example$Rat)
#fit <- cor_test(memory_example)

# Bayesian correlation analysis of first three variables in memory data
# for two different groups
#HC <- subset(BFpack::memory[,c(1:3,7)], Group == "HC")[,-4]
#SZ <- subset(BFpack::memory[,c(1:3,7)], Group == "SZ")[,-4]
#fit <- cor_test(HC,SZ)

Student t approximations of Fisher transformed correlations

Description

Approximated degrees of freedom and approximated scale of the Fisher transformed correlations depending on the dimension of the vector of dependent variables P based on a joint uniform prior.

Usage

data(Fcor)

Format

A data.frame with 3 columns.

Details

nu numeric Approximated degrees of freedom
sigma numeric Approximated scale
P integer Dimension of vector of dependent variables

fMRI data

Description

fMRI data assessing relation between individual differences in the ability to recognize faces and cars and thickness of the superficial, middle, and deep layers of the fusiform face area, as assessed by high-resolution fMRI recognition (Williams et al, 2019, under review)

Usage

data(fmri)

Format

A data.frame with 13 rows and 6 columns.

Details

Subject numeric Particicpant ID number
Face numeric Standardized score on face recognition battery
Vehicle numeric Standardized score on vehicle recognition battery
Superficial numeric Depth in mm of superficial layer of FFA
Middle numeric Depth in mm of middle layer of FFA
Bform numeric Depth in mm of deep layer of FFA

References

McGuigin, R.W., Newton, A.T., Tamber-Rosenau, B., Tomarken, A.J, & Gauthier, I. (under review). Thickness of deep layers in the fusiform face area predicts face recognition.


Memory data on health and schizophrenic patients

Description

Data set from study assessing differences between schizophrenic patients and healthy control participants in patterns of correlations among 6 verbal memory tasks (Ichinose et al., 2019).

Im numeric Percent correct on immediate recall of 3 word lists
Del numeric Percent correct on delayed recall of 3 word lists
Wmn numeric Number correct on letter-number span test of auditory working memory
Cat numeric Number correct on category fluency task
Fas numeric Number correct on letter fluency task
Rat numeric Number correct on remote associates task
Group factor Participant Group (HC = Healthy Control; SZ = Schizophrenia)

Usage

data(memory)

Format

A data.frame with 40 rows and 8 columns.

References

Ichinose, M.C., Han, G., Polyn, S., Park, S., & Tomarken, A.J. (2019). Verbal memory performance discordance in schizophrenia: A reflection of cognitive dysconnectivity. Unpublished manuscript.


Multivariate Student t test

Description

First step to performs a Bayesian multivariate one sample Student t test using the (adjusted) fractional Bayes factor using the BF() function.

Usage

mvt_test(X, Y, null = NULL, paired = FALSE, ...)

Arguments

X

a data matrix with the variables in the columns.

Y

an optional data matrix with the variables in the columns.

null

a vector of the null values of the variables.

paired

a logical indicating whether you want a multivariate paired t-test.

...

further arguments to be passed to or from methods.

Details

X must be a data matrix and null must be a vector of the assumed null values of the variables.

Value

An object that can be applied to the BF().

References

Mulder, J. and Gu, X. (2023). Bayesian Testing of Scientific Expectations under Multivariate Normal Linear Models. Multivariate Behavioral Research, 57, 767-783. DOI: 10.1080/00273171.2021.1904809.

Examples

mvt_fmri <- mvt_test(fmri[,1:2],null = c(0,0))
BF(mvt_fmri)

# the same test can be executed via the lm() function
intercept <- rep(1,nrow(fmri))
lm1 <- lm(cbind(Face,Vehicle) ~ -1 + intercept, data=fmri)
BF(lm1,hypothesis="intercept_on_Face=intercept_on_Vehicle=0")

A sequence of innovation-related e-mail messages

Description

A time-ordered sequence of 247 communication messages between 25 actors.

Usage

data(relevents)

Format

dataframe (247 rows, 3 columns)

relevents$time numeric Time of the e-mail message, in seconds since onset of the observation
relevents$sender integer ID of the sender, corresponding to the employee IDs in the actors dataframe
relevents$receiver integer ID of the receiver

Details

The related data files 'actors', 'same_location', 'same_culture' contain information on the actors and three event statistics respectively.


Same culture event statistic

Description

A matrix coding whether senders of events (in the rows) and receivers of events (in the column) have the background culture. Related to the 'events' data object, that contains a relational event sequence, and the 'actors' object, that contains information on the 25 actors involved in the relational event sequence.

Usage

data(same_culture)

Format

dataframe (25 rows, 4 columns)

same_culture integer Event statistic. Matrix with senders in the rows and receivers in the columns. The event statistic is 1 if sender and receiver have the same culture and 0 otherwise.

Same location event statistic

Description

A matrix coding whether senders of events (in the rows) and receivers of events (in the column) have the same location. Related to the 'events' data object, that contains a relational event sequence, and the 'actors' object, that contains information on the 25 actors involved in the relational event sequence.

Usage

data(same_location)

Format

dataframe (25 rows, 4 columns)

same_location integer Event statistic. Matrix with senders in the rows and receivers in the columns. The event statistic is 1 if sender and receiver have the same location and 0 otherwise.

Wason task performance and morality

Description

Data from an experimental study, using the Wason selection task (Wason 1968) to examine whether humans have cognitive adaptations for detecting violations of rules in multiple moral domains. Moral domains are operationalized in terms of the five domains of the Moral Foundations Questionnaire (Graham et al. 2011). These data were simulated using the R-package synthpop, based on the characteristics of the original data.

Usage

data(sivan)

Format

A data.frame with 887 rows and 12 columns.

Details

sex factor Participant sex
age integer Participant age
nationality factor Participant nationality
politics integer How would you define your political opinions? Likert type scale, from 1 (Liberal) to 6 (Conservative)
WasonOrder factor Was the Wason task presented before, or after the MFQ?
Harm numeric MFQ harm domain.
Fairness numeric MFQ fairness domain.
Loyalty numeric MFQ loyalty domain.
Purity numeric MFQ purity domain.
Tasktype ordered How was the Wason task framed?
GotRight factor Did the participant give the correct answer to the Wason task?

References

Sivan, J., Curry, O. S., & Van Lissa, C. J. (2018). Excavating the Foundations: Cognitive Adaptations for Multiple Moral Domains. Evolutionary Psychological Science, 4(4), 408–419. doi:10.1007/s40806-018-0154-8


Trends in International Mathematics and Science Study (TIMSS) 2011-2015

Description

A stratified sample was drawn by country and school to obtain a balanced sample of p = 15 grade-4 students per school for each of four countries (The Netherlands (NL), Croatia (HR), Germany (DE), and Denmark (DK)) and two measurement occasions (2011, 2015). Achievement scores (first plausible value) of overall mathematics were considered. Performances of fourth and eight graders from more than 50 participating countries around the world can be found at (https://www.iea.nl/timss) The TIMSS achievement scale is centered at 500 and the standard deviation is equal to 100 scale score points. The TIMSS data set has a three-level structure, where students are nested within classrooms/schools, and the classrooms/schools are nested within countries. Only one classroom was sampled per school. Changes in the mathematics achievement can be investigated by examining the grouping of students in schools across countries. Changes in country-specific intraclass correlation coefficient from 2011 to 2015, representing heterogeneity in mathematic achievements within and between schools across years, can be tested. When detecting a decrease in average performance together with an increase of the intraclass correlation, a subset of schools performed worse. For a constant intraclass correlation across years the drop in performance applied to the entire population of schools. For different countries, changes in the intraclass correlation across years can be tested concurrently to examine also differences across countries.

Usage

data(timssICC)

Format

A data.frame with 16770 rows and 15 columns.

Details

math numeric math score child
groupNL11 numeric Indicator for child from NL in 2011
groupNL15 numeric Indicator for child from NL in 2015
groupHR11 numeric Indicator for child from HR in 2011
groupHR15 numeric Indicator for child from HR in 2015
groupDE11 numeric Indicator for child from DE in 2011
groupDE15 numeric Indicator for child from DE in 2015
groupDR11 numeric Indicator for child from DK in 2011
groupDR15 numeric Indicator for child from DK in 2015
gender numeric Female=0,Male=1
weight numeric Child sampling weight
yeargender numeric Interaction for occassion and gender
lln numeric total number of children in school-class
groupschool factor Nested indicator for school in country
schoolID factor Unique indicator for school

References

Mulder, J. & Fox, J.-P. (2019). Bayes factor testing of multiple intraclass correlations. Bayesian Analysis. 14, 2, p. 521-552.


Precision of the Anchor Influences the Amount of Adjustment

Description

Data from an experimental study where participants have to guess the price of a plasma tv. There were two experimental conditions. These data were simulated using the sufficient statistics from Janiszewski & Uy (2008).

Usage

data(tvprices)

Format

A data.frame with 59 rows and 3 columns.

Details

price numeric Participant z-scores of price
anchor factor Participant anchor
motivation factor motivation to change

References

Janiszewski, C., & Uy, D. (2008). Precision of the anchor influences the amount of adjustment. Psychological Science, 19(2), 121–127. doi:10.1111/j.1467-9280.2008.02057.x


Facial trustworthiness and criminal sentencing

Description

Data from a correlational study in which the correlation between ratings of facial trustworthiness of inmates was correlated with whether they had received the death penalty or not (wilson and Rule, 2015). These data were simulated using the R-package synthpop, based on the characteristics of the original data.

Usage

data(wilson)

Format

A data.frame with 742 rows and 13 columns.

Details

stim integer Stimulus Number
sent integer Sentence: 1 = Death, 0 = Life
race integer Race: 1 = White, -1 = Black
glasses integer Glasses: 1 = Yes, 0 = No
tattoos integer Tattoos: 1 = Yes, 0 = No
ztrust numeric Trustworthiness
trust_2nd numeric Trustworthiness ratings with 2nd control group; Death targets are same as in primary analysis, Life targets are different.
afro numeric raw Afrocentricity ratings.
zAfro numeric Afrocentricity ratings normalized within target race. Analyses in paper were done with this variable.
attract numeric Attractiveness
fWHR numeric facial width-to-height
afWHR numeric fWHR normalized within target race. Analyses in paper were done with this variable
maturity numeric Maturity

References

Wilson, J. P., & Rule, N. O. (2015). Facial Trustworthiness Predicts Extreme Criminal-Sentencing Outcomes. Psychological Science, 26(8), 1325–1331. doi: 10.1177/0956797615590992