With the discovery of a planetary system around the ultracool dwarf TRAPPIST-1, there has been a surge of interest in such stars as potential planet hosts. Planetary systems around ultracool dwarfs represent our best chance of characterising temperate rocky-planet atmospheres with the James Webb Space Telescope. However, TRAPPIST-1 remains the only known system of its kind and the occurrence rate of planets around ultracool dwarfs is still poorly constrained. We seek to perform a complete transit search on the ultracool dwarfs observed by NASA's K2 mission, and use the results to constrain the occurrence rate of planets around these stars. We filter and characterise the sample of ultracool dwarfs observed by K2 by fitting their spectral energy distributions and using parallaxes from Gaia. We build an automatic pipeline to perform photometry, detrend the light curves, and search for transit signals. Using extensive injection-recovery tests of our pipeline, we compute the detection sensitivity of our search, and thus the completeness of our sample. We infer the planetary occurrence rates within a hierarchical Bayesian model (HBM) to treat uncertain planetary parameters.With the occurrence rate parametrised by a step-wise function, we present a convenient way to directly marginalise over the second level of our HBM (the planetary parameters). Our method is applicable generally and can greatly speed up inference with larger catalogues of detected planets. We detect one planet in our sample of 702 ultracool dwarfs: a previously validated mini-Neptune. We thus infer a mini-Neptune (2-4R_{Earth}) occurrence rate of {eta}=0.20^+0.16^_0.11 within orbital periods of 1-20 days. For super-Earths (1-2R_{Earth}) and ice or gas giants (4-6R{Earth}_) within 1-20 days, we place 95% credible intervals of {eta}<1.14 and {eta}<0.29, respectively. If TRAPPIST-1-like systems were ubiquitous, we would have a 96% chance of finding at least one.
Cone search capability for table J/A+A/641/A170/target (All K2 target stars used)