0

Trying to perform power statistics to calculate power and effect size for a one sample two-sided binomial test using stat models. For the Pearson g-o-f test it is working but same for binomial test gives an error (I pasted below). how to solve this error and calculate the power and effect size. with stat models or other package

from statsmodels.stats.power import GofChisquarePower

from statsmodels.stats.proportion import binom_test

obj = binom_test(12,46)

# set the significance level and effect size
alpha = 0.05
effect_size = 0.5

# set the degrees of freedom and the null distribution
df = 5


# create the power calculator
power_calc = GofChisquarePower()

# calculate the sample size required to achieve the desired power
power = 0.8
sample_size = power_calc.solve_power(
    effect_size=effect_size, 
    nobs=None, 
    alpha=alpha, 
    n_bins=df, 
    power=power
)

sample_size = obj.solve_power(
    effect_size=effect_size, 
    nobs=None, 
    alpha=alpha, 
    n_bins=df, 
    power=power
)

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-5-b722917d3e28> in <cell line: 28>()
     26 obj = binom_test(12,46)
     27 
---> 28 sample_size = obj.solve_power(
     29     effect_size=effect_size,
     30     nobs=None,

AttributeError: 'numpy.float64' object has no attribute 'solve_power'
    
    print(f"Sample size: {sample_size}")
pranav nerurkar
  • 596
  • 7
  • 19

0 Answers0