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]
Re: st: Program syntax for svy bootstrap or bs4rw
From
Mark McGovern <[email protected]>
To
[email protected]
Subject
Re: st: Program syntax for svy bootstrap or bs4rw
Date
Tue, 26 Jun 2012 14:57:45 -0400
Thanks Jeff and Stas, problem solved!
Mark
On Tue, Jun 26, 2012 at 12:36 PM, Stas Kolenikov <[email protected]> wrote:
> Oh, that was it. Mark can make his program somewhat more flexible with say
>
> syntax , first( varlist numeric ) second( varlist numeric )
>
> and then
>
> ...
> reg `first' [`weight'`exp'] if `touse'
> tempvar re
> predict `re', xb
> reg `second' `re' [`weight'`exp'] if `touse'
> ...
>
> within his program. That would kill enough birds with one stone. He
> would then call this program as
>
> svy : test1 , first( age race ) second( birthweight )
>
> which would contain some required options that -svy- would have to
> parse out and thus forced to make a real estimation call to -test1-.
>
> Going back a step or two, I don't see how the first regression
> produces random effect estimates, but I guess Mark just wanted a
> placeholder to demonstrate the two-step procedure.
>
> On Tue, Jun 26, 2012 at 11:11 AM, Jeffrey Pitblado <[email protected]> wrote:
>> Mark McGovern<[email protected]> asked a question about programming
>> syntax and using -svy bootstrap- or my -bs4rw- prefix command. Stas
>> Kolenikov
>> and Steve Samuels replied with several good suggestions, but Mark is still
>> having some trouble:
>>
>>
>>> Thank you Steve and Stas for your suggestions. For now I can work with
>>> bs4rw, although at some point I think I might need to use some of the
>>> functionality of svy, so I may have to return to this in the future.
>>>
>>> As you pointed out Steve, from the Stata 12 programming manual (p.326):
>>>
>>> 1. Command must be eclass and allow iweights and accept the standard
>>> estimation syntax.
>>> 2. Command must save the model coefficients and ancillary parameters
>>> in e(b) and the estimation sample size in e(N), and it must identify
>>> the estimation subsample in e(sample);
>>> 3. svy’s vce(bootstrap), vce(brr), and vce(sdr) require that command
>>> have svyb as a property.
>>>
>>> I thought these were satisfied as the original code below does return
>>> results in e() in the usual way from "regress". For example,
>>> specifically overwriting e() does not help as in the below.
>>
>>
>> Here is Mark's code:
>>
>>
>>> capture program drop test1
>>> program define test1, eclass properties(svyb)
>>> syntax [if] [in] [pw iw]
>>> marksample touse
>>> tempvar b V
>>> qui xi:reg age race [`weight'`exp'] if `touse'
>>> capture drop re1
>>> predict re1
>>> qui xi:reg birthwgt re1 [`weight'`exp'] if `touse'
>>> local nobs = e(N)
>>> matrix `b' = e(b)
>>> matrix `V' = e(V)
>>> ereturn post `b' `V', esample(`touse')
>>> ereturn local cmd="test1"
>>> ereturn scalar N = `nobs'
>>> ereturn display
>>> end
>>>
>>> svy : test1
>>
>>
>> The problem here is that
>>
>> . svy : test1
>>
>> looks like a replay call to -svy-. Mark put all the model specfication
>> information in the -test1- program. Mark can add something to the syntax
>> to -test1- that will prevent -svy- from trying to replay nonexistent
>> results.
>> I would suggest
>>
>> . svy : test1 in 1/l
>>
>> -- Jeff Pitblado
>> [email protected]
>>
>>
>> *
>> * 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/
>
>
>
> --
> ---- Stas Kolenikov
> -- http://stas.kolenikov.name
> ---- Senior Survey Statistician, Abt SRBI
> -- Opinions stated in this email are mine only, and do not reflect the
> position of my employer
>
> *
> * 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/