jtengyp 发表于 2012-12-23 16:51 
处理非面板数据的话,能不能介绍一下区别,我看不太懂
处理非面板数据
xtset is used to declare the dataset is panel data, see example
webuse pig
xtset id week
declare data is panel with id as identifier and stub is week
. xtset id week
panel variable: id (strongly balanced)
time variable: week, 1 to 9
delta: 1 unit
tsset is used to declare the data is time-series data, see example
use the same dataset as above:
. tsset week
repeated time values in sample
r(451);
the reason of error is because week is not a time-series variable. list week in 1/10
| week |
|------|
1. | 1 |
2. | 1 |
3. | 1 |
4. | 1 |
5. | 1 |
|------|
6. | 1 |
7. | 1 |
8. | 1 |
9. | 1 |
10. | 1 |
now show a case where tsset can be applied to time-series data
webuse dow1
tsset date
. . tsset date
time variable: date, 02jan1953 to 20feb1990, but with gaps
delta: 1 day
list date in 1/10
| date |
|-----------|
1. | 02jan1953 |
2. | 05jan1953 |
3. | 06jan1953 |
4. | 07jan1953 |
5. | 08jan1953 |
|-----------|
6. | 09jan1953 |
7. | 12jan1953 |
8. | 13jan1953 |
9. | 14jan1953 |
10. | 15jan1953 |