Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: collinearity error with xtmixed


From   Tim <lists@timbp.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: collinearity error with xtmixed
Date   Thu, 07 Mar 2013 19:49:58 +1100

Hello statalist

This afternoon I am getting a collinearity error with an -xtmixed- model that ran without error earlier in the week. I suspect it may be related to the 25 February 2013 update that I installed this morning, and I am wondering if anyone else has had any issues. I have not been able to reproduce the error in a standard dataset.

. mi extract 0
. xtmixed factc i.onemonth c.mth i.exent i.predischarge#1.exent i.exent#(i.onemonth c.mth) , || id:
note: 1.exent#c.mth omitted because of collinearity
factc collinear with 1.onemonth mth 1.exent 1.predischarge#1.exent 1.exent#1.onemonth _cons
r(459);

The above command ran earlier this week (with -mi estimate- in the full imputed data). I did recreate the dataset yesterday, and at first I thought I might have introduced an error in creating one of the variables. But I have rechecked that do file and believe the variables are correctly created, and as far as I can see they are not collinear.
 Furthermore -regress- with the same variables works:
. regr factc i.onemonth c.mth i.exent i.predischarge#1.exent i.exent#(i.onemonth c.mth)

Source | SS df MS Number of obs = 907 -------------+------------------------------ F( 6, 900) = 11.13 Model | 29167.1194 6 4861.18657 Prob > F = 0.0000
    Residual |  392985.922   900  436.651024           R-squared =  0.0691
-------------+------------------------------ Adj R-squared = 0.0629
       Total |  422153.041   906  465.952584           Root MSE =  20.896

------------------------------------------------------------------------------------
factc | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------------+----------------------------------------------------------------
1.onemonth | 2.159979 4.877711 0.44 0.658 -7.413033 11.73299 mth | .8091676 .506566 1.60 0.111 -.1850205 1.803356 1.exent | 2.403435 4.091718 0.59 0.557 -5.626985 10.43386
                   |
predischarge#exent |
1 1 | -12.85066 2.540801 -5.06 0.000 -17.83725 -7.864078
                   |
    exent#onemonth |
1 1 | -4.527393 5.393465 -0.84 0.401 -15.11263 6.05784
                   |
       exent#c.mth |
1 | -.0603609 .5561196 -0.11 0.914 -1.151803 1.031081
                   |
_cons | 90.67813 3.693961 24.55 0.000 83.42835 97.9279
------------------------------------------------------------------------------------

But if I use my own constant I get a variable omitted for collinearity, and ridiculous results: . regr factc i.baseline i.onemonth c.mth i.exent i.predischarge#1.exent i.exent#(i.onemonth c.mth)
>  , nocons
note: 1.exent#c.mth omitted because of collinearity

Source | SS df MS Number of obs = 907 -------------+------------------------------ F( 6, 901) = 0.00 Model | 0 6 0 Prob > F = 1.0000
    Residual |   8153786.3   901  9049.70733           R-squared =  0.0000
-------------+------------------------------ Adj R-squared = -0.0067
       Total |   8153786.3   907  8989.84157           Root MSE =   95.13

------------------------------------------------------------------------------------
factc | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------------+----------------------------------------------------------------
1.baseline | -2294.535 38.70451 -59.28 0.000 -2370.497 -2218.574 1.onemonth | 3036.203 50.02024 60.70 0.000 2938.033 3134.373 mth | -136.4238 2.383266 -57.24 0.000 -141.1012 -131.7464 1.exent | 2928.942 46.65202 62.78 0.000 2837.383 3020.501
                   |
predischarge#exent |
1 1 | -554.1757 14.01385 -39.54 0.000 -581.6793 -526.6721
                   |
    exent#onemonth |
1 1 | -2888.99 47.15213 -61.27 0.000 -2981.53 -2796.449
                   |
       exent#c.mth |
                1  |          0  (omitted)
------------------------------------------------------------------------------------

Omit that variable from the command myself instead of letting Stata drop it, and the results are reasonable again: . regr factc i.baseline i.onemonth c.mth i.exent i.predischarge#1.exent i.exent#(i.onemonth) , noc
> ons

Source | SS df MS Number of obs = 907 -------------+------------------------------ F( 6, 901) = 2965.49 Model | 7760795.24 6 1293465.87 Prob > F = 0.0000
    Residual |  392991.066   901  436.172104           R-squared =  0.9518
-------------+------------------------------ Adj R-squared = 0.9515
       Total |   8153786.3   907  8989.84157           Root MSE =  20.885

------------------------------------------------------------------------------------
factc | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------------+----------------------------------------------------------------
1.baseline | 90.67813 3.691934 24.56 0.000 83.43233 97.92392 1.onemonth | 2.396769 4.360251 0.55 0.583 -6.16066 10.9542 mth | .7590845 .208915 3.63 0.000 .3490678 1.169101 1.exent | 2.403435 4.089474 0.59 0.557 -5.622568 10.42944
                   |
predischarge#exent |
1 1 | -12.85066 2.539407 -5.06 0.000 -17.8345 -7.866821
                   |
    exent#onemonth |
1 1 | -4.81595 4.690143 -1.03 0.305 -14.02083 4.388927
------------------------------------------------------------------------------------

-xtreg- also drops a variable, but does fit the model and produce reasonable results:
. encode id, gen(ppn)

. xtreg factc i.onemonth c.mth i.exent i.predischarge#1.exent i.exent#(i.onemonth c.mth), i(ppn)
note: 1.exent omitted because of collinearity
[output omitted]

Today I am working on version 12.1 (updated this morning), but my do files all have a -version 11.2- command at the top. Tomorrow I will be back on my other computer, which runs version 11.2, and I'll see if the problem persists there.

Tim BP
lists@timbp.com

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index