src/dlt/power_analysis_utils.py
def gen_employment(
    number_control_per_week: Union[int, List[int]],
    effect_size: float,
    emp_base_rate: float = 0.62,
    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 employment outcomes after RESEA intervention according to a binomial
    distribution using `np.random.binomial`. Input for binomial distribution is
    determined by `effect_size` and `emp_base_rate` variables.

    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
        emp_base_rate: default reemployment rate assuming no RESEA interventionn.
            Defaults to 0.62, which was the reemployment rate at Boston for 2018
            according to https://oui.doleta.gov/unemploy/uir_rates.asp
        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)

    # the amount we expect incrased
    emp_treatment_effect = float(emp_base_rate * (1 + effect_size))

    try:
        emp_outcome_value_of_treated = random.binomial(
            1, emp_treatment_effect, size=number_of_weeks * number_treat_per_week
        )
    except ValueError:
        print(f"error at {emp_treatment_effect}")
    try:
        emp_outcome_value_of_control = random.binomial(
            1,
            emp_base_rate,
            size=number_of_weeks * number_control_per_week,
        )
    except ValueError:
        print(f"error at {emp_base_rate}")

    treated_df = pd.DataFrame({"employment": emp_outcome_value_of_treated})
    control_df = pd.DataFrame({"employment": emp_outcome_value_of_control})
    return treated_df, control_df

    Generates employment outcomes after RESEA intervention according to a binomial
    distribution using `np.random.binomial`. Input for binomial distribution is
    determined by `effect_size` and `emp_base_rate` variables.

    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
        emp_base_rate: default reemployment rate assuming no RESEA interventionn.
            Defaults to 0.62, which was the reemployment rate at Boston for 2018
            according to https://oui.doleta.gov/unemploy/uir_rates.asp
        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 employment outcomes after RESEA intervention according to a binomial
distribution using `np.random.binomial`. Input for binomial distribution is
determined by `effect_size` and `emp_base_rate` variables.
Generates employment outcomes after RESEA intervention according to a binomial distribution using ` np . random . binomial ` . Input for binomial distribution is determined by ` effect_size ` and ` emp_base_rate ` variables .
def gen_employment(
    number_control_per_week: Union[int, List[int]],
    effect_size: float,
    emp_base_rate: float = 0.62,
    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)
    emp_treatment_effect = float(emp_base_rate * (1 + effect_size))
    try:
        emp_outcome_value_of_treated = random.binomial(
            1, emp_treatment_effect, size=number_of_weeks * number_treat_per_week
        )
    except ValueError:
        print(f"error at {emp_treatment_effect}")
    try:
        emp_outcome_value_of_control = random.binomial(
            1,
            emp_base_rate,
            size=number_of_weeks * number_control_per_week,
        )
    except ValueError:
        print(f"error at {emp_base_rate}")
    treated_df = pd.DataFrame({"employment": emp_outcome_value_of_treated})
    control_df = pd.DataFrame({"employment": emp_outcome_value_of_control})
    return treated_df, control_df
def gen_employment ( number_control_per_week : Union [ int , List [ int ] ] , effect_size : float , emp_base_rate : float = 0.62 , 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 ) emp_treatment_effect = float ( emp_base_rate * ( 1 + effect_size ) ) try : emp_outcome_value_of_treated = random . binomial ( 1 , emp_treatment_effect , size = number_of_weeks * number_treat_per_week ) except ValueError : print ( f"error at {emp_treatment_effect}" ) try : emp_outcome_value_of_control = random . binomial ( 1 , emp_base_rate , size = number_of_weeks * number_control_per_week , ) except ValueError : print ( f"error at {emp_base_rate}" ) treated_df = pd . DataFrame ( { "employment" : emp_outcome_value_of_treated } ) control_df = pd . DataFrame ( { "employment" : emp_outcome_value_of_control } ) return treated_df , control_df
Generates employment outcomes after RESEA intervention according to a binomial
distribution using `np.random.binomial`.
Generates employment outcomes after RESEA intervention according to a binomial distribution using ` np . random . binomial ` .
"""
    Generates employment outcomes after RESEA intervention according to a binomial
    distribution using `np.random.binomial`. Input for binomial distribution is
    determined by `effect_size` and `emp_base_rate` variables.

    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
        emp_base_rate: default reemployment rate assuming no RESEA interventionn.
            Defaults to 0.62, which was the reemployment rate at Boston for 2018
            according to https://oui.doleta.gov/unemploy/uir_rates.asp
        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
    """ # the amount we expect incrased
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
emp_base_rate
float
default reemployment rate assuming no RESEA interventionn.
default reemployment rate assuming no RESEA interventionn .
number_of_weeks
int
None
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