Bookmark and Share

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: xtmixed variance functions


From   "Feiveson, Alan H. (JSC-SK311)" <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: RE: xtmixed variance functions
Date   Tue, 8 Mar 2011 08:31:02 -0600

Leslie - I don't know if this is what you're asking, but you can model the lowest-level variance in -xtmixed- by introducing the observation number as an artificial "level" e.g.

Suppose this is my original analysis:
. xtmixed y5 post ||isub: ,nolog

Mixed-effects REML regression                   Number of obs      =        48
Group variable: isub                            Number of groups   =        24

                                                Obs per group: min =         2
                                                               avg =       2.0
                                                               max =         2


                                                Wald chi2(1)       =     26.09
Log restricted-likelihood = -206.45646          Prob > chi2        =    0.0000

------------------------------------------------------------------------------
          y5 |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        post |  -20.22917   3.960537    -5.11   0.000    -27.99168   -12.46666
       _cons |   102.9958    4.68471    21.99   0.000     93.81397    112.1777
------------------------------------------------------------------------------

------------------------------------------------------------------------------
  Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
-----------------------------+------------------------------------------------
isub: Identity               |
                   sd(_cons) |   18.39799   3.547973      12.60723    26.84856
-----------------------------+------------------------------------------------
                sd(Residual) |    13.7197   2.022859      10.27642    18.31671
------------------------------------------------------------------------------
LR test vs. linear regression: chibar2(01) =    12.25 Prob >= chibar2 = 0.0002


But I want to model the residual variance as a function of a variable x - so now I introduce a new "level" that is just the observation number:

. gen ord = _n  // (my artificial new level)
. xtmixed y5 post ||isub: ||ord: x,noc nolog

Mixed-effects REML regression                   Number of obs      =        48

-----------------------------------------------------------
                |   No. of       Observations per Group
 Group Variable |   Groups    Minimum    Average    Maximum
----------------+------------------------------------------
           isub |       24          2        2.0          2
            ord |       48          1        1.0          1
-----------------------------------------------------------

                                                Wald chi2(1)       =     29.89
Log restricted-likelihood = -205.91786          Prob > chi2        =    0.0000

------------------------------------------------------------------------------
          y5 |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        post |   -21.0016   3.841315    -5.47   0.000    -28.53044   -13.47276
       _cons |   102.7677   4.689839    21.91   0.000     93.57579    111.9596
------------------------------------------------------------------------------

------------------------------------------------------------------------------
  Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
-----------------------------+------------------------------------------------
isub: Identity               |
                   sd(_cons) |   18.14146   3.553234      12.35815     26.6312
-----------------------------+------------------------------------------------
ord: Identity                |
                       sd(x) |   1.092523   .1624449      .8163333    1.462157
-----------------------------+------------------------------------------------
                sd(Residual) |   .0291567   .0633542      .0004123    2.062069
------------------------------------------------------------------------------
LR test vs. linear regression:       chi2(2) =    13.33   Prob > chi2 = 0.0013

Note: LR test is conservative and provided only for reference.


Hope this helps

Al Feiveson






-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Leslie Roche
Sent: Monday, March 07, 2011 2:12 PM
To: [email protected]
Subject: st: xtmixed variance functions

Hi All,
I have been trying to figure out how to specify a variance function in
Stata for within-group heteroscedasticity. I have run into this
problem a few times. Basically, my residuals by predicted plot show a
classic increase in variance. Even though the various residual plots
looked fine, I have tried residuals(independent, by(id)), and
residuals(independent, by(x category)), but none of these worked. The
other residuals options available require a time variable, which I do
not have.

In S-plus (and R), the function I generally use to model this type of
heteroscedasticity is "weights=varPower())". Here, the default
covariate is  ~fitted. Is there a similar function in Stata that is
available outside the base commands? I would prefer not to have to
transform the response variable. Any suggestions much appreciated.

Thanks,
Leslie

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

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


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index