Forecasting using SAS Forecast Server, SAS/ETS, and more

sas code

Frequent Contributor
Posts: 91

sas code


Can someone please help me with the following coding?

I need to create a data set of 1000 values for the following model:

X(t) = {(1-L)^0.4]^(-1)} e ,where e is a standard normal random variable and L is the lag operator. I don't know how to deal with the lag operator. finally I need to plot X vs. t.


Super User
Super User
Posts: 7,039

Re: sas code

Posted in reply to malakaext

Your formula blows up when L is greater than 1 as you will be trying to root of a negative number.

Assuming that by lag operator you mean you want to feed in the previous value of X?

57   data want ;

58    x=0;

59    do time=1 to 1000 ;

60      e=rannorm(0);

61      put time= x= e= ' -> ' @;

62      x= (1/((1-x)**0.4))*e ;

63      put x= ;

64      if x=. then stop;

65      output;

66    end;

67   run;

time=1 x=0 e=-0.107529115  -> x=-0.107529115

time=2 x=-0.107529115 e=0.3713905792  -> x=0.3565240426

time=3 x=0.3565240426 e=0.3788970702  -> x=0.4519686557

time=4 x=0.4519686557 e=-0.256832352  -> x=-0.326683778

time=5 x=-0.326683778 e=0.1424978021  -> x=0.1272627191

time=6 x=0.1272627191 e=0.3964266863  -> x=0.4186098767

time=7 x=0.4186098767 e=0.493639789  -> x=0.6132295837

time=8 x=0.6132295837 e=0.3337242418  -> x=0.4879849812

time=9 x=0.4879849812 e=2.3604100433  -> x=3.0851364281

NOTE: Invalid argument(s) to the exponential operator "**" at line 62 column 16.

time=10 x=3.0851364281 e=1.5859540911  -> x=.

x=. time=10 e=1.5859540911 _ERROR_=1 _N_=1

Frequent Contributor
Posts: 91

Re: sas code

Thanks . But I  need use the 1st 100 terms of the INFINITE  BINOMIAL expansion of the term (1/((1-x)**0.4)). Can you please modify your model according to it?

Ask a Question
Discussion stats
  • 2 replies
  • 2 in conversation