Page 1 of 1
TREND function and Vensim PLE
Posted: Mon Jul 19, 2010 8:19 am
by Lukas
Hello,
Can I use the TREND function within Vensim PLE?
kind regards,
Lukas
Posted: Mon Jul 19, 2010 9:59 am
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.
Posted: Mon Jul 19, 2010 11:10 am
by Lukas
thank you for the quick response.
Where can I get that MACRO and is there more background information about the TREND function?
Posted: Mon Jul 19, 2010 6:35 pm
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
Macros
Posted: Mon Jul 19, 2010 6:58 pm
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.
Posted: Mon Jul 19, 2010 9:49 pm
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
Posted: Tue Jul 20, 2010 9:33 am
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
Posted: Tue Jul 20, 2010 2:29 pm
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