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: name conflict in posting a matrix


From   Emmanouil Mentzakis <[email protected]>
To   [email protected]
Subject   Re: st: name conflict in posting a matrix
Date   Tue, 10 Jul 2012 15:11:15 +0100

Dear Nick,

Thank you for the response. You are right, the program is just an
example that doesn’t make sense but simply replicates the problem in
my actual program. In reality I am estimating a model with two
equations (with the same covariates) and I need to bootstrap it.

Hence, regress is not my estimation routine and the locals are there
to replicate what I have in my other model (where they are actually a
part of a previous calculation).

I think the problem is that I don’t tell -ereturn- correctly that I
have two equations with the same covariates (I try to rename them
using -matrix coleq-) and it therefore sees the same covariates names
appear multiple times, hence the name conflict. However, I often
models in Stata use the same covariates in multiple equations and
naming them with a prefix similar to eq1 etc.

Hope this provides a bit more info.

Thanks again

Regards
Manos


On Tue, Jul 10, 2012 at 2:23 PM, Nick Cox <[email protected]> wrote:
> What you are trying to do here is not clear. You are -bootstrap-ping
> _b which you can do directly, e.g .
>
> . bootstrap _b , reps(2) : regress mpg foreign, nocons
>
> You don't need to write a program to do that. Conversely, what is the
> point of the program? It just does the same estimation twice and you
> don't ask -bootstrap- to pay attention to its results.
>
> By the way, the stuff like
>
> local s1 = 1
> local s2 = 2
> local s3 = 3
>
> is pure indirection.  Your code can be simplified down to
>
> sysuse auto,clear
>
> cap prog drop ddd
> program ddd, eclass
>         tempname b1 b2 b3 betas
>         reg price foreign, nocons
>         mat `b1'=e(b)
>         matrix coleq `b1' = eq1
>
>         reg price foreign, nocons
>         mat `b2' =e(b)
>         matrix coleq `b2' = eq2
>
>         mat `b3'=1
>
>         mat `betas' = `b1', `b2', `b3'
>         ereturn post `betas'
> end
>
>
>
> On Mon, Jul 9, 2012 at 8:53 PM, Emmanouil Mentzakis
> <[email protected]> wrote:
>> Dear all,
>>
>> I am trying to -ereturn post- a matrix in order to bootstrap it but
>> get an error. I d be grateful if anyone could point to my mistake.
>> Below is an example.
>>
>> Thank you
>>
>> Regards
>> Manos
>>
>>
>> *** Example ***
>>
>> sysuse auto,clear
>>
>> cap prog drop ddd
>> program ddd, eclass
>>         tempname b1 b2 b3 betas
>>         reg price foreign, nocons
>>         local s1=1
>>         mat `b`s1''=e(b)
>>         matrix coleq `b`s1'' = eq`s1'
>>
>>         reg price foreign, nocons
>>         local s2=2
>>         mat `b`s2''=e(b)
>>         matrix coleq `b`s2'' = eq`s2'
>>
>>         local s3=3
>>         mat `b`s3''=1
>>
>>         mat `betas' = `b1', `b2', `b3'
>>         ereturn post `betas'
>> end
>>
>> bootstrap _b, reps(2): ddd
> *
> *   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