I’m developing a 2-compartment model in stan to analyze a pk dataset in which a 10 mg dose of a drug was administered into the central compartment as a 15 minute infusion. I want to include the ODEs as a function in the first block of the stan code. Could you possibly direct me to example code describing drug administration via a short infusion to guide model development? Thanks in advance for your help.

This is not my area of models but here two threads discussing this kind of thing.

There is some discussion here for a one compartment Bounding posterior output of pharmacokinetic model that might get you going in the right direction.

Here as well: Stan simple model for pharmacokinetics

You can, but you don’t have to add ODE function because 2-cpt model has analytical solution. All you need is to code that solution. This way is more efficient than numerical solution.

Shameless plug: you can also use Torsten, a pharmacometric library built on top of Stan as it has built in 2-cpt functionality. If you are comfortable with NONMEM model specification, Torsten could be your thing. If you still prefer numerical solution of ODE, check out this Torsten example for a possible implementation of 2-cpt model.

Is it really necessary to model it as an infusion? Often the infusion time is very short in comparison to when measurements are taken or what time-spans are of interest… unless you are really after mass balance and want to get things right just after infusion stops. In case you can simplify, then a bolus iv shot can approximate the infusion well enough.