Page 1 of 1
data storage
Posted: Sun Mar 07, 2010 10:05 am
by khalediwm
Lets say I need to calculate the rate of change for any variables, but I don't know how to store data from the previous time step (T-1)? Can anybody help me please?
Posted: Sun Mar 07, 2010 10:21 am
by LAUJJL
This question was already asked, October 2009, see at the Vensim Forum for the thread:
'question about tracing variable change from the SD forum'
posted on 20th of October approximately.
Regards. ^
JJ
Posted: Sun Mar 07, 2010 11:18 am
by bob@vensim.com
The thread JJ refers to is
http://www.ventanasystems.co.uk/forum/v ... php?t=3943
See also the molecules. The general formulation for continuous time is
rate of change = (current value - smoothed value)/(smooth time * smoothed value)
smoothed value =SMOOTH(current value,smooth time)
in your example you would replace smooth time with TIME STEP.
Posted: Mon Mar 08, 2010 8:06 am
by karankhosla
Here is a macro to find the second derivative (you can modify it for the first derivative):
:MACRO: seconderiv(input,dt)
seconderiv = (firstderiv-SMOOTH(firstderiv, dt))/dt~input/dt/dt~|
firstderiv = (((input-SMOOTH(input,dt))/dt)) ~input/dt~|
:END OF MACRO:
Posted: Tue Jun 22, 2010 8:37 am
by khalediwm
Hi Bob
I tried with your way, as well as followed the link that you mentioned. None of theme worked for me. I am attaching my file for your review.
Thanking you in advance
Khaled
[Edited on 6-22-2010 by khalediwm]
Posted: Tue Jun 22, 2010 9:32 am
by bob@vensim.com
For variation use
fractional change = ZIDZ(val - older val,older val)/measurement interval
older val = INTEG((val - older val)/measurement interval,val)
in your model you used TIME STEP as measurement interval and forgot to divide by it in the fractional change equation. The denominator in the fraction really only make sense as older val.
Again see the molecules.
Posted: Tue Jun 22, 2010 1:25 pm
by tomfid
Bear in mind that any calculation of derivatives or trends over short times (like TIME STEP) will be very sensitive to noise or discontinuities. If you're modeling a real-world decision, there has to be significant smoothing (which implies delay) in the trend perception process.
Tom
Posted: Thu Jun 24, 2010 11:29 pm
by ouzfalcon
I have same problem with the Sea Level Rise model, Grinsted_v3b‎.vpm.
I saved the file as .htm then changed to vpm ( and tried .mdl too). When I received 'Syntax Error msg when I tried to view as sketch.
I also tried changing character encoding to UTF-8 before saving the model as .htm. No succes.
With DICE model, by using same method, I viewed the model as text but no succes viewing as sketch.
I am not sure if I am missing something.
Posted: Thu Jun 24, 2010 11:34 pm
by ouzfalcon
please ignore my message as it was sent by mistake. it was intended to be sent to another thread.
Need more sleep i guess.