citestR is a lightweight R client for the citest Python package.
It lets you run the conditional-independence-of-missingness test without
using reticulate at runtime — all communication happens
over a local HTTP connection to a FastAPI server that wraps the Python
package.
If you don’t already have a Python environment with
citest installed, the package provides a helper:
library(citestR)
# Creates a virtualenv called "citest_env" and installs the citest API backend
install_backend(method = "pip")You only need to do this once.
library(citestR)
# Example data frame with some missing values
set.seed(42)
n <- 500
df <- data.frame(
Y = rnorm(n),
X1 = rnorm(n),
X2 = rnorm(n),
X3 = rnorm(n)
)
# Introduce MAR missingness on X2
df$X2[df$X1 > 0.5] <- NA
# Run the CI test (server starts automatically)
result <- ci_test(
data = df,
y = "Y",
imputer = "iterative",
classifier = "rf",
m = 5L,
n_folds = 5L
)
result$resultsThe first call starts the Python server in the background; subsequent calls reuse the running process.