Supreme court: Analysis in the original basis

[1]:
# Imports
from mcmpy import Data, MCM, MCMSearch

Initialization

[2]:
# Data object

n = 9   # Number of variables
q = 2   # Number of states
data = Data('../../input/US_SupremeCourt_n9_N895.dat', n, q)

print("The dataset contains %i datapoints, of which %i different ones." %(data.N, data.N_unique))
The dataset contains 895 datapoints, of which 128 different ones.
[3]:
# MCMSearch object
searcher = MCMSearch()

Search for the optimal MCM

[4]:
# The system is small enough to perform an exhaustive search
opt_mcm = searcher.exhaustive(data)
opt_mcm.print_details()
MCM contains 9 variables divided into 2 components
Total log-evidence: -3300.4
Component 0 :   101110100        Size: 5         Log-evidence: -1754.41
Component 1 :   010001011        Size: 4         Log-evidence: -1545.98

Analysis

Log-evidence

[5]:
# Writing the partition as a 1D gray code array
print("The log-evidence of the complete model: ", data.log_evidence([0,0,0,0,0,0,0,0,0]))       # All variables in component 0
print("The log-evidence of the independent model: ", data.log_evidence([0,1,2,3,4,5,6,7,8]))    # All variables in a different component

print("The log-evidence of the optimal MCM: ", data.log_evidence(opt_mcm))
The log-evidence of the complete model:  -3305.546575913696
The log-evidence of the independent model:  -5258.100240438084
The log-evidence of the optimal MCM:  -3300.395469673639

Note that it is advised to used MCM objects as input parameters as there is no check if a given array is a valid partition. The same results can be obtained in the following way:

[6]:
print("The log-evidence of the complete model: ", data.log_evidence(MCM(n, "complete")))
print("The log-evidence of the independent model: ", data.log_evidence(MCM(n, "independent")))

print("The log-evidence of the optimal MCM: ", data.log_evidence(opt_mcm))
The log-evidence of the complete model:  -3305.546575913696
The log-evidence of the independent model:  -5258.100240438084
The log-evidence of the optimal MCM:  -3300.395469673639