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

Re: st: Problems with -bs- command


From   Gary Longton <[email protected]>
To   [email protected]
Subject   Re: st: Problems with -bs- command
Date   Wed, 07 Aug 2002 10:47:41 -0700

Paul Seed wrote:

I am interested in a bootstrapped confidence interval for the
difference between two means, and to save time
wish to work out the means using -summ, meanonly-.

I have written a Stata program to do this, which runs perfectly well
on it's own.  However, when trying to get -bs- to work out the confidence
intervals, I get an unexplained error message.

Any thoughts on wher ethe problem lies, greatly appreciated.

the program:

cap prog drop myprog
prog define myprog, rclass
	summ centile if aps, mean
	di "r(mean) = " r(mean)
	local m1 = r(mean)
	return local m1 = r(mean)
	summ centile if control, mean
	return local m2 = r(mean)
	return local m2_m1 = `m1' - r(mean)
end myprog

called with -bs-


	set seed 35435141
	bs "myprog" "r(m1)", reps(50)

or

> 	bs "myprog" "r(m1) r(m2) r(m2_m1)", reps(50)


and output:

. * Now use it for bootstrap"
.         set seed 35435141

.         bs "myprog" "r(m1) r(m2) r(m2_m1)", reps(50)

command:     myprog
statistics:  r(m1) r(m2) r(m2_m1)
error in statistic: r(m1)
r(198);
I believe the -bs- command is complaining about the use of macro results placed in the expression list, i.e. "r(m1)"

It should work if these are instead scalar results. Eg. in the program -myprog-, replace

return local m1 = r(mean)

with

return scalar m1 = r(mean)
^^^^^^

and likewise for m2, and m2_m1
and it should work.

However, am wondering whether this type of sampling is best for your design? The command

> summ centile if control, mean

hints that this might be a case-control design?, in which case you might want to be sampling separately from cases and controls? which can be done, but not with -bs-.

- Gary







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