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]

Re: st: svy bootstrap


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: svy bootstrap
Date   Thu, 10 Mar 2011 09:13:34 +0000

As advised before, use -set trace- to see where the error occurs.

Note that your invocations of  `if' will do nothing. You never define
any local macro -if- either directly or indirectly through -syntax-.

Similar comment for `typlist'. Empty because never defined.

Your -summ- calls name `exp' but if you want these -summarize-s to use
weights you need to use the [pw=exp] syntax just as in other commands.

I didn't read to the end.

Nick

On Thu, Mar 10, 2011 at 2:13 AM, Michael Palmer
<[email protected]> wrote:
> Thanks so much for your reply. I went ahead with the suggested code in the single program.
> However, I was met with the error message: '=unknown weight type'.
>
> The revised do file is:
>
> capture program drop twopart
> program twopart, rclass
> tempname sm1 sm0 smear prob 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
> syntax [pweight /]
> logit inpat_public $xlist1 if age > 5 [`weight'=`exp']
> predict `pr_y', pr
> reg ipexp_public_log $xlist1 if age > 5 & inpat_public==1 [`weight'=`exp']
> predict `yhat', xb
> predict `ehat', residuals
>
> egen `smear_ins' = mean(exp(`ehat')) if insurance==1  [`weight'=`exp']
> summ `smear_ins' `typlist' `if' `exp'
> scalar `sm1' = r(max)
> egen `smear_noins' = mean(exp(`ehat')) if insurance==0 [`weight'=`exp']
> summ `smear_noins' `typlist' `if' `exp'
> scalar `sm0' = r(max)
> gen `yhat_duan' = exp(`yhat')*`sm1' if insurance==1
> replace `yhat_duan' = exp(`yhat')*`sm0' if insurance==0
> mean `yhat_duan'
> scalar `smear' = _b[`yhat_duan']
> mean `pr_y'
> scalar `prob' = _b[`pr_y']
>
> gen `yhat_pwd1' = `yhat_duan' if pwd==1
> mean `yhat_pwd1' [`weight'=`exp']
> scalar `m_1' = _b[`yhat_pwd1']
> gen `yhat_pwd0' = `yhat_duan' if pwd==0
> mean `yhat_pwd0' [`weight'=`exp']
> scalar `m_2' = _b[`yhat_pwd0']
> gen `y_pwd1' = `pr_y' if pwd==1
> mean `y_pwd1' [`weight'=`exp']
> scalar `m_3' = _b[`y_pwd1']
> gen `y_pwd0' = `pr_y' if pwd==0
> mean `y_pwd0' [`weight'=`exp']
> scalar `m_4' = _b[`y_pwd0']
>
> return scalar bpwd = `m_1'*`m_3' - `m_2'*`m_4'
>
> end
>
> set more off
> twopart
> return list
> bsweights bsw, reps(100) n(-1)
> bs4rw (bpwd=r(pwd)), rw(bsw*): twopart [pw=psindwt]
>

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