data storage

Use this forum to post Vensim related questions.
Post Reply
khalediwm
Member
Posts: 42
Joined: Sun Mar 07, 2010 9:58 am

data storage

Post 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?
LAUJJL
Senior Member
Posts: 1427
Joined: Fri May 23, 2003 10:09 am
Vensim version: DSS

Post 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
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post 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.
karankhosla
Senior Member
Posts: 107
Joined: Wed Nov 26, 2008 6:12 am

Post 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:
khalediwm
Member
Posts: 42
Joined: Sun Mar 07, 2010 9:58 am

Post 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]
Attachments
variable change.mdl
(2.59 KiB) Downloaded 210 times
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post 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.
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Post 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
ouzfalcon
Junior Member
Posts: 6
Joined: Wed Nov 18, 2009 8:15 am

Post 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.
ouzfalcon
Junior Member
Posts: 6
Joined: Wed Nov 18, 2009 8:15 am

Post 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.
Post Reply