Learn R Programming

setweaver

setweaver is an R package designed to help users create sets of variables based on a mutual information approach. In this context, a set is a collection of distinct elements (e.g., variables) that can also be treated as a single entity. Mutual information, a concept from probability theory, quantifies the dependence between two variables by expressing how much information about one variable can be gained from observing the other.

Authors

Aaron Fisher
Nicolas Leenaerts

Installation

You can install the released version of setweaver from CRAN with:

install.packages("setweaver")

Or you can install the development version of setweaver from GitHub with the following code snippet:

devtools::install_github('nicolasleenaerts/setweaver')

You can then attach the package as follows:

library(setweaver)

Simple example

Create sets of variables using the pairmi function, which takes a dataframe of variables and pairs them up to a specified maximum number of elements.

# Loading the package, which automatically also downloads the example data (misimdata)
library(setweaver) 

# Pairing variables
results = pairmi(misimdata[,2:11],alpha = 0.05,n_elements = 5)
x1x2x3x4x5x6x7x8x9x10x1_x2x2_x3x3_x4x3_x5x4_x5x5_x6x6_x7x3_x4_x5
100010101000000000
111010101111010000
110010111110000000
101010111000010000
100101111000000010

Table 1. Expanded Data

n_elementssetmirelative.mip
2x1_x20.01483410.00000000.0000972
2x2_x30.01126990.00000000.0008788
2x3_x40.00904650.00000000.0048279
2x3_x50.00318420.00000000.0370173
2x4_x50.01024410.00000000.0020023
2x5_x60.01023470.00000000.0013331
2x6_x70.00527970.00000000.0046674
3x3_x4_x50.01465430.01147010.0142389

Table 2. Information on sets

Once the sets are created with the pairmi function , you can assess their relationship with a specific outcome using the probstat function.

# Evaluating the sets
evaluated_sets = probstat(misimdata$y,results$expanded.data[,results$sets$set],nfolds = 5)
xvarsyprobxprobcprobcprobxcprobicpdifcpdifperxentyentcecedifcedifperORORmargprmse
1x1_x20.30039990.2050.1660.1130.335-0.134-0.4470.7310.8820.8640.0180.0200.3940.46400.00706
6x4_x50.30039990.1860.1930.1200.325-0.107-0.3580.6940.8820.8720.0100.0110.4960.55600.00706
2x2_x30.30039990.1960.2000.1300.325-0.101-0.3360.7150.8820.8730.0090.0100.5200.58200.00706
3x3_x40.30039990.1760.2030.1190.321-0.098-0.3250.6700.8820.8740.0070.0080.5380.59200.00706
5x3_x50.30039990.2730.2270.2060.328-0.074-0.2450.8460.8820.8740.0070.0080.6020.68400.00706

Table 3. Evaluated sets

More information

Consult the vignette for more detailed information!

Copy Link

Version

Install

install.packages('setweaver')

Version

1.0.0

License

CC BY 4.0

Issues

Pull Requests

Stars

Forks

Maintainer

Nicolas Leenaerts

Last Published

February 4th, 2026

Functions in setweaver (1.0.0)

gstat

gstat
entropy

entropy
cprob_inv

cprob_inv
ce

ce
mi

mi
find_minimal_sets

find_minimal_sets
joint

joint
entfuns

entfuns
jtct

jtct
cprob

cprob
plot_prob

plot_prob
prob

prob
probstat

probstat
pairmi

pairmi
misimdata

misimdata
setmapmi

setmapmi
zprob

zprob