Residualizes X and Y on the conditioning variables with linear regression, then tests the mean of the product of the residuals with a studentised z statistic. Only continuous columns are supported: a factor column raises a "wrong column kind" error. Degenerate inputs raise errors rather than 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.

gcm(data)

Arguments

data

A dataset() result or a data.frame.

Value

A fastcit_test bound to data.

Examples

set.seed(1)
df <- data.frame(Z = rnorm(100))
df$X <- df$Z + rnorm(100)
df$Y <- df$Z + rnorm(100)
run_test(gcm(df), "X", "Y", "Z")
#> $statistic
#> [1] -0.539759
#> 
#> $p_value
#> [1] 0.5893633
#> 
#> $dof
#> NULL
#> 
#> $effect_size
#> [1] 0.04952633
#>