############################################################################## # # This file is part of BATMON # # BATMON (BAyes Test for MONotonicity) is a Bayesian Procedure for testing # monotonicity of a regression function. # Copyright (C) 2012 JB Salomond # # 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 3 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. # # You should have received a copy of the GNU General Public License # along with this program. If not, see # ############################################################################## ===================================================================================== GENERAL ============================================================================ ===================================================================================== Bayes Test of monotonicity procedure. This program was put online to illustrate the "Adaptive Bayes Test For Monotonicity article, written by Jean-Bernard Salomond (arxiv ?) This code was used to get the results of the article. Its only purpose was to study the behaviour of our test on simulated/real data. Thus it is most certainly not efficient. I may not provide full support for this code, but feel free to contact me if you have any question. ===================================================================================== REQUIREMENTS ======================================================================= ===================================================================================== The code is written in python, hence you will need python to run it. It also require some other packages : − numpy, scipy usually package as python-numpy and python-scipy. See http://numpy.scipy.org/ − Rpy is require for the graph, but that can easily be disabled. make sure to have all the require packages before running the code. You should have received with this file : - 'entries.py' : a python script that create the dataset from a .txt file and in which one can specify some variables - 'batmon.py' : A python script that runs the test given the variables specified in 'entries.py'. ===================================================================================== RUNNING THE CODE =================================================================== ===================================================================================== You should first launch the program on a "toy example" with the command python batmon.py This will run the test on a test data named "data2.txt" simulated from a model with monotone non increasing regression function. This should take less than a minute. You can easily run the test on your own data. To do so, simply change the path in line 32 of the file 'entries.py' dat = genfromtxt('path-to-your-dataset.txt',delimiter=' ') # the data Note that by default, the code take .txt files, with no header row names. The first column should be the design points (note that this code works for design point sa presented in the article). The second column should be the data points. The delimiter can be specified in the 'genfromtxt' function. Within the 'entries.py' file you can also specify some variable such as : - The number of time you want to re-run the test on your datas (1 by default) with the variable Nech (line 30) - The number of draws from the MCMC sampler to approximate the posterior (10000 by default) with the variable NKsim (line 31). ===================================================================================== OUTPUT ============================================================================= ===================================================================================== The output you get when running the code is of the following form 0.99999 H0 rejected, the function is not monotone The first line gives you the posterior probability of H(omega,k) being greater than the threshold. The second line gives the result of the test. ###################################################### Contact : (JB Salomond) jean.bernard.salomond@ensae.fr JB Salomond PhD Student @ CREST & Université Paris Dauphine supervised by Judith Rousseau ######################################################