  We estimate the density and its derivatives using a local polynomial
approximation to the logarithm of an unknown density $f$. The estimator is
guaranteed to be nonnegative and achieves the same optimal rate of convergence
in the interior as well as the boundary of the support of $f$. The estimator is
therefore well-suited to applications in which nonnegative density estimates
are required, such as in semiparametric maximum likelihood estimation. In
addition, we show that our estimator compares favorably with other kernel-based
methods, both in terms of asymptotic performance and computational ease.
Simulation results confirm that our method can perform similarly in finite
samples to these alternative methods when they are used with optimal inputs,
i.e. an Epanechnikov kernel and optimally chosen bandwidth sequence. Further
simulation evidence demonstrates that, if the researcher modifies the inputs
and chooses a larger bandwidth, our approach can even improve upon these
optimized alternatives, asymptotically. We provide code in several languages.
