DataEval(.) example usage?

47 views
Skip to first unread message

James Thorson

unread,
Mar 26, 2025, 9:59:44 AMMar 26
to TMB Users
Hi all,

Does anyone have an example of using `RTMB::DataEval` to share?

I want to calculate the derivative of function $f( p, d )$ with respect to parameters $p$ when repeatedly updating the value of continuous-valued data $d$ without rebuilding the tape.  I can obviously define a new vector `z = c(p,d)` and then throw out the derivative information w.r.t. $d$ but this seems inefficient computationally.  I also note that the example in the reference docs here seems to cover a different use-case (which I don't fully understand), but states that `RTMB::DataEval` replaces `DATA_UPDATE` in TMB, where I think the latter covers the use-case I envision.

Cheers,
Jim   

Ben Bolker

unread,
Mar 26, 2025, 10:03:49 AMMar 26
to tmb-...@googlegroups.com
+1.

Is there a discussion of the pros and cons of DATA_UPDATE somewhere
(other than the basic caveats described in the docs) ? Is it costly if
the data do *not* change?

https://kaskr.github.io/adcomp/group__macros.html#ga3a3716228d46fbe32e23856b2f53be8d

On 2025-03-26 9:59 a.m., James Thorson wrote:
> Hi all,
>
> Does anyone have an example of using `RTMB::DataEval` to share?
>
> I want to calculate the derivative of function $f( p, d )$ with respect
> to parameters $p$ when repeatedly updating the value of continuous-
> valued data $d$ without rebuilding the tape.  I can obviously define a
> new vector `z = c(p,d)` and then throw out the derivative information
> w.r.t. $d$ but this seems inefficient computationally.  I also note that
> the example in the reference docs here <https://rdrr.io/cran/RTMB/man/
> Tape.html> seems to cover a different use-case (which I don't fully
> understand), but states that `RTMB::DataEval` replaces `DATA_UPDATE` in
> TMB, where I think the latter covers the use-case I envision.
>
> Cheers,
> Jim
>
> --
> To post to this group, send email to us...@tmb-project.org. Before
> posting, please check the wiki and issuetracker at https://github.com/
> kaskr/adcomp/ <https://github.com/kaskr/adcomp/>. Please try to create a
> simple repeatable example to go with your question (e.g issues 154, 134,
> 51). Use the issuetracker to report bugs.
> ---
> You received this message because you are subscribed to the Google
> Groups "TMB Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to tmb-users+...@googlegroups.com <mailto:tmb-
> users+un...@googlegroups.com>.
> To view this discussion visit https://groups.google.com/d/msgid/tmb-
> users/CAMDbYvZVonL2xMRo-
> _XCmpLNdURCAdZDTuzoLNM8MUVQQopCxg%40mail.gmail.com <https://
> groups.google.com/d/msgid/tmb-users/CAMDbYvZVonL2xMRo-
> _XCmpLNdURCAdZDTuzoLNM8MUVQQopCxg%40mail.gmail.com?
> utm_medium=email&utm_source=footer>.

--
Dr. Benjamin Bolker
Professor, Mathematics & Statistics and Biology, McMaster University
Director, School of Computational Science and Engineering
> E-mail is sent at my convenience; I don't expect replies outside of
working hours.

Reply all
Reply to author
Forward
0 new messages