Bookmark and Share

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]

st: svy bootstrap


From   "Michael Palmer" <[email protected]>
To   <[email protected]>
Subject   st: svy bootstrap
Date   Mon, 7 Mar 2011 14:20:26 +1100

Dear Statalist, 

I am trying to bootstrap standard errors in a two-part model using
complex survey data. The first model is a logit and the second a log
linear model of expenditures. From the below do file I get the following
error message. Any help is greatly appreciated.  

 bsweights bsw, reps(40) n(-1)
 svyset [pweight=psindwt], strata(domain) psu(commcode) vce(bootstrap)
bsrweight(bsw*)

      pweight: psindwt
          VCE: bootstrap
          MSE: off
    bsrweight: bsw1 bsw2 bsw3 bsw4 bsw5 bsw6 bsw7 bsw8 bsw9 bsw10 bsw11
bsw12
               bsw13 bsw14 bsw15 bsw16 bsw17 bsw18 bsw19 bsw20 bsw21
bsw22
               bsw23 bsw24 bsw25 bsw26 bsw27 bsw28 bsw29 bsw30 bsw31
bsw32
               bsw33 bsw34 bsw35 bsw36 bsw37 bsw38 bsw39 bsw40
  Single unit: missing
     Strata 1: domain
         SU 1: commcode
        FPC 1: <zero>

. svy: mean r(prod2) 
(running mean on estimation sample)
factor variables and time-series operators not allowed
an error occurred when bootstrap executed mean
r(101);

Full do file: 

**** TPM

capture program drop twopart
program twopart, rclass
tempname sm1 sm0 m_1 m_2 m_3 m_4 
tempvar pr_y yhat ehat smear smear_ins sm1 smear_noins sm2 yhat_duan
yhat_pwd1 yhat_pwd0 y_pwd1 y_pwd0 
logit inpat_public $xlist1 if age > 5
predict `pr_y', pr
reg ipexp_public_log $xlist1 if age > 5 & inpat_public==1  
predict `yhat', xb
predict `ehat', residuals

egen `smear_ins' = mean(exp(`ehat')) if insurance==1
summ `smear_ins'
scalar `sm1' = r(max)
egen `smear_noins' = mean(exp(`ehat')) if insurance==0
summ `smear_noins'
scalar `sm0' = r(max)
gen `yhat_duan' = exp(`yhat')*`sm1' if insurance==1
replace `yhat_duan' = exp(`yhat')*`sm0' if insurance==0

gen `yhat_pwd1' = `yhat_duan' if pwd==1
mean `yhat_pwd1'
scalar `m_1' = _b[`yhat_pwd1']
gen `yhat_pwd0' = `yhat_duan' if pwd==0
mean `yhat_pwd0' 
scalar `m_2' = _b[`yhat_pwd0']
gen `y_pwd1' = `pr_y' if pwd==1
mean `y_pwd1'
scalar `m_3' = _b[`y_pwd1']
gen `y_pwd0' = `pr_y' if pwd==0
mean `y_pwd0'
scalar `m_4' = _b[`y_pwd0']

return scalar prod2 = `m_1'*`m_3' - `m_2'*`m_4'
end

twopart
return list
bsweights bsw, reps(40) n(-1)
svyset [pweight=psindwt], strata(domain) psu(commcode) vce(bootstrap)
bsrweight(bsw*)
svy: mean r(prod2) 


Best regards, 

Michael Palmer
PhD Candidate 
National Centre for Epidemiology and Population Health 
The Australian National University 
Ph. 6125 0538
M. 0437 867 940

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Maarten buis
Sent: Thursday, 3 February 2011 2:19 AM
To: [email protected]
Subject: RE: st: FW: Marginal effects for the two-part model

--- On Wed, 2/2/11, Maarten buis wrote:
> The difference between that and your two-part model is that in that 
> model the dependence is included by deriving the inverse Mill's ratio 
> from the selection model, add it to the OLS model, and adjust the 
> standard errors.

Nick is in a pedantic mood today(*). He correctly pointed out to me
privately that it is Mills' ratio and not Mill's ratio. (And the moment
he told me, I remembered that he made that point before, and at that
time I made a mental note not to make that mistake...
<http://www.stata.com/statalist/archive/2008-02/msg00945.html>)

-- Maarten

(*) but see the entry on pedantry in this glossary:
<http://www.stata.com/statalist/archive/2011-01/msg00003.html>

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl
--------------------------


      

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


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index