View source: R/entropy_trivar.R
| entropy_trivar | R Documentation |
Computes trivariate entropies of all triples of discrete variables in a multivariate data set.
entropy_trivar(dat)
dat |
dataframe with rows as observations and columns as variables. Variables must all be observed or transformed categorical with finite range spaces. |
Trivariate entropies can be used to check for functional relationships and stochastic independence between triples of variables.
The trivariate entropy H(X,Y,Z) of three discrete random variables X, Y, and Z is bounded according to
H(X,Y) <= H(X,Y,Z) <= H(X,Z) + H(Y,Z) - H(Z).
The increment between the trivariate entropy and its lower bound is equal to the expected conditional entropy.
Dataframe with the first three columns representing possible triples
of variables (X, Y, Z) and the fourth column giving
trivariate entropies H(X,Y,Z).
Termeh Shafie
Frank, O., & Shafie, T. (2016). Multivariate entropy analysis of network data. Bulletin of Sociological Methodology/Bulletin de Méthodologie Sociologique, 129(1), 45-63.
entropy_bivar, prediction_power
# use internal data set
data(lawdata)
df_att <- lawdata[[4]]
# data editing:
# 1. categorize variables 'years' and 'age' into approximately
# equally sized groups
# 2. recode selected variables so categories start at 0
att_var <- data.frame(
status = df_att$status - 1,
gender = df_att$gender,
office = df_att$office - 1,
years = ifelse(df_att$years <= 3, 0,
ifelse(df_att$years <= 13, 1, 2)),
age = ifelse(df_att$age <= 35, 0,
ifelse(df_att$age <= 45, 1, 2)),
practice = df_att$practice,
lawschool = df_att$lawschool - 1
)
# calculate trivariate entropies
h_trivar <- entropy_trivar(att_var)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.