Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# st: RE: generating varables

 From Nick Cox <[email protected]> To "'[email protected]'" <[email protected]> Subject st: RE: generating varables Date Mon, 25 Oct 2010 11:42:32 +0100

```What you need follows from the help for -generate- and for -subscripting-.

I doubt that menus help anyone here, as the formula defining each variable has to be typed in somewhere and it might as well be in the Command window.

Nick
[email protected]

Max Zamanian

For teaching purposes I would like to create variables following
different order of difference equations such as
1.	Yt=bYt-1
2.	Yt=a+bYt-1
3.	Yt=a+bYt-1+cYt-2
etc
This is an example of data series I generate in MS Excel.
1	Sigle nubmer, 1
0,5	Formula: =+E1*0,5
-0,55	=+(E2*0,5)-(E1*0,8)
-0,675
0,1025
0,59125
0,213625
-0,36619
-0,35399
0,115953
0,341172
0,077823
-0,23403
-0,17927
0,097585
0,19221
0,018037
-0,14475
-0,0868
0,072397
0,105642
-0,0051
-0,08706
-0,03945
0,049923
0,056524
-0,01168

For the first one I have got the way doing it, through STATA support,
which is the following:
clear
set obs 10
generate x = 1 * (0.5)^(_n - 1)
list
* end example
Here b=0.5 and the initial value of Y=1. I can of course replace these
values to get different series. Otherwise I do not understand what is
going on, therefore I cannot generate diff eq 2 and 3 above.

I need a general description about how to generate variables like these
and preferably also references to the appropriate menu(s) to get these
variables.

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```