# AW: st: question about rolling regression and nlcom

 From "Nadine Kalwey" To "Kit Baum" Subject AW: st: question about rolling regression and nlcom Date Mon, 13 Oct 2008 10:53:33 +0200

```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]
end

executed it with

use emerging, clear

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

What have I done wrong?

Thanks again

-----Ursprüngliche Nachricht-----
Von: Kit Baum [mailto:baum@bc.edu]
Gesendet: Samstag, 11. Oktober 2008 17:00
Cc: statalist@hsphsun2.harvard.edu
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
>
> occurred when rolling executed roll, r(111)".
>
> It would be great if you could help me with that!
>
>
> Best regards
>
> **********************************
> 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