Get startedGet started for free

Do neonicotinoid insecticides have unintended consequences?

As a final exercise in hypothesis testing before we put everything together in our case study in the next chapter, you will investigate the effects of neonicotinoid insecticides on bee reproduction. These insecticides are very widely used in the United States to combat aphids and other pests that damage plants.

In a recent study, Straub, et al. (Proc. Roy. Soc. B, 2016) investigated the effects of neonicotinoids on the sperm of pollinating bees. In this and the next exercise, you will study how the pesticide treatment affected the count of live sperm per half milliliter of semen.

First, we will do EDA, as usual. Plot ECDFs of the alive sperm count for untreated bees (stored in the NumPy array control) and bees treated with pesticide (stored in the NumPy array treated).

This exercise is part of the course

Statistical Thinking in Python (Part 2)

View Course

Exercise instructions

  • Use your ecdf() function to generate x,y values from the control and treated arrays for plotting the ECDFs.
  • Plot the ECDFs on the same plot.
  • The margins have been set for you, along with the legend and axis labels. Hit submit to see the result!

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Compute x,y values for ECDFs
x_control, y_control = ____
x_treated, y_treated = ____

# Plot the ECDFs
plt.plot(____, ____, marker='.', linestyle='none')
plt.plot(____, ____, marker='.', linestyle='none')

# Set the margins
plt.margins(0.02)

# Add a legend
plt.legend(('control', 'treated'), loc='lower right')

# Label axes and show plot
plt.xlabel('millions of alive sperm per mL')
plt.ylabel('ECDF')
plt.show()
Edit and Run Code