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: Variable in bootstrap program not found


From   Stas Kolenikov <[email protected]>
To   [email protected]
Subject   Re: st: Variable in bootstrap program not found
Date   Thu, 3 Mar 2011 08:54:16 -0500

Carl,

-set trace on- and see what's going on.

If I were writing this program, I would write it with two generic
dependent variables and a varlist of regressors, so that there would
be no hard-coded variable names within the program itself:

program define whatever

   gettoken depvar1 rest : 0
   gettoken depvar2 rest : rest
   gettoken equals 0 : rest

   confirm numeric variable `depvar1'
   confirm numeric variable `depvar2'
   assert "`equals'" == "="
   syntax varlist, generate( name )

   regress `depvar1'
   predict `generate'
   poisson `depvar2' `varlist' `generate'
   drop `generate'

end

whatever cdmunicipio rendaactivities = stuff, generate( mun_res )

Besides, you don't have to return anything, as the -bootstrap- will
pick up the last estimated model. Also, the -bootstrap- will suppress
the output from your commands, which might be handy.

On Thu, Mar 3, 2011 at 8:01 AM, Nelson, Carl <[email protected]> wrote:
> I am writing a bootstrap to obtain standard errors after two-step estimation with a generated regressor. When I try to execute the program I receive the following error.
>
>  use full_inv, replace
> . capture program drop twostepseboot
> . program define twostepseboot, rclass
>  1. version 10
>  2.
> . quietly: reg cdmunicipio proprietrioa  posseiroa arrendatrioa assentadoapelo
>> pnra larea cooperativa associacao  ///
>> malet1 nmembrosdafamilia nempregadospermanentes literate secondary primary t
>> echnical superior
>  3. quietly: predict mun_res
>  4. quietly: poisson rendaactivities proprietrioa  posseiroa arrendatrioa ass
>> entadoapelopnra larea cooperativa  ///
>> associacao malet1 nmembrosdafamilia nempregadospermanentes literate secondar
>> y primary technical superior mun_res
>  5. quietly: local coeff  proprietrioa  posseiroa arrendatrioa assentadoapelo
>> pnra larea cooperativa  ///
>> associacao malet1 nmembrosdafamilia nempregadospermanentes literate secondar
>> y primary technical superior mun_res ///
>> _cons
>  6. foreach c of local coeff {
>  7.         scalar b`c' = _b[`c']
>  8.         return scalar bs`c' = b`c'
>  9. }
>  10. drop mun_res
>  11. end
>
> .
> . twostepseboot
> [technical] not found
> r(111);
> When I run the code through line 8 as a do file and add scalar list I see all the b`c' and bs`c' variables have been created, thus I am puzzled by the error message.
> And insight would be appreciated.
>
> Carl Nelson
> University of Illinois
>
> *
> *   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, also found at http://stas.kolenikov.name
Small print: I use this email account for mailing lists only.

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