Statalist


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

Fwd: AW: st: question about rolling regression and nlcom


From   Kit Baum <[email protected]>
To   [email protected]
Subject   Fwd: AW: st: question about rolling regression and nlcom
Date   Mon, 13 Oct 2008 08:25:26 -0400


From: Kit Baum <[email protected]>
Date: October 13, 2008 7:32:26 AM EDT
To: "Nadine Kalwey" <[email protected]>
Subject: Re: AW: st: question about rolling regression and nlcom

Use scalars, not locals. -rolling- wants numbers, not strings.

prog drop _all

program roll, rclass
version 9.2
syntax varlist(ts) if
regress `varlist' `if'
nlcom _b[l.income]/_b[l.consumption]
mat nadineb = r(b)
return scalar lnadineb = nadineb[1,1]
mat nadinev = r(V)
return scalar lnadinev = nadinev[1,1]
end

rolling lnadineb=r(lnadineb) ladinev=r(lnadinev), window(10) ///
saving(nadine2,replace): roll d.income l.income l.consumption if tin(1960q4,)


Kit Baum, Boston College Economics and DIW Berlin
http://ideas.repec.org/e/pba1.html
An Introduction to Modern Econometrics Using Stata:
http://www.stata-press.com/books/imeus.html


On Oct 13, 2008, at 04:53 , Nadine Kalwey wrote:


Thank you, Kit, for your help.

I wrote the program as follows:

program roll, rclass
version 9.2
syntax varlist(ts) if
regress `varlist' `if'
nlcom _b[l.mmr]/_b[l.lr]
mat nadineb = r(b)
local localnadineb = nadineb[1,1]
return local lnadineb =`localnadineb'
mat nadinev = r(V)
local localnadinev = nadinev[1,1]
return local lnadinev =`localnadinev'
end

executed it with

use emerging, clear

rolling lnadineb= r(localnadineb) ladinev= r(localnadinev), window(60) saving(nadine2,replace): roll d.lr l(1/2)d.lr l(0/3)d.mmr l.lr l.mmr if
country ==4

Now, it is running "roll" on the estimation sample but without producing any
estimates:

Rolling replications (265)
1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
xxxxxxxxxxxxxxxxxxxeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee	50
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee	100
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee	150
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee	200
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee	250
eeeeeeeeeeeeeee
file nadine2.dta saved

What have I done wrong?

Thanks again
Nadine

-----Ursprüngliche Nachricht-----
Von: Kit Baum [mailto:[email protected]]
Gesendet: Samstag, 11. Oktober 2008 17:00
An: Nadine Kalwey
Cc: [email protected]
Betreff: Re: st: question about rolling regression and nlcom


< >
You can't return a matrix as a local.


matrices:
                 r(b) :  1 x 1
                 r(V) :  1 x 1

. local junk `r(b)'

. di "`junk'"
matrix

You also must move r(b), r(V) to new matrices before you can refer to
their elements (as with e(b), E(V)).
You could extract the [1,1] element of r(b) and the [1,1] element of
r(V) and save them as locals and return them.

. mat b = r(b)

. local elt = b[1,1]

. di "`elt'"
.0000498711997947

etc.

Kit Baum, Boston College Economics and DIW Berlin
http://ideas.repec.org/e/pba1.html
An Introduction to Modern Econometrics Using Stata:
http://www.stata-press.com/books/imeus.html


On Oct 11, 2008, at 09:51 , Nadine Kalwey wrote:

Dear Kit,

I have some problems obtaining standard errors from nonlinear
combinations
of estimators after running a rolling regression. In July 2007, in the context of "rolling" and "lincom" you suggested to someone to write a
'wrapper' program. I tried to do the same for 'nlcom':

program roll, rclass
version 9.2
syntax varlist(ts) if
regress `varlist' `if'
nlcom -(_b[l.mmr]/_b[l.lr])
return local b =`r(b)'
return local v =`r(V)'
end

and then try to execute the program with:
use emerging, clear

rolling b=r(b) v=r(V), window(60) saving(nadine, replace): roll lrd
l(1/2).lrd l(0/3).mmrd l.lr l.mmr  if country ==4

Unfortunately, I receive the error message "matrix not found, an error
occurred when rolling executed roll, r(111)".

It would be great if you could help me with that!

Thanks for your time,

Best regards
Nadine

**********************************
Nadine Kalwey
University of Cologne
Department of Economic Policy

Wiso-Hochhaus, Room 731a
Albertus-Magnus Platz
D-50923 Köln

PHONE: +49 (0)221 470-2378
FAX: +49 (0)221 470-5188
email: [email protected]






*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index