We present a theory that examines the optimal match between firm R&D units
and external partners for projects that involve problem solving. We have a
firm selecting an external partner conditional on the learning costs of its
internal R&D unit. We show that there exists a matching equilibrium with
property that external partners with low learning costs for a project work
with R\&D units that also have low learning costs for the same project.
Empirically, we use a dataset of Spanish R\&D firms and relate their share
of R&D outsourcing to universities to the composition of their R&D units,
described by the presence of staff with a PhD. Our main finding is that,
controlling for endogeneity, firms that employ R\&D staff with a PhD
outsource relatively more to universities than to firms. We interpret this
result as evidence that R&D units with relatively low learning costs for
basic projects tend to match with external partners, universities, with
relatively low learning costs for the same projects.