Learn R Programming

setweaver (version 1.0.0)

entfuns: entfuns

Description

Computes a set of descriptive diagnostics for a binary outcome `y` against one or more predictors in `x`, including marginal probability, conditional probability, absolute and proportional differences between marginal and conditional probabilities, and analogous measures based on . entropy.

Usage

entfuns(y, x)

Value

A data frame with one row per predictor and the following columns:

xvar

Predictor name.

yprob

Marginal probability \(P(Y=1)\) computed on complete cases for that predictor.

xprob

Marginal probability \(P(X=1)\).

cprob

Conditional probability \(P(Y=1 \mid X=1)\).

cpdif

Absolute difference \(P(Y=1 \mid X=1) - P(Y=1)\).

cpdifper

Percent difference relative to \(P(Y=1)\).

yent

Entropy \(H(Y)\).

ce

Conditional entropy \(H(Y \mid X)\).

cedif

Absolute difference \(H(Y) - H(Y \mid X)\).

cedifper

Percent difference in entropy relative to \(H(Y)\).

Arguments

y

A binary outcome vector (0/1 or logical). Length `n`.

x

A data frame of binary predictors (columns). Must have `n` rows; each column is analyzed separately against `y`.

Details

Inputs are treated as binary (0/1 or logical). Missing values are removed pairwise for each predictor (rows with `NA` in either the outcome or the predictor are excluded for that predictor's calculations).

Examples

Run this code
entfuns(misimdata$y,misimdata[,2:5])

Run the code above in your browser using DataLab