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

From |
Dick Campbell <dcamp@uic.edu> |

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

Subject |
st: Patterns of longitudinal data |

Date |
Sat, 10 Aug 2002 08:24:01 -0500 |

Guillermo Cruces said:

I am working with panel data and I found the program xtpattern extremely useful.

<snip>

What I need now is to know how many contiguous observations there are, so for

instance:

1.1..1 would be zero

111111 would be six

111.11 would be (perhaps) three (the max).

The obvious thing would be to parse through the string generated by xtpattern...

but I couldn't find an elegant way around this p

xtpattern generates a string variable in the form 1.11.1 etc.

This can be interpreted as a binary number. Suppose there

are three observations maximum and we create the decimal

equivalent of the binary numbers resulting from xtpattern.

The fist position expands as 2**2, the second as 2**1

and the third as 2**0 (= 1). Thus for each pattern of observations

there is a unique decimal number,

Here is an example for four possible patterns.

111 = 7

11. = 6

1.1 = 5

1.. = 4

A neat characteristic of the decimal number is that

the higher the number of consecutive observations at the beginning of the

series the higher the decimal number. The second observation has a higher number than the third.

etc. You will also see that "consecutive observations always generate higher numbers

that non-consecutive, regardless of pattern.

=====================================

Richard T. Campbell

Professor of Sociology

Phone: 312/413-3759

Fax: 312/996-5104

More info: http://www.uic.edu/~dcamp

*

* 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/

- Prev by Date:
**st: multiple classification analysis** - Next by Date:
**st: svy command for mixed model** - Previous by thread:
**st: multiple classification analysis** - Next by thread:
**st: svy command for mixed model** - Index(es):

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