Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: RE: local macro and xtmixed in stata 12 giving diff results
From
Nick Cox <[email protected]>
To
"'[email protected]'" <[email protected]>
Subject
st: RE: local macro and xtmixed in stata 12 giving diff results
Date
Fri, 17 Feb 2012 17:11:08 +0000
I don't think the results are "slightly different". In essence, the -xtmixed- command that you invoke with an embedded reference to `variables' interprets that reference as referring to a non-existent macro. Otherwise put, Stata cannot see the macro from where it is implementing the -xtmixed- command.
My guess is that there is something you are not telling us, namely that the -local variables <stuff>- is defined in one place and the -xtmixed- command is run from another. In fact, this is not really a guess. The tell-tale line is "end of do-file" meaning that this is not a "complete log" at all, as you ran a do-file to do part of this.
A key point about local macros is that they _are_ local, so that local macros defined in one locale are not visible from another. Here a "locale" is defined (by me, not StataCorp) as being one of (1) an interactive session (2) a program (3) a do-file (4) the do-file editor contents.
The remedy is easy: if you refer to a local macro within a do-file or do-file editor window, you _must_ define that local macro earlier in the same locale.
Nick
[email protected]
Clara Barata
Any idea why these two models below would give me slightly different results?
*Model1
xtmixed ptc_10_ interv ptc_09_ D2-D5 agrup saseAp09 saseBp09 saseCp09
compy_09 web_09 preesc secundario totalunos_09 ///
docenttot_09 docentPercfem_09 docidade_09 naodoctot_09 antigu_09
docdoutmest_09 ///
AMU10 APU10 || cescola:, cov(un) pweight(pscorewgt) mle var
*Model2
local variables D2-D5 agrup saseAp09 saseBp09 saseCp09 compy_09 web_09
preesc secundario totalunos_09 ///
docenttot_09 docentPercfem_09 docidade_09 naodoctot_09 antigu_09
docdoutmest_09 ///
AMU10 APU10
xtmixed ptc_10_ interv ptc_09_ `variables' || cescola:, cov(un)
pweight(pscorewgt) mle var
* Complete log
. local variables D2-D5 agrup saseAp09 saseBp09 saseCp09 compy_09
web_09 preesc secundario totalunos_09 ///
> docenttot_09 docentPercfem_09 docidade_09 naodoctot_09 antigu_09 docdoutmest_09 ///
> AMU10 APU10
. xtmixed ptc_10_ interv ptc_09_ `variables' || cescola:, cov(un)
pweight(pscorewgt) mle var
Note: single-variable random-effects specification; covariance
structure set to identity
(1625 missing values generated)
Obtaining starting values by EM:
Performing gradient-based optimization:
Iteration 0: log pseudolikelihood = -7629.1893
Iteration 1: log pseudolikelihood = -7628.8716
Iteration 2: log pseudolikelihood = -7628.8715
Computing standard errors:
Mixed-effects regression Number of obs = 1359
Group variable: cescola Number of groups = 361
Obs per group: min = 1
avg = 3.8
max = 8
Wald chi2(2) = 329.84
Log pseudolikelihood = -7628.8715 Prob > chi2 = 0.0000
(Std. Err. adjusted for 361 clusters in cescola)
------------------------------------------------------------------------------
| Robust
ptc_10_ | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
interv | 4.425498 .7011216 6.31 0.000 3.051325 5.799671
ptc_09_ | .4548144 .0289727 15.70 0.000 .398029 .5115999
_cons | 47.83422 2.600319 18.40 0.000 42.73769 52.93075
------------------------------------------------------------------------------
------------------------------------------------------------------------------
| Robust
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
cescola: Identity |
var(_cons) | 9.664571 2.245821 6.128909 15.2399
-----------------------------+------------------------------------------------
var(Residual) | 42.38466 2.659331 37.4802 47.93088
------------------------------------------------------------------------------
.
. xtmixed ptc_10_ interv ptc_09_ D2-D5 agrup saseAp09 saseBp09
saseCp09 compy_09 web_09 preesc secundario totalunos_09 ///
> docenttot_09 docentPercfem_09 docidade_09 naodoctot_09 antigu_09 docdoutmest_09 ///
> AMU10 APU10 || cescola:, cov(un) pweight(pscorewgt) mle var
Note: single-variable random-effects specification; covariance
structure set to identity
(1641 missing values generated)
Obtaining starting values by EM:
Performing gradient-based optimization:
Iteration 0: log pseudolikelihood = -7567.187
Iteration 1: log pseudolikelihood = -7565.6155
Iteration 2: log pseudolikelihood = -7565.6135
Iteration 3: log pseudolikelihood = -7565.6135
Computing standard errors:
Mixed-effects regression Number of obs = 1359
Group variable: cescola Number of groups = 361
Obs per group: min = 1
avg = 3.8
max = 8
Wald chi2(23) = 493.65
Log pseudolikelihood = -7565.6135 Prob > chi2 = 0.0000
(Std. Err. adjusted for 361 clusters
in cescola)
----------------------------------------------------------------------------------
| Robust
ptc_10_ | Coef. Std. Err. z P>|z| [95%
Conf. Interval]
-----------------+----------------------------------------------------------------
interv | 4.098699 .5971533 6.86 0.000 2.9283
5.269098
ptc_09_ | .4162623 .0267885 15.54 0.000 .3637578
.4687669
D2 | -.5525483 .8820861 -0.63 0.531 -2.281405
1.176309
D3 | -3.002324 .8082203 -3.71 0.000 -4.586407
-1.418241
D4 | -3.811223 1.05004 -3.63 0.000 -5.869264
-1.753181
D5 | -4.668435 1.141422 -4.09 0.000 -6.90558
-2.431289
agrup | 1.900642 .9238745 2.06 0.040 .0898816
3.711403
saseAp09 | -5.459656 2.802486 -1.95 0.051 -10.95243
.0331154
saseBp09 | 5.247487 4.820744 1.09 0.276 -4.200997
14.69597
saseCp09 | -5.374767 8.870566 -0.61 0.545 -22.76076
12.01122
compy_09 | -.0563566 .0343605 -1.64 0.101 -.123702
.0109889
web_09 | .0823975 .0430518 1.91 0.056 -.0019826
.1667775
preesc | 1.373344 1.237249 1.11 0.267 -1.051619
3.798308
secundario | .3618894 .6426638 0.56 0.573 -.8977086
1.621487
totalunos_09 | .0011173 .0018731 0.60 0.551 -.0025538
.0047884
docenttot_09 | -.0349247 .023305 -1.50 0.134 -.0806017
.0107524
docentPercfem_09 | -.0630209 .0412631 -1.53 0.127 -.1438951
.0178534
docidade_09 | -.3729159 .1935731 -1.93 0.054 -.7523122
.0064805
naodoctot_09 | -.0240927 .0380972 -0.63 0.527 -.0987619
.0505765
antigu_09 | .1846323 .1690689 1.09 0.275 -.1467367
.5160014
docdoutmest_09 | .093919 .0949468 0.99 0.323 -.0921734
.2800113
AMU10 | -1.187541 1.247426 -0.95 0.341 -3.632452
1.25737
APU10 | -1.663058 1.27383 -1.31 0.192 -4.15972
.833603
_cons | 73.14461 8.145537 8.98 0.000 57.17965
89.10957
----------------------------------------------------------------------------------
------------------------------------------------------------------------------
| Robust
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
cescola: Identity |
var(_cons) | 7.148994 1.617105 4.588839 11.13748
-----------------------------+------------------------------------------------
var(Residual) | 41.30718 2.560637 36.58133 46.64355
------------------------------------------------------------------------------
.
end of do-file
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/