tests/test_causalEffect.R

library(pcalg)
suppressWarnings(RNGversion("3.5.0"))
set.seed(34)
g <- randomDAG(5,0.8)
trMat <- matrix(0, 5,5)
trMat[1,5] <- 0.305
trMat[1,4] <- 0.863
trMat[1,2] <- 0.354
trMat[2,4] <- 0.392
trMat[2,5] <- 0.495
trMat[3,4] <- 0.278


## eff 1->5: 0.305 + 0.354*0.495
trEff <- 0.305 + 0.354*0.495
estEff <- causalEffect(g, 5,1)

if (!(round(trEff,3) == round(estEff, 3))) {
  stop("Test in wgtMatrix: Weights have wrong value!")
}

Try the pcalg package in your browser

Any scripts or data that you put into this service are public.

pcalg documentation built on May 29, 2024, 5:24 a.m.