Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Using mkmat with a local as the varlist


From   Mauricio Esteban Cuak <cuak2000@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Using mkmat with a local as the varlist
Date   Fri, 8 Mar 2013 19:50:03 -0600

Thanks a lot!!!

2013/3/8 William Buchanan <william@williambuchanan.net>:
> Slight correction:
>
>> webuse hsng2
>> ivregress 2sls rent pcturban (hsngval = faminc region), small
>> ereturn li
>> loc instruments `e(insts)'
>> di `"`instruments'"'
> mkmat `instruments', matrix(B)
>
> Apparently -mkmat- does not like factor variables.
>
>
> On Mar 8, 2013, at 2:13 PM, William Buchanan <william@williambuchanan.net> wrote:
>
>> webuse hsng2
>> ivregress 2sls rent pcturban (hsngval = faminc i.region), small
>> ereturn li
>> loc instruments `e(insts)'
>> di `"`instruments'"'
>>
>> You weren't referencing the _macro_ where the variable names were stored correctly.
>>
>> HTH,
>> Billy
>>
>>
>> On Mar 8, 2013, at 2:05 PM, Mauricio Esteban Cuak <cuak2000@gmail.com> wrote:
>>
>>> Hi,
>>>
>>> I'm trying to save the lists of variables from a macro as an argument
>>> for the mkmat command.
>>> Here is an example of the use I'm trying to give:
>>>
>>> ******** Begin Code**************
>>>
>>> sysuse auto, replace
>>>
>>> foreach v of var * {
>>>      drop if missing(`v')
>>> }
>>>
>>> qui ivregress gmm price trunk (weight = turn length )
>>>
>>> /*  Now i'd like to construct a matrix with the instruments      */
>>>
>>> /* This works: */
>>>
>>> mkmat trunk turn length, matrix(A)
>>>
>>> /* But this doesn't:  */
>>>
>>> local instruments e(insts)
>>>
>>> mkmat `instruments', matrix(B)
>>>
>>>
>>> ***** End of code ********
>>>
>>> I've tried different ways to define the local but I haven't been able
>>> to make it work. I think the problem is mkmat takes `instruments' as a
>>> string and not as
>>> a list of variables, but I don't know how to fix it...
>>>
>>> Thanks for your time,
>>>
>>> M.C.
>>> *
>>> *   For searches and help try:
>>> *   http://www.stata.com/help.cgi?search
>>> *   http://www.stata.com/support/faqs/resources/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/faqs/resources/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/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index