should I use a loop in calculate standard deviation

Problems with modeling
Post Reply
sandy12310627
User
User
Posts: 23
Joined: 4 years ago

should I use a loop in calculate standard deviation

Post by sandy12310627 »

Hi!

I have a problem with calculating the standard deviation in my model.
I would like to assume that standard deviation is the difference between the previously estimated demand and actual demand and I have the equation shows below.
Image
for example, if I want to get the standard deviation of demand at period 9, I should calculate the ste.dev. at period 8.
to get the ste.dev at period 8, I need period 1~7 expected demand and actual demand to calculate it.
and I write the code in GAMS as

Code: Select all

AA(k-1)..SS(k)=e=SQRT(sum(k,DF(k-1)-X(k-1))**2/ord(k-1);
BUT it said I already control the set. and too many ')' and ')'expected.
I think I need to revise the problem of the controlled set.
I am wondering what the problem is. should I use a loop to get the value?

Thank you for reading! I appreciate any help!

Sincerely,
Sandy
Attachments
image.png
image.png (6.13 KiB) Viewed 1644 times
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: should I use a loop in calculate standard deviation

Post by Renger »

Hi Sandy
See my answer to your other post regarding ord(k-1).
To sum, you should sum over an alias as the equation is defined over k.

Code: Select all

alias(k,kk)
sum(kk, ....)
CHeers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Post Reply