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.

    ConfoundersEffectOnT

    pub enum ConfoundersEffectOnT {
    BinaryFlip
    Linear
    }

    The kind of effect the simulated confounder has on the treatment.

    ConfoundersEffectOnT::binary_flip

    A flipped value of the treatment.

    ConfoundersEffectOnT::linear

    A linear effect on the treatment.

    ConfoundersEffectOnY

    pub enum ConfoundersEffectOnY {
    BinaryFlip
    Linear
    }

    The kind of effect the simulated confounder has on the outcome.

    ConfoundersEffectOnY::binary_flip

    A flipped value of the outcome.

    ConfoundersEffectOnY::linear

    A linear effect on the outcome.

    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.

    Transformation

    pub enum Transformation {
    Zero
    Noise(Double)
    Permute(Double)
    LinearRegression
    NearestNeighbour(Int)
    Estimate((
    DataFrame
    , Array[Double],
    DataFrame
    ) -> (Array[Double], Array[Double]))
    }

    A transformation of the outcome of the dummy outcome refuter.

    Transformation::estimate

    A transformation that predicts the outcome with the given model.

    Transformation::linear_regression

    fn Transformation::linear_regression() -> Transformation

    A transformation that predicts the outcome with a linear regression.

    Transformation::nearest_neighbour

    fn Transformation::nearest_neighbour(k : Int) -> Transformation

    A transformation that predicts the outcome with the k nearest neighbours.

    Transformation::noise

    fn Transformation::noise(std_dev : Double) -> Transformation

    A transformation that adds a white noise of the given standard deviation.

    Transformation::permute

    fn Transformation::permute(fraction : Double) -> Transformation

    A transformation that permutes the given fraction of the rows.

    Transformation::zero

    A transformation that replaces every value by zero.

    dummy_outcome_default_transformations

    fn dummy_outcome_default_transformations() -> Array[Transformation]

    The transformation list of the upstream when the caller gives none.

    refute_add_unobserved_common_cause

    fn refute_add_unobserved_common_cause(estimator :
    CausalEstimator
    , estimand :
    IdentifiedEstimand
    , data :
    DataFrame
    , treatment_name : String, outcome_name : String, kappa_t : Double, kappa_y : Double, treatment_value : Double, control_value : Double, target_units : String, random :
    Random
    , effect_on_t? : ConfoundersEffectOnT, effect_on_y? : ConfoundersEffectOnY) -> CausalRefutation

    The refuter that adds an unobserved common cause.

    kappa_t is the strength of the confounder on the treatment and kappa_y the strength on the outcome. The simulation is the one of the upstream: a single confounder is drawn and a single refutation is reported, so there is no interval to report besides the refuted effect itself.

    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, treatment_name : String, num_simulations : Int, treatment_value : Double, control_value : Double, target_units : String, random :
    Random
    , required_variables? : RequiredVariables, transformations? : Array[Transformation], min_data_point_threshold? : Int, bucket_size_scale_factor? : Double, test_fraction? : Double, true_causal_effect? : (Array[Double]) -> Array[Double]?) -> Array[CausalRefutation]

    The dummy outcome refuter.

    The estimate of the data is refuted by replacing the outcome with a simulated outcome whose causal effect is true_causal_effect, which is zero when the caller gives no other. The refutations come back with one entry per bucket of the treatment, the way the upstream returns its list.

    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.