[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: RE: RE: product function
At 18:00 25/05/04 +0100, Nick Cox wrote:
Thanks for that trick, Nick. I wasn't aware that you could do recurrence
relations in Stata that way. I always somehow assumed that the -replace-
command in Stata created a whole new variable as a result, assigned its
values on the basis of pre-existing variables, and then discarded the old
variable and put the new one in its place. Evidently, it doesn't do that,
and instead writes directly to the old variable, observation by
observation, using the previous observation(s) as input if asked to do so.
This trick will no doubt be useful next time I need to do a recurrence
relation. I have noted, of course, that the last character in the 4th line
is a l (the lower case version of L), and not a 1 (the digit one).
Woops. Sorry, Professor Feller!
. set obs 50
. gen i = _n
. gen double p = 1 - 1/365
. replace p = p[_n - 1] * (1 - _n / 365) in 2/l
. replace p = 1 - p
. scatter p i
Lecturer in Medical Statistics
Department of Public Health Sciences
King's College London
5th Floor, Capital House
42 Weston Street
London SE1 3QD
Tel: 020 7848 6648 International +44 20 7848 6648
Fax: 020 7848 6620 International +44 20 7848 6620
or 020 7848 6605 International +44 20 7848 6605
Opinions expressed are those of the author, not the institution.
* For searches and help try: