TREND function and Vensim PLE

Use this forum to post Vensim related questions.
Post Reply
Lukas
Junior Member
Posts: 8
Joined: Fri Jul 16, 2010 8:02 am

TREND function and Vensim PLE

Post by Lukas »

Hello,

Can I use the TREND function within Vensim PLE?

kind regards,
Lukas
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

You can use TREND in Vensim PLE, but it will not show up in the list of functions in the equation editor. This function is implemented as a MACRO and you might want to just write the equations out instead of using the function, this will make the model clearer.
Lukas
Junior Member
Posts: 8
Joined: Fri Jul 16, 2010 8:02 am

Post by Lukas »

thank you for the quick response.

Where can I get that MACRO and is there more background information about the TREND function?
karankhosla
Senior Member
Posts: 107
Joined: Wed Nov 26, 2008 6:12 am

Post by karankhosla »

Business Dynamics (John Sterman, McGraw Hill) gives a fantastic explanation for the TREND function (with equations) in Chapter 16 (pages 634-635)

Best Wishes,

Karan
karankhosla
Senior Member
Posts: 107
Joined: Wed Nov 26, 2008 6:12 am

Macros

Post by karankhosla »

Dear Lukas,

As for the macros, you have to go into the text editor for Vensim (under view "As Text") and insert the macro code in the equation set.

For example, here is a macro which demonstrates (one possible) way to find the first derivative of a variable:

:MACRO: firstderiv(input,dt)
firstderiv = (((input-SMOOTH(input,dt))/dt))
~ input/dt
~ |

:END OF MACRO:

Once this is done, you can go back to the "sketch" view and introduce a variable which will call the macro. Open the equation editor, go to functions and select macro - your macro should show up. Put in the required inputs and the units and things should work!

Model Attached.
Attachments
firstderivmacro.mdl
(1.39 KiB) Downloaded 288 times
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Post by tomfid »

Equations for TREND are in the online help entry for the function:
TREND=ZIDZ(input-avval,average time*ABS(avval))
avval=INTEG((input-avval)/average time,input/(1+ini*averate time))


Incidentally, Karan's macro shows nicely why the TREND function (which is basically a first derivative divided by a baseline value) is not a good model for expectations when the input is noisy or subject to abrupt changes. In those cases, the input changes quickly. If you use (((input-SMOOTH(input,dt))/dt)) the result is dominated by noise. If you lengthen the horizon from dt to some longer value, it helps a little, but not much because of the presence of the unfiltered input.

To model expectations with realistically noisy inputs, you really need a second-order structure that smooths the data before forming slope expectations.

Tom
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

The equations for Vensim's trend function are in the documentation for that function. This is true of all functions that are implemented as Macros. Note that Vensim's trend function is different from that documented in Business Dynamics, and also the Trend Molecule both of which have an additional SMOOTH relative to the Vensim implementation.

You can't enter MACROs in Vensim PLE, you will need to explicitly build out the equations (eg as the Trend Molecule). Molecules can be download from vensim.com
Lukas
Junior Member
Posts: 8
Joined: Fri Jul 16, 2010 8:02 am

Post by Lukas »

Thank you for all your reactions. They are very helpful.

I have already discovered that I cannot enter MACROs into Vensim PLE. However, Molecules are a great alternative for me right now.

First , I will take a look at Business Dynamics (page 634 and 635).

kind regards,
Lukas
Post Reply