Estimating Derivatives

55 views
Skip to first unread message

Gary Schultz

unread,
Jun 4, 2016, 9:05:41 PM6/4/16
to Stan users mailing list
I'm relatively new to Stan, but have been really impressed with it. Thank you so much for making this excellent work available under a permissive open source license. I have been using command Stan 2.9.

Now my question: Is there a nice way to estimate derivatives in a Stan model?

Specifically, I have a financial portfolio valuation v = E[ f(x) ], and need to compute the derivative of v with respect to certain parameters of the distribution. (The vector x are basically prices and the function f is a payoff function that is continuous and piece-wise smooth.) There are two flavors of how to do this: First, the "path-wise" method looks at the prices x(t) as a function of the parameters t, and differentiates d(f(x(t))/dt using the chain rule (and takes its expectation). The other main flavor parameterizes the probability distribution p(x;t) with t, and computes 

dv/dt = E[ f(x) d(log p(x;t))/dt ]

where the "score" or "likelihood ratio" (the derivative of the log likelihood) also requires a derivative. 

Since Stan has automatic differentiation built in, can I access those to implement one of these methods in Stan without hand-coding derivatives into my Stan code? Is there an elegant way to express this? Any pointers to examples?

Thanks in advance for any help you can provide.
Gary

Ben Goodrich

unread,
Jun 6, 2016, 4:53:13 PM6/6/16
to Stan users mailing list
On Saturday, June 4, 2016 at 9:05:41 PM UTC-4, Gary Schultz wrote:
Now my question: Is there a nice way to estimate derivatives in a Stan model?

There is currently no way to do so within a Stan program. We have thought about it some

https://github.com/stan-dev/stan/wiki/Functionals-spec

Ben


Gary Schultz

unread,
Jun 7, 2016, 12:45:14 PM6/7/16
to Stan users mailing list
Thank you, Ben. The link was a good answer. It would be really cool to have this, but it sounds like it would require some fundamental work.

-Gary
Reply all
Reply to author
Forward
0 new messages