Hey all,
I would be rather asking something really basic, as I am new to Vensim. I could not figure out that how can I take the average of only certain time period (lets say first ten years) of from the data in stock?
How to calculate average
Re: How to calculate average
If an exponentially-weighted moving average is OK, you can use the SMOOTH function to compute an average. For example,
avg value = SMOOTH( value, horizon ) ~ stuff
horizon = 10 ~ years
If you want to freeze the average at some point, you can replace the SMOOTH with the underlying stock/flow equivalent:
avg value = INTEG( avg adjusting, initial value ) ~ stuff
avg adjusting = avg active * (value-avg value) / horizon ~ stuff/time
horizon = 10 ~ years
avg active = 1-STEP(1,freeze time) ~ dmnl ~ switch that controls whether updating is active
freeze time = 20 ~ year
If you need a simple average, it's a little more complicated, but you can do something like the following:
inflow = value ~ stuff
cum value = INTEG( inflow-outflow, 0 ) ~ stuff*time
outflow = DELAY FIXED(inflow, horizon, 0) ~ stuff
avg value = cum value/horizon ~ stuff
avg value = SMOOTH( value, horizon ) ~ stuff
horizon = 10 ~ years
If you want to freeze the average at some point, you can replace the SMOOTH with the underlying stock/flow equivalent:
avg value = INTEG( avg adjusting, initial value ) ~ stuff
avg adjusting = avg active * (value-avg value) / horizon ~ stuff/time
horizon = 10 ~ years
avg active = 1-STEP(1,freeze time) ~ dmnl ~ switch that controls whether updating is active
freeze time = 20 ~ year
If you need a simple average, it's a little more complicated, but you can do something like the following:
inflow = value ~ stuff
cum value = INTEG( inflow-outflow, 0 ) ~ stuff*time
outflow = DELAY FIXED(inflow, horizon, 0) ~ stuff
avg value = cum value/horizon ~ stuff
/*
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
*/