Hi,
I am trying to figure out how to include the data value at time=x-1 into an equation. How do I do that? For variable Z, I want Vensim at time=0 to use =z(initial)+Y*0.01, but at time=2, i'd like it to use =z(at time=1)+Y*0.01. At time=3, i want the equation to read =z(at time=2)+Y*0.01, etc. What is the correct format for the equation to achieve this? Thank you.
Kei
calling time=x-1 data into an equation
Re: calling time=x-1 data into an equation
You can use the TIME SHIFT function to generate a shifted version of the data - https://www.vensim.com/documentation/in ... _shift.htm
You can also use GET DATA AT TIME, https://www.vensim.com/documentation/in ... t_time.htm
Note that it's an expensive function call, so you want to use it sparingly (e.g., wrapped by INITIAL()).
You can also use GET DATA AT TIME, https://www.vensim.com/documentation/in ... t_time.htm
Note that it's an expensive function call, so you want to use it sparingly (e.g., wrapped by INITIAL()).
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Re: calling time=x-1 data into an equation
Thank you for your reply.
In both those solutions you mention, i would have to call out a specific time point, but I am interested in telling Vensim to use the data value in the previous time point (day-1) at every step (every day), except for time=1, where there would be an initial value that must be given, since there is no t=0. How could I tell Vensim, as I would in equations in Excel, to use the data value at time=x-1 to compute the value at time=x, for all time steps?
thank you.
In both those solutions you mention, i would have to call out a specific time point, but I am interested in telling Vensim to use the data value in the previous time point (day-1) at every step (every day), except for time=1, where there would be an initial value that must be given, since there is no t=0. How could I tell Vensim, as I would in equations in Excel, to use the data value at time=x-1 to compute the value at time=x, for all time steps?
thank you.
Re: calling time=x-1 data into an equation
TIME SHIFT gives you a complete time series with the offset you specify.
At INITIAL TIME, it will look back into the data for a point at (INITIAL TIME-1), but if there is no such point, it will return the value at INITIAL TIME.
At INITIAL TIME, it will look back into the data for a point at (INITIAL TIME-1), but if there is no such point, it will return the value at INITIAL TIME.
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Re: calling time=x-1 data into an equation
Hi, I just tried using TIME <b>****</b>("variable name", -1), but i get this error message: "can only use data and constants in data equations "variable name".
Like i said before, I want to use the value calculated at time-1 for "variable name" in the equation, so that each value given an at time=x is a function of the calculated value for that variable at time-1.
Thank you.
Like i said before, I want to use the value calculated at time-1 for "variable name" in the equation, so that each value given an at time=x is a function of the calculated value for that variable at time-1.
Thank you.
Re: calling time=x-1 data into an equation
What I suggested is for data, per your original query. If you want the delayed value of a model variable, you can use DELAY FIXED or similar.
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Re: calling time=x-1 data into an equation
Hi
I have a similar query.I want to calculate growth rates of my stock variables.How can i do this in vensim ple? For example, I have a stock variable called aggregate output (Y). I want to calculate growth rate of Y using the formula : [Y(t) -Y(t-1)]/Y(t).
How do I get lagged value Y(t-1)?
Swati
I have a similar query.I want to calculate growth rates of my stock variables.How can i do this in vensim ple? For example, I have a stock variable called aggregate output (Y). I want to calculate growth rate of Y using the formula : [Y(t) -Y(t-1)]/Y(t).
How do I get lagged value Y(t-1)?
Swati
-
- Super Administrator
- Posts: 4589
- Joined: Wed Mar 05, 2003 3:10 am
Re: calling time=x-1 data into an equation
To quote Tom, "If you want the delayed value of a model variable, you can use DELAY FIXED.....".
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine-27509559
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Re: calling time=x-1 data into an equation
Also, this is what the TREND function does, if the horizon equals one time step.
https://www.vensim.com/documentation/in ... _trend.htm
https://www.vensim.com/documentation/in ... _trend.htm
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Re: calling time=x-1 data into an equation
Thanks.this works perfectly for me.