# Re: st: xttobit

 From Sophia Rabe-Hesketh To statalist@hsphsun2.harvard.edu Subject Re: st: xttobit Date Sun, 29 Feb 2004 21:26:24 -0800

```Matt,

I suggest first running xttobit and using
the estimates as starting values for gllamm.
For the example command you gave in your email,
the data manipulation and gllamm command would be:

xttobit zteq `vars', ll(0) ul(100) i(sys_id)

* create a new dependent variable equal to 1 if right-censored
* and 0 if left-censored:

gen y=cond(zteq>=100,1,cond(zteq<=0,0,zteq)) if zteq<.

* create offset variable equal to -100 if right-censored at
* 100, 0 otherwise:

gen off = cond(zteq>=100,-100,0)

* create var=2 for censored observations, 1 otherwise:

gen var=cond(zteq>=100|zteq<=0,2,1)

* get starting values from xttobit (last two elements, /sigma_u
* and /sigma_e need to be switched and need logarithm of /sigma_e:

matrix a=e(b)
local n=colsof(a)
matrix a[1,`n']=a[1,`n'-1]
matrix a[1,`n'-1]=ln(a[1,`n'])

gllamm y `vars', offset(off) i(sys_id) fam(gauss binom) link(ident sprobit)  /*
*/ lv(var) fv(var) from(a) copy adapt

The default number of quadrature points gllamm uses is 8
(which may be more accurate than 12 with ordinary quadrature).
You may have to increase this using nip(20), etc.
(perhaps do a kind of quadcheck manually).

Please let me know if you have any problems.

Best wishes,

Sophia

Matt Dobra wrote:
```
Sophia,

In general, with the default 12 quadratures, most of my estimated betas have a relative difference of between 1-4%, and a few are estimated with a very high relative difference, sometimes over 50%. I presume that I am running into this problem because some of my independent variables are time-invariant within groups. .

Thanks for offering to help me with this. There are actually 30 regressions I want to run...10 different dependent variables, each with three different sets of independent variables, captured in a macro called `vars'. Any guidance you could give me in how to generally set up a random effects tobit using gllamm would be greatly appreciated.

The general form of all of the random effects tobits I want to run is:
xttobit zteq `vars', ll(0) ul(100) i(sys_id)

Each of the dependent variables has a name starting with the letter "z" (e.g. zteq, zdeq, zieq), so for simplicity, I could do the data manipulation within a loop like:

. foreach var of varlist z* {
. stuff
. }

Matt

Sophia Rabe-Hesketh wrote:

```Matt,

If the estimates seem robust with 30 quadrature points,
why not use 30?

However, if you are not sure that the estimates are robust,
gllamm (see http://www.gllamm.org). In situations where
to be more reliable, see e.g.

Rabe-Hesketh, S., Skrondal, A. and Pickles, A. (2002).
Reliable estimation of generalised linear mixed models

However, estimating random effects tobit models in gllamm
is a bit involved. You have to treat the data as if you
had mixed responses and specify a linear model for the
non-censored responses and a scaled probit model for the
censored responses (with the same residual variance).
If you send me the xttobit command that you used,
I can send you the corresponding gllamm command
(and data manipulation steps).

Sophia

Matthew L Dobra wrote:

```
Statalisters,

Any advice you can give me would be appreciated. I have some data that
seems appropriate for xttobit analysis. My LHS variables are bounded
between 0 and 100 (percentages), and an unbalanced panel of approximately
300 i's and 4 t's. I used the quadchk command and found that my
estimates were quite sensitive to my choice of quadratures. I played
around with the quadrature option on xttobit, and found that only when I
estimates were robust. So, I'm resigned to think that Stata's xttobit
command may not be the best option.

Moving on, I'm curious as to what I might do from here. Are there other
commands that might help me out? Has somebody written a version of
xttobit that uses a different method of approximation?

Matt

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
```
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```
```

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```
```--
Sophia Rabe-Hesketh, Professor
Educational Statistics
3659 Tolman Hall
University of California, Berkeley
Berkeley, CA 94720-1670
WWW: http://www.gllamm.org/sophia.html
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```