  Nonparametric random coefficient (RC)-density estimation has mostly been
considered in the marginal density case under strict independence of RCs and
covariates. This paper deals with the estimation of RC-densities conditional on
a (large-dimensional) set of control variables using machine learning
techniques. The conditional RC-density allows to disentangle observable from
unobservable heterogeneity in partial effects of continuous treatments adding
to a growing literature on heterogeneous effect estimation using machine
learning. %It is also informative of the conditional potential outcome
distribution. This paper proposes a two-stage sieve estimation procedure. First
a closed-form sieve approximation of the conditional RC density is derived
where each sieve coefficient can be expressed as conditional expectation
function varying with controls. Second, sieve coefficients are estimated with
generic machine learning procedures and under appropriate sample splitting
rules. The $L_2$-convergence rate of the conditional RC-density estimator is
derived. The rate is slower by a factor then typical rates of mean regression
machine learning estimators which is due to the ill-posedness of the RC density
estimation problem. The performance and applicability of the estimator is
illustrated using random forest algorithms over a range of Monte Carlo
simulations and with real data from the SOEP-IS. Here behavioral heterogeneity
in an economic experiment on portfolio choice is studied. The method reveals
two types of behavior in the population, one type complying with economic
theory and one not. The assignment to types appears largely based on
unobservables not available in the data.
