riantr/moonbit_dowhy/refuters does not have a README file

    CausalRefutation

    pub struct CausalRefutation {
    estimated_effect : Double
    new_effect : Double
    new_effect_lower : Double
    new_effect_upper : Double
    refutation_type : String
    p_value : Double
    is_significant : Bool
    }

    The result of one refutation.

    CausalRefutation::estimated_effect

    fn CausalRefutation::estimated_effect(self : CausalRefutation) -> Double

    The original estimate.

    CausalRefutation::is_significant

    fn CausalRefutation::is_significant(self : CausalRefutation) -> Bool

    Whether the refutation is statistically significant.

    CausalRefutation::new

    fn CausalRefutation::new(estimated_effect : Double, new_effect : Double, refutation_type : String) -> CausalRefutation

    A refutation without a significance test.

    CausalRefutation::new_effect

    fn CausalRefutation::new_effect(self : CausalRefutation) -> Double

    The estimate after the refutation.

    CausalRefutation::new_effect_lower

    fn CausalRefutation::new_effect_lower(self : CausalRefutation) -> Double

    The lower bound of the refuted estimates.

    CausalRefutation::new_effect_upper

    fn CausalRefutation::new_effect_upper(self : CausalRefutation) -> Double

    The upper bound of the refuted estimates.

    CausalRefutation::p_value

    fn CausalRefutation::p_value(self : CausalRefutation) -> Double

    The p-value of the significance test.

    CausalRefutation::refutation_type

    fn CausalRefutation::refutation_type(self : CausalRefutation) -> String

    The name of the refutation.

    CausalRefutation::to_string

    fn CausalRefutation::to_string(self : CausalRefutation) -> String

    A human readable summary of the refutation.

    PlaceboType

    pub enum PlaceboType {
    RandomData
    Permute
    }

    The kind of placebo the placebo treatment refuter builds.

    PlaceboType::permute

    fn PlaceboType::permute() -> PlaceboType

    The permuted placebo: the rows of the treatment are permuted.

    PlaceboType::random_data

    fn PlaceboType::random_data() -> PlaceboType

    The random data placebo: the treatment is replaced by a random variable.

    RequiredVariables

    pub enum RequiredVariables {
    All
    None
    Count(Int)
    Named(Array[String])
    Others(Array[String])
    }

    The variables the bootstrap refuter perturbs.

    This is the port of the required_variables argument of the upstream: a boolean asks for every variable of interest or for none of them, an integer asks for that many of them and a list names them. The upstream takes the three of them in one argument and raises an error when a list selects and deselects at the same time; the enumeration of the port cannot hold such a list.

    RequiredVariables::all

    Every variable of interest.

    RequiredVariables::count

    fn RequiredVariables::count(count : Int) -> RequiredVariables

    That many variables of interest, chosen at random.

    RequiredVariables::named

    fn RequiredVariables::named(names : Array[String]) -> RequiredVariables

    The named variables of interest.

    RequiredVariables::none

    No variable at all.

    RequiredVariables::others

    fn RequiredVariables::others(names : Array[String]) -> RequiredVariables

    Every variable of interest but the named ones.

    SignificanceTestType

    pub enum SignificanceTestType {
    Auto
    Bootstrap
    Normal
    }

    The kind of test the significance test of a refutation uses.

    SignificanceTestType::auto

    The automatic kind of test.

    SignificanceTestType::bootstrap

    The two sided percentile test of the bootstrap.

    SignificanceTestType::normal

    The test of the normal distribution.

    refute_add_unobserved_common_cause

    fn refute_add_unobserved_common_cause(estimator :
    CausalEstimator
    , estimand :
    IdentifiedEstimand
    , data :
    DataFrame
    , treatment_name : String, outcome_name : String, epsilon : Double, num_simulations : Int, treatment_value : Double, control_value : Double, target_units : String, random :
    Random
    ) -> CausalRefutation

    The unobserved common cause refuter.

    An unobserved confounder is simulated with the strength epsilon and the effect is re-estimated; the refutation reports how much the estimate moves when the confounder is strong.

    refute_bootstrap

    fn refute_bootstrap(estimator :
    CausalEstimator
    , estimand :
    IdentifiedEstimand
    , data :
    DataFrame
    , num_simulations : Int, sample_size_fraction : Double, treatment_value : Double, control_value : Double, target_units : String, random :
    Random
    , required_variables? : RequiredVariables, noise? : Double, probability_of_change? : Double?) -> CausalRefutation

    The bootstrap refuter.

    The data is resampled with replacement and the variables of interest are perturbed with a noise; the effect is re-estimated on every resample and the refutation reports the mean of the resampled estimates and the interval they span.

    The noise of a numeric column has the standard deviation of the given fraction of the standard deviation of the column, the way the upstream perturbs it. A column of zeros and ones is flipped and a discrete column gets another one of its categories, both with the probability of the change, which is the noise unless it is given.

    refute_data_subset

    fn refute_data_subset(estimator :
    CausalEstimator
    , estimand :
    IdentifiedEstimand
    , data :
    DataFrame
    , subset_fraction : Double, num_simulations : Int, treatment_value : Double, control_value : Double, target_units : String, random :
    Random
    ) -> CausalRefutation

    The data subset refuter.

    The effect is re-estimated on random subsets of the data; a robust estimate does not depend on the subset. The subset holds no row twice, the way the upstream samples it.

    refute_dummy_outcome

    fn refute_dummy_outcome(estimator :
    CausalEstimator
    , estimand :
    IdentifiedEstimand
    , data :
    DataFrame
    , outcome_name : String, num_simulations : Int, treatment_value : Double, control_value : Double, target_units : String, random :
    Random
    ) -> CausalRefutation

    The dummy outcome refuter.

    The outcome is replaced by a random variable; the refuted effect must be close to zero.

    refute_placebo_treatment

    fn refute_placebo_treatment(estimator :
    CausalEstimator
    , estimand :
    IdentifiedEstimand
    , data :
    DataFrame
    , treatment_name : String, num_simulations : Int, treatment_value : Double, control_value : Double, target_units : String, random :
    Random
    , placebo_type? : PlaceboType) -> CausalRefutation

    The placebo treatment refuter.

    The treatment is replaced by a placebo variable and the effect is estimated again on every simulation; a causal estimate that survives the refutation is not credible.

    The random data placebo builds the placebo the way the upstream does: a continuous treatment becomes a constant zero, a binary treatment becomes a random draw of a Bernoulli variable with the probability of a half, and a categorical treatment becomes a random draw of one of its categories. The permuted placebo takes the rows of the treatment and permutes them.

    The upstream reports the error it raises for the instrumental variable method with the random data placebo; MoonBit cannot catch an error, so the port aborts with the message of the upstream.

    refute_random_common_cause

    fn refute_random_common_cause(estimator :
    CausalEstimator
    , _estimand :
    IdentifiedEstimand
    , data :
    DataFrame
    , num_simulations : Int, treatment_value : Double, control_value : Double, target_units : String, random :
    Random
    ) -> CausalRefutation

    The random common cause refuter.

    A random variable is added to the adjustment set; a robust estimate does not change.

    test_significance

    fn test_significance(estimate : Double, simulations : Array[Double], test_type? : SignificanceTestType, significance_level? : Double) -> (Double, Bool)

    The p-value of the significance test of a refutation and whether the estimate is significant at the given level.

    This is the port of test_significance of dowhy.causal_refuter: the estimate is tested against the distribution of the estimates the refuter produced. The refutations that sever the causal relation test the zero estimate against it, the ones that leave the relation alone test the estimate of the data against it.

    Source Files

    Powered by MoonBit

    Site sourceReport issueModulesSkillsBuild queueStatistics

    © 2026 mooncakes.io