src/dlt/power_analysis_utils.py
def gen_pay_ratio(
    number_control_per_week: Union[int, List[int]],
    effect_size: float,
    pay_ratio_lambda=0.5,
    pay_ratio_min=11.50,
    distribution: str = "exponential",
    number_of_weeks: int = 13,
    number_treat_per_week=150,
    seed: Optional[Union[int, np.random.mtrand.RandomState]] = 189389,
) -> Tuple[pd.DataFrame, pd.DataFrame]:
    """
    Generates pay ratio outcomes after RESEA intervention according to a distribution.
    The distribution can be exponential or pareto depending on the user's assumptions
    about the population of individuals eligible for unemployment. Specifically, the
    exponential distribution assumes the majority of individuals are making close to
    minimum wage, while the pareto assumes a heavier tail.

    As everyone is assumed from an initial pay ratio of 0; we only generate the outcome
    ratio.

    Args:
        number_control_per_week: a single number if control does not vary weekly. List of int otherwise
        effect_size: used to define the treatment effect, which modifies the mean of generated data
        pay_ratio_lambda: input for exponential and pareto distribution.
        pay_ratio_min: minimum wage for RI in 2021
        distribution: selection of data generating distribution; either exponential or pareto
        number_of_weeks: how many cohorts we want to generate. Defaults to 13 because we generate data quarterly.
        number_treat_per_week: number of individuals selected for treatment.
            Defaults to 150 based on DLT's experiment design
        seed: seed for randomization

    Returns: treated_df, control_df
    """
    random = _convert_seed_to_randomstate(seed)

    if distribution == "exponential":
        pay_ratio_outcome_value_of_treated = (
            random.exponential(
                pay_ratio_lambda, number_of_weeks * number_treat_per_week
            )
            * (1 - effect_size)
            + 1
        ) * pay_ratio_min
        pay_ratio_outcome_value_of_control = (
            random.exponential(
                pay_ratio_lambda,
                number_of_weeks * number_control_per_week,
            )
            + 1
        ) * pay_ratio_min

    elif distribution == "pareto":
        pay_ratio_outcome_value_of_treated = (
            random.pareto(1 / pay_ratio_lambda, number_of_weeks * number_treat_per_week)
            + 1 * (1 - effect_size)
        ) * pay_ratio_min
        pay_ratio_outcome_value_of_control = (
            random.pareto(
                1 / pay_ratio_lambda,
                number_of_weeks * number_control_per_week,
            )
            + 1
        ) * pay_ratio_min
    else:
        raise ValueError(
            f"distribution must be one of 'pareto' or 'exponential', not {distribution}"
        )

    treated_df = pd.DataFrame({"pay_ratio": pay_ratio_outcome_value_of_treated})
    control_df = pd.DataFrame({"pay_ratio": pay_ratio_outcome_value_of_control})
    return treated_df, control_df

    Generates pay ratio outcomes after RESEA intervention according to a distribution.
    The distribution can be exponential or pareto depending on the user's assumptions
    about the population of individuals eligible for unemployment. Specifically, the
    exponential distribution assumes the majority of individuals are making close to
    minimum wage, while the pareto assumes a heavier tail.

    As everyone is assumed from an initial pay ratio of 0; we only generate the outcome
    ratio.

    Args:
        number_control_per_week: a single number if control does not vary weekly. List of int otherwise
        effect_size: used to define the treatment effect, which modifies the mean of generated data
        pay_ratio_lambda: input for exponential and pareto distribution.
        pay_ratio_min: minimum wage for RI in 2021
        distribution: selection of data generating distribution; either exponential or pareto
        number_of_weeks: how many cohorts we want to generate. Defaults to 13 because we generate data quarterly.
        number_treat_per_week: number of individuals selected for treatment.
            Defaults to 150 based on DLT's experiment design
        seed: seed for randomization

    Returns: treated_df, control_df
    
Generates pay ratio outcomes after RESEA intervention according to a distribution.
The distribution can be exponential or pareto depending on the user's assumptions
about the population of individuals eligible for unemployment. Specifically, the
exponential distribution assumes the majority of individuals are making close to
minimum wage, while the pareto assumes a heavier tail.

