New command: xtset
A new command, xtset replaces the i(groupvar) and t(timevar) (but they can still be used). The advantage is that you only have to use xtset once for your dataset, rather than every time you run an analysis. For example:
xtset idcode year
panel variable: idcode (unbalanced)
time variable: year, 70 to 88, but with gaps
delta: 1 unit
xtset also allows the delta option sets the periodicity of timevar, most frequently used with %tc (time clock) where time is recorded in ms but the actual data was not collected that frequently. For example, for hourly data, one would declare delta((60*60*1000)) or delta(hours).
New Models: xtmelogit and xtmepoisson
Mixed models for dichotomous (xtmelogit) and count (xtmepoisson) outcomes!
The data for this example are from a survey of women in Bangladesh about
their contraceptive use. The level 1 variables are:
c_use: contraceptive use
age: woman's age (mean centered)
child1: one child
child2: two children
child3: three or more children
urban: dummy for urban vs. rural
use http://www.stata-press.com/data/r10/bangladesh.dta
(Bangladesh Fertility Survey, 1989)
xtset district
panel variable: district (unbalanced)
xtmelogit c_use urban age child1 child2 child3 || district: urban, cov(un)
Refining starting values:
Iteration 0: log likelihood = -1215.8594 (not concave)
Iteration 1: log likelihood = -1204.0802
Iteration 2: log likelihood = -1199.7943
Performing gradient-based optimization:
Iteration 0: log likelihood = -1199.7943
Iteration 1: log likelihood = -1199.4697
Iteration 2: log likelihood = -1199.3158
Iteration 3: log likelihood = -1199.315
Iteration 4: log likelihood = -1199.315
Mixed-effects logistic regression Number of obs = 1934
Group variable: district Number of groups = 60
Obs per group: min = 2
avg = 32.2
max = 118
Integration points = 7 Wald chi2(5) = 97.50
Log likelihood = -1199.315 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
c_use | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
urban | .8157872 .1715519 4.76 0.000 .4795516 1.152023
age | -.026415 .008023 -3.29 0.001 -.0421398 -.0106902
child1 | 1.13252 .1603285 7.06 0.000 .8182819 1.446758
child2 | 1.357739 .1770522 7.67 0.000 1.010724 1.704755
child3 | 1.353827 .1828801 7.40 0.000 .9953881 1.712265
_cons | -1.71165 .1605617 -10.66 0.000 -2.026345 -1.396954
------------------------------------------------------------------------------
------------------------------------------------------------------------------
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
district: Unstructured |
sd(urban) | .8162856 .1975237 .5080068 1.31164
sd(_cons) | .6242944 .1035136 .451079 .8640248
corr(urban,_cons) | -.796473 .1151556 -.9361775 -.4394905
------------------------------------------------------------------------------
LR test vs. logistic regression: chi2(3) = 58.42 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference.
For random intercept models, you will still want to use xtlogit since it will generally run faster. The parameter estimates for the same model running xtlogit and xtmelogit will not be identical because the default number of integration points for xtlogit is 12 while the default for xtmelogit is 7. You can set the number of integration points for either procedure, and with equal numbers of integration points you will receive identical estimates.
Other Improvements:
The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California.