Residualizes X and Y on the conditioning variables with linear regression (pgmpy's Pillai default is a random forest) and computes the Pillai trace from the exact canonical correlations of the residuals. Conditioning variables are one-hot encoded minus one level. A categorical X or Y becomes K - 1 level indicators, residualized with a linear probability model. Factor and numeric columns may be mixed. Degenerate inputs raise errors instead of returning NaN. Conditioning sets whose columns are linearly dependent (duplicate or nested categorical variables, a constant column) raise a degenerate-data error, whereas pgmpy fits them by least squares. When Z is not empty and n - columns == max(p, q), the residuals force V = s and the test returns p = 0 ("dependent"), as pgmpy does. When n - columns < max(p, q), the test raises an error.

pillai(data)

Arguments

data

A dataset() result or a data.frame.

Value

A fastcit_test bound to data.

Examples

set.seed(1)
df <- data.frame(
  X = factor(sample(c("a", "b", "c"), 100, TRUE)),
  Y = rnorm(100),
  Z = rnorm(100)
)
run_test(pillai(df), "X", "Y", "Z")
#> $statistic
#> [1] 0.002901045
#> 
#> $p_value
#> [1] 0.8685717
#> 
#> $dof
#> NULL
#> 
#> $effect_size
#> [1] 0.002901045
#>