View source: R/PolyaTreeFunctions.R
PolyaTreetest | R Documentation |
Compute a Bayes factor that checks to see if two data sets share the same distribution by Polya Tree
PolyaTreetest(datasetX, datasetY, Ginv = NULL, c = NULL, leveltot = NULL)
datasetX |
A set of data (or in the case of screening a predictor corresponding to one class), one of the data sets we want to check if its distribution is the same as dataset Y's. |
datasetY |
Another set of data (or in the case of screening a predictor corresponding to another class), the other data set we're comparing to datasetX |
Ginv |
A function that can compute quantiles of some distribution. The default is qnorm. Can specify another function, needs to be able to take in a number between 0 and 1 and return back some positive value. It needs to be a quantile function. |
c |
A tuning parameter corresponding to how influential the prior should be. Authors recommend to set to 1. Can change from 1. The larger the tuning parameter the more influential the prior. The smaller the tuning parameter the less influential the prior. |
leveltot |
Total number of levels deep the tree should go. 9 is given as a default. Some authors recommend going to $log_2(sample size)$, but doesn't need to be done. The deeper the tree the more computation that is required. |
Returns a list. The log BF component is a scalar that corresponds to the log BF of the computed test, and a vector which correspons to the contribution of the log BF at each level.
set.seed(100)
dataset1 = rnorm(200)
dataset2 = rnorm(200)
PTtest1 = PolyaTreetest(dataset1, dataset2)
PTtest1$logBF #Gives back the log Bayes factor
PTtest1$logBFcont #Gives back the contributions of the log Bayes factor for different levels of the tree. Summing these gives the log BF.
PTtest2 = PolyaTreetest(dataset1, dataset2, Ginv = qnorm, leveltot = 10) #Can fill in arguments to suit data set, default should be good.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.