View source: R/BNPPairedSamples.R
BNP.test | R Documentation |
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.
BNP.test(x, y, n.mcm)
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). |
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.
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.
Pereira, L. A., Taylor-Rodriguez, D. & Gutierrez, L. (2020), A Bayesian nonparametric testing procedure for paired samples. Biometrics 76(1), 1-14.
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.