Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: suest for intreg


From   vwiggins@stata.com (Vince Wiggins, StataCorp)
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: suest for intreg
Date   Sat, 31 Dec 2005 10:56:26 -0600

Bart Vanneste <bvanneste.phd2004@london.edu> asks,

> Is it possible to use suest for intreg when some of the intervals
> are not bounded (i.e. < -&#8734; , a] or [b, &#8734; > )?
>
> I am trying to test differences in coefficients across two intreg
> models. In both models I have censored data, i.e. only a maximum or
> minimum value is specified.
>
> When using suest I get the following error message:  Score variables
> for model X contain missing values
>
> Even though suest seems possible when using intreg, see example:
> http://www.stata.com/help.cgi?suest
>
> suest requires the predict, score option to give non-missing values,
> so I guess that's where it goes wrong. [...]

This is indeed a bug in -predict- after -intreg- and, as Bart surmised, it
occurs whenever any of the intervals is unbounded (specified by a missing
value).  In such cases, -predict- sets the scores to missing.  It shouldn't.

This will be fixed in the next ado update, which I expect out during the
second week of January.

Working around this is rather tricky.  I have provided two little ado files
below my signature that should do what's needed.  They are not heavily tested,
but worked for my test case and I believe they handle all syntax options.
Bart will need to copy these to his PERSONAL directory on his ado path (type
-adopath- to find this directory).

Bart will then need to use the command -intregscr- in place of -intreg-, and
he will need to add the option -sc(<name>)- to each model he wishes to supply
to -suest-.  <name> should be replaced with a valid Stata name (less than 28
characters) and the name must be different for each estimation that Bart
wishes to compare.  For example,

      . intregscr y1 y2 x1s ... , ... sc(mod1)
      . est store one

      . intregscr y1 y2 x2s ... , ... sc(mod2)
      . est store two

      . suest one two

The supplied ado files are poster children for the term "kludge", so don't
look too closely under the hood and switch back to -intreg- quickly after the
next ado update.

 
-- Vince
   vwiggins@stata.com

---------------------------------- BEGIN --- intregscr.ado --- CUT HERE -------
*! version 1.0.0  30dec2005

program intregscr, eclass
	
	syntax [varlist] [if] [in] [aw fw iw pw] [, SCores(string) *]

	if ("`weight'" != "")  local wgt "[`weight'`exp']"

	capture drop _`scores'_*
	intreg `varlist' `if' `in' `wgt', `options' score(_`scores'_*)

	ereturn local predict   "intregscrprd"
	ereturn local scorestub "_`scores'_"
end
----------------------------------   END --- intregscr.ado --- CUT HERE -------

---------------------------------- BEGIN --- intregscrprd.ado --- CUT HERE ----
*! version 1.0.0  30dec2005

program intregscrprd
	syntax [anything] [if] [in] [, SCores *]

	if "`scores'" == "" {
		intreg_p `anything' `if' `in', `options'
		exit
	}

	local stub : subinstr local anything "*" ""
	gen `stub'1 = `e(scorestub)'1 `if' `in'
	gen `stub'2 = `e(scorestub)'2 `if' `in'
end
----------------------------------   END --- intregscrprd.ado --- CUT HERE ----

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



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index