infer_orientation_signs: Infer orientation signs for each observable indicator

View source: R/orientation_helpers.R

infer_orientation_signsR Documentation

Infer orientation signs for each observable indicator

Description

This helper analyzes observable indicators and returns a numeric vector of 1 or -1 for use with the orientation_signs argument in lpmec. Each sign is chosen so that the correlation between the oriented indicator and either the outcome Y or the first principal component of the indicators is positive.

Usage

infer_orientation_signs(Y, observables, method = c("Y", "PC1"))

Arguments

Y

Numeric outcome vector. Only used when method = "Y".

observables

A matrix or data frame of binary observable indicators.

method

Character string specifying how to orient the indicators.

"Y"

orient each indicator so that its correlation with Y is positive.

"PC1"

orient each indicator so that its correlation with the first principal component of observables is positive.

Default is "Y".

Value

A numeric vector of length ncol(observables) containing 1 or -1.

Examples

set.seed(1)
Y <- rnorm(10)
obs <- data.frame(matrix(sample(c(0,1), 20, replace = TRUE), ncol = 2))
infer_orientation_signs(Y, obs)

lpmec documentation built on Feb. 9, 2026, 5:07 p.m.