cor_test: Bayesian correlation analysis

View source: R/BF.cortest.R

cor_testR Documentation

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)

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).

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)



jomulder/BFpack documentation built on April 1, 2024, 5:27 a.m.