[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"Nick Cox" <n.j.cox@durham.ac.uk> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
RE: st: assignment by indexing |

Date |
Wed, 4 Feb 2004 13:13:54 -0000 |

Now I'm confused. As was emphasised yesterday, gen newvar = x[indexvar] is legal and useful. If you want the syntax gen newvar = x(indexvar) to select from variables x1, x2, ... according to whether indexvar is 1, 2, ..., then (1) that syntax is not supported; (2) there's no neat way of doing exactly that in one step (although it could easily be programmed as an -egen- function); (3) there are other ways to do the same thing. Your Markov problem should definitely not need 107 equations. You could set it up a matrix problem or as a variables problem. Nick n.j.cox@durham.ac.uk > -----Original Message----- > From: owner-statalist@hsphsun2.harvard.edu > [mailto:owner-statalist@hsphsun2.harvard.edu]On Behalf Of Ben Pelzer > Sent: 04 February 2004 12:41 > To: statalist@hsphsun2.harvard.edu > Subject: RE: st: assignment by indexing > > > Nick, Ernest and Allan, > > Thanks for your comments and tips. I am surprised that a > statement like "gen > newvar = x(indexvar)" is not available in Stata, since in > other packages, > this is everyday meat. In my application, the indexvariable > is "time" which > is used in a Markov model that links state probabilities a > timepoint t to > those at t-1 and to the transition probabilities to "stay in 1" or to > "switch from 0 to 1", i.e.: > > p(y=1|time) = p(y=1|time-1) * p(stay in 1) + p(y=0|time-1) * > p(switch from 0 to 1) > > This equation is to be evaluated for 107 timepoints, so using > time as an > index, would be very handsome. In the past I implemented the model in > several other packages, (which I dare not mention here), and > I now would > like to develop a Stata version as well. In Stata I suppose I > have to use > 107 equations, then? Ok, if that's all it takes, I'll go for > it. * * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**RE: st: assignment by indexing***From:*"Ben Pelzer" <b.pelzer@maw.kun.nl>

- Prev by Date:
**Re: st: assignment by indexing** - Next by Date:
**RE: st: assignment by indexing** - Previous by thread:
**Re: RE: st: assignment by indexing** - Next by thread:
**RE: st: assignment by indexing** - Index(es):

© Copyright 1996–2016 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |