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: Regression and Looping


From   Reese Andorfer <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Regression and Looping
Date   Sun, 2 Mar 2014 23:44:02 +0000

Hi Nick,

first of all thank you for the quick reply.
I tried the statsby command now unfortunately do I get only missing
values for a0 and a1 ....

and this is basically what I get once I execute the command:

Statsby groups
----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx    50
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx   100
xxxxxxxxxxxxxxxxxxxx

any idea what I could possibly do wrong here ?

Thank you again,
Best Reese

2014-03-02 23:20 GMT+00:00 Nick Cox <[email protected]>:
> This sounds confused. -ID- as e.g. "01Jan03" could not be the result
> of applying -string()- to a numeric variable unless you also specified
> a date format. In any case, if you have an integer date variable, it
> should not need conversion to string for this purpose.
>
> That said, this sounds like some misunderstanding of your data.
>
> I tend to use -statsby- for this kind of exercise. Here is a silly example:
>
> . webuse grunfeld, clear
>
> . statsby a0=_b[_cons] a1=_b[mvalue] , by(year) : regress invest mvalue
> (running regress on estimation sample)
>
> In your case it sounds as if you just should try
>
> statsby a0=_b[_cons] a1=_b[return_m] , by(dt) : regress return_p return_m
>
> Nick
> [email protected]
>
> On 2 March 2014 22:58, Reese Andorfer <[email protected]> wrote:
>
>> I have an industry portfolio with at the respective return return_p
>> and then I the return of the market portfolio return_m. My time period
>> is 10 years and I have the returns- on a monthly basis.
>>
>> Now I would like to perform the following regression : reg return_p
>> return_m for every month in my 10 year time period.
>>
>> I would like to save the constant as well as the beta coefficient for
>> return_m, thus I tried to use the following :
>>
>> gen ID=string( dt)
>>
>>
>> gen a0=.
>> gen a1=.
>>
>>
>> levelsof ID, local(x)
>> foreach obs of local x {
>> reg return_p return_m if ID=="`obs'"
>> replace a0=_b[_cons] if ID=="`obs'"
>> replace a1=_b[return_m] if ID=="`obs'"
>> }
>>
>>
>> whereby ID - is the date of the observation f.e. 01Jan03 in string form
>>
>> now I have no missing observations whatsoever and I get the error no
>> observations.
> *
> *   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index