[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Prefix commands and returned matrix results

From (Jeff Pitblado, StataCorp LP)
Subject   Re: st: Prefix commands and returned matrix results
Date   Tue, 27 May 2008 12:01:03 -0500

Roger Newson <> asks to questions about Stata's prefix
estimation commands.  I'll address Roger's questions in reverse order.

Question 2

Roger notes that -svy brr- doesn't currently work with -rclass- commands:

> Another query concerns the svy brr prefix. This seems to be able to
> access only e() results, and not r() results. Is this indeed the case?
> And is it by accident or by design? And, if it is by accident, then are
> there plans to fix it?

This is definitely an accident.  We have determined why -svy brr- isn't
working properly with -rclass- commands.  -svy jackknife- has a similar
problem.  Both of these commands will be fixed in a future ado-file update.

Question 1

Rogers first question relates to working with matrix results other than
regression coefficients and their standard errors (-_b- and -_se-):

> I have a query about Stata prefix commands (such as bootstrap:, statsby:
> and svy brr:) and returned matrix results. Based on the online help
> accessible by typing
> whelp exp_list
> there does not seem to be any way in which an expression list used by a
> prefix command can access elements of returned matrix results from the
> command that has been prefixed, except for the estimates stored in e(b)
> and the standard errors extracted from the diagonal of e(V). Is this
> indeed the case? And, if you want the numeric results from a command to
> be available to bootstrap:, statsby: and similar prefixes, do you have
> to return them in scalars? I ask because I have 2 commands cendif and
> censlope, which are part of the SSC package somersd, and they return
> confidence intervals for percentile slopes, differences or ratios in a
> matrix returned result r(cimat), in which the first column contains
> percents, the second column contains the estimates, and the third and
> fourth columns contain the lower and upper confidence limits,
> respectively. If I want users to be able to bootstrap: or statsby: these
> commands, accessing entries of those matrices, then must I also store
> these entries in scalars, similar to the r(c_#) results returned by the
> centile command in official Stata?

While -_b- and -_se- are the only syntax elements in -exp_list- for
conveniently dealing with elements from the matrices -e(b)- and -e(V)-,
Stata's -el()- matrix function can be used to pull elements from other
matrices; even other matrices in -r()- or -e()-.  Here is a simple example
using Roger's -cendif- command:

	. set seed 12345
	. sysuse auto
	. bootstrap diff=el(r(cimat),1,2) : cendif mpg, by(for)

*   For searches and help try:

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