As everyone is assumed from an initial pay ratio of 0; we only generate the outcome
ratio.
Generates pay ratio outcomes after RESEA intervention according to a distribution . The distribution can be exponential or pareto depending on the user ' s assumptions about the population of individuals eligible for unemployment . Specifically the exponential distribution assumes the majority of individuals are making close to minimum wage while the pareto assumes a heavier tail . As everyone is assumed from an initial pay ratio of 0 ; we only generate the outcome ratio .
def gen_pay_ratio(
    number_control_per_week: Union[int, List[int]],
    effect_size: float,
    pay_ratio_lambda=0.5,
    pay_ratio_min=11.50,
    distribution: str = "exponential",
    number_of_weeks: int = 13,
    number_treat_per_week=150,
    seed: Optional[Union[int, np.random.mtrand.RandomState]] = 189389,
) -> Tuple[pd.DataFrame, pd.DataFrame]:
    random = _convert_seed_to_randomstate(seed)
    if distribution == "exponential":
        pay_ratio_outcome_value_of_treated = (
            random.exponential(
                pay_ratio_lambda, number_of_weeks * number_treat_per_week
            )
            * (1 - effect_size)
            + 1
        ) * pay_ratio_min
        pay_ratio_outcome_value_of_control = (
            random.exponential(
                pay_ratio_lambda,
                number_of_weeks * number_control_per_week,
            )
            + 1
        ) * pay_ratio_min
    elif distribution == "pareto":
        pay_ratio_outcome_value_of_treated = (
            random.pareto(1 / pay_ratio_lambda, number_of_weeks * number_treat_per_week)
            + 1 * (1 - effect_size)
        ) * pay_ratio_min
        pay_ratio_outcome_value_of_control = (
            random.pareto(
                1 / pay_ratio_lambda,
                number_of_weeks * number_control_per_week,
            )
            + 1
        ) * pay_ratio_min
    else:
        raise ValueError(
            f"distribution must be one of 'pareto' or 'exponential', not {distribution}"
        )
    treated_df = pd.DataFrame({"pay_ratio": pay_ratio_outcome_value_of_treated})
    control_df = pd.DataFrame({"pay_ratio": pay_ratio_outcome_value_of_control})
    return treated_df, control_df
def gen_pay_ratio ( number_control_per_week : Union [ int , List [ int ] ] , effect_size : float , pay_ratio_lambda = 0.5 , pay_ratio_min = 11.50 , distribution : str = "exponential" , number_of_weeks : int = 13 , number_treat_per_week = 150 , seed : Optional [ Union [ int , np . random . mtrand . RandomState ] ] = 189389 , ) -> Tuple [ pd . DataFrame , pd . DataFrame ] : random = _convert_seed_to_randomstate ( seed ) if distribution == "exponential" : pay_ratio_outcome_value_of_treated = ( random . exponential ( pay_ratio_lambda , number_of_weeks * number_treat_per_week ) * ( 1 - effect_size ) + 1 ) * pay_ratio_min pay_ratio_outcome_value_of_control = ( random . exponential ( pay_ratio_lambda , number_of_weeks * number_control_per_week , ) + 1 ) * pay_ratio_min elif distribution == "pareto" : pay_ratio_outcome_value_of_treated = ( random . pareto ( 1 / pay_ratio_lambda , number_of_weeks * number_treat_per_week ) + 1 * ( 1 - effect_size ) ) * pay_ratio_min pay_ratio_outcome_value_of_control = ( random . pareto ( 1 / pay_ratio_lambda , number_of_weeks * number_control_per_week , ) + 1 ) * pay_ratio_min else : raise ValueError ( f"distribution must be one of 'pareto' or 'exponential', not {distribution}" ) treated_df = pd . DataFrame ( { "pay_ratio" : pay_ratio_outcome_value_of_treated } ) control_df = pd . DataFrame ( { "pay_ratio" : pay_ratio_outcome_value_of_control } ) return treated_df , control_df
Generates pay ratio outcomes after RESEA intervention according to a distribution.
Generates pay ratio outcomes after RESEA intervention according to a distribution .
"""
    Generates pay ratio outcomes after RESEA intervention according to a distribution.
    The distribution can be exponential or pareto depending on the user's assumptions
    about the population of individuals eligible for unemployment. Specifically, the
    exponential distribution assumes the majority of individuals are making close to
    minimum wage, while the pareto assumes a heavier tail.

    As everyone is assumed from an initial pay ratio of 0; we only generate the outcome
    ratio.

    Args:
        number_control_per_week: a single number if control does not vary weekly. List of int otherwise
        effect_size: used to define the treatment effect, which modifies the mean of generated data
        pay_ratio_lambda: input for exponential and pareto distribution.
        pay_ratio_min: minimum wage for RI in 2021
        distribution: selection of data generating distribution; either exponential or pareto
        number_of_weeks: how many cohorts we want to generate. Defaults to 13 because we generate data quarterly.
        number_treat_per_week: number of individuals selected for treatment.
            Defaults to 150 based on DLT's experiment design
        seed: seed for randomization

    Returns: treated_df, control_df
    """
number_control_per_week
Union[int, List[int]]
a single number if control does not vary weekly. List of int otherwise
a single number if control does not vary weekly . List of int otherwise
effect_size
float
used to define the treatment effect, which modifies the mean of generated data
used to define the treatment effect which modifies the mean of generated data
pay_ratio_lambda
input for exponential and pareto distribution.
input for exponential and pareto distribution .
pay_ratio_min
minimum wage for RI in 2021
minimum wage for RI in 2021
distribution
str
selection of data generating distribution; either exponential or pareto
selection of data generating distribution ; either exponential or pareto
number_of_weeks
int
None
13 because we generate data quarterly
number_treat_per_week
number of individuals selected for treatment.
Defaults to 150 based on DLT's experiment design
number of individuals selected for treatment . Defaults to 150 based on DLT ' s experiment design
seed
Optional[Union[int, np.random.mtrand.RandomState]]
seed for randomization
seed for randomization