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: How to combine ttest and regression estimates in one table


From   Amadou DIALLO <stata.diallo@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: How to combine ttest and regression estimates in one table
Date   Wed, 12 Feb 2014 10:12:17 +0100

Sergiy,
I've run your code and got the following:
. mata
------------------------------------------------- mata (type end to
exit) ---------------
:   b=xl()
                 <istmt>:  3499  xl() not found
r(3499);

:   b.create_book("Results","Sheet1")
type mismatch:  exp.exp:  transmorphic found where struct expected
r(3000);

:   b.put_string(1,1,"Variable")
type mismatch:  exp.exp:  transmorphic found where struct expected
r(3000);

:   b.put_string(1,2,"Coefficient")
type mismatch:  exp.exp:  transmorphic found where struct expected
r(3000);

:   b.put_string(1,3,"Test")
type mismatch:  exp.exp:  transmorphic found where struct expected
r(3000);

:
:   b.put_string(2,1,"weight")
type mismatch:  exp.exp:  transmorphic found where struct expected
r(3000);

:   b.put_string(3,1,"length")
type mismatch:  exp.exp:  transmorphic found where struct expected
r(3000);

:
:   b.put_number(2,2,0.654)
type mismatch:  exp.exp:  transmorphic found where struct expected
r(3000);

:   b.put_number(2,3,0.124)
type mismatch:  exp.exp:  transmorphic found where struct expected
r(3000);

:   b.put_number(3,2,0.434)
type mismatch:  exp.exp:  transmorphic found where struct expected
r(3000);

:   b.put_number(3,3,0.294)
type mismatch:  exp.exp:  transmorphic found where struct expected
r(3000);

: end
-----------------------------------------------------------------------------------------

.
end of do-file

.
What am I doing wrong?



2014-02-05 18:22 UTC+01:00, Evert Reins <revertlm.r1@gmail.com>:
> Hello Sergiy,
> thanks for your profound answer. I will use your advice concerning the
> illustration of tables in my further works in order to prevent any
> missunderstandings due to the different layouts of mail clients and
> browsers. Thank you! Furthermore, you really helped with the clue that
> estimates can be stored and used later on. That is what I was looking
> for. In the end, I conducted the table a bit differently than your
> suggestion, because I am somewhat more familiar with the -esttab-
> command.
> I used the following code:
>
> bysort State: eststo: reg earningsyear4 treatmnt avgunemployment
> avgminimumwage avggdptotal avggdprrate
>
> esttab est*  using estimates.csv, replace
>
> Then a little extra work in Excel had to be done in order to structure
> the table and make it understandable .
>
> Best,
> Evert
>
> 2014-02-05 Sergiy Radyakin <serjradyakin@gmail.com>:
>> Evert, Stata can write any results to Excel, but the layout it up to
>> you. Use the xl  class in Mata and with a couple of loops you should
>> be ok. Sergiy.
>> PS: either gmail or your mailer, or Stata itself is wrapping the lines
>> so heavily, it is not possible to recognize a table in your posting.
>> With long texts, it is safer to write:
>>
>> c11 c12 c13
>> c21 c22 c23
>> c31 c32 c33
>> ---------------------------------------------
>> c11="State"
>> c12="Regression coefficient"
>> c13="Impact of unemployment rate"
>> c21="Alabama"
>> ...
>> ---------------------------------------------
>> // Example code to write something to an XLS file:
>> sysuse auto
>> regress price weight length if foreign
>> regress price weight length if !foreign
>> // do whatever estimations and save the results from e() or r()
>> //.....
>> // output the results to Excel
>> mata
>>   b=xl()
>>   b.create_book("Results","Sheet1")
>>   b.put_string(1,1,"Variable")
>>   b.put_string(1,2,"Coefficient")
>>   b.put_string(1,3,"Test")
>>
>>   b.put_string(2,1,"weight")
>>   b.put_string(3,1,"length")
>>
>>   b.put_number(2,2,0.654)
>>   b.put_number(2,3,0.124)
>>   b.put_number(3,2,0.434)
>>   b.put_number(3,3,0.294)
>> end
>>
>> On Tue, Feb 4, 2014 at 4:52 PM, Evert Reins <revertlm.r1@gmail.com>
>> wrote:
>>> Dear Stata List users,
>>>
>>> I want to combine ttest and regression estimates in one table.
>>>
>>> I am currently working on my bachelor thesis in economics. In this
>>> regard,
>>> I conduct an analysis of the impact effects of "Job Corps" a program
>>> implemented by the DOL, which helps young people to find access to the
>>> labor market. Anyways, I am approaching the question, whether there is a
>>> correlation between the earnings of participants in the program and the
>>> economic situation in the state, where they live and work in. Therefore,
>>> I
>>> so far generated a data set which yields information about the earnings
>>> and
>>> state of residence, their belonging to the treatment (control)group
>>> (binary
>>> variable 0/1), plus key indicators for the economy of the state (minimum
>>> wage, unemployment rate, gdp growth rate...).
>>>
>>> Now I want to generate a table which shows the ttest values for
>>> difference
>>> in earnings for the treatment variable per participant (1st column)
>>> sorted
>>> by state combined with the regression outcomes for each indicator,
>>> regarding the earnings. To illustrate, it should look something like
>>> this:
>>>
>>>
>>>
>>> State                   difference in earnings                   impact
>>> of uenemployment rate               ....
>>>
>>> Alabama              difference in dollars
>>> regression
>>> coefficient (t-value)                ....
>>>
>>> Alaska
>>> -$152                                                    1.5677 (1.98)
>>>
>>> Thanks for your consideration
>>> *
>>> *   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/
>


-- 
Amadou B. DIALLO, PhD.
Senior Economist, AfDB.
a.b.diallo@afdb.org
+21671101789
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index