ComeçarComece de graça

Visualizing the relationship

Now that we've gone over the effect on certain errors and calculated the necessary sample size for different power values, let's take a step back and look at the relationship between power and sample size with a useful plot.

In this exercise, we'll switch gears and look at a t-test rather than a z-test. In order to visualize this, use the plot_power() function that shows sample size on the x-axis with power on the y-axis and different lines representing different minimum effect sizes.

Este exercício faz parte do curso

Practicing Statistics Interview Questions in Python

Ver curso

Instruções do exercício

  • Assign a TTestIndPower() object to the results variable.
  • Visualize the relationship between power and sample size using the plot_power() function with the appropriate parameter values; what do you notice?

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

sample_sizes = np.array(range(5, 100))
effect_sizes = np.array([0.2, 0.5, 0.8])

# Create results object for t-test analysis
from statsmodels.stats.power import TTestIndPower
results = ____

# Plot the power analysis
results.plot_power(dep_var='nobs', nobs=____, effect_size=____)
plt.show()
Editar e executar o código