BNP.test: BNP Testing Procedure for Paired Samples function

View source: R/BNPPairedSamples.R

BNP.testR Documentation

BNP Testing Procedure for Paired Samples function

Description

Given two vectors of numerical values, this function returns the result for Bayesian nonparametric hypothesis testing for paired samples proposed by Pereira et al. (2020), performing an analytical and graphical comparison of the marginal distributions of the data set.

Usage

BNP.test(x, y, n.mcm)

Arguments

x

a numeric vector of data values taken prior to measurement.

y

a numeric vector of data values taken post measurement.

n.mcm

the number of simulations for the MCMC in the Gibbs sampling (suggested: 10000).

Value

A list with three items. The first element (sampling.parameters) is a list of the parameters estimated by Gibbs sampling, which are returned as data frames within each of the iterations. The second element (posterior.probability.H1) refers to the posterior probability for the alternative hypothesis, i.e. that differences between the marginal distributions occur. The third element (data.init) refers to the original data set, which will be useful when applying other functions of the package.

Note

For a proper execution of the function it is required that the data vectors have the same length, otherwise the function will return an error message.

References

Pereira, L. A., Taylor-Rodriguez, D. & Gutierrez, L. (2020), A Bayesian nonparametric testing procedure for paired samples. Biometrics 76(1), 1-14.

Examples


## Not run: 
x <- rnorm(30,3,2)
y <- rnorm(30,4,3)
BNP.test(x, y, n.mcm=10000)

y <- matrix(runif(300), ncol = 300)
y <- apply(y, 2, function(i) if (i < 0.5) {
  y <- rmvnorm(1, mean = c(0,-3), sigma = matrix(c(1,0.8,0.8,1),nrow = 2,byrow = T))
}else{
  y <- rmvnorm(1, mean = c(0,3), sigma = matrix(c(1,0.8,0.8,1),nrow = 2,byrow = T))
})
y <- t(y)
x1 <- y[,1]
y1 <- y[,2]
BNP.test(x1, y1, n.mcm=10000)

## End(Not run)


kevortiz10/BNPPairedSamples documentation built on July 21, 2022, 12:42 a.m.