Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

Re: Re: st: RE: rolling regression and hypothesis testing

From   Nat Tharnpanich <>
Subject   Re: Re: st: RE: rolling regression and hypothesis testing
Date   06 Apr 2011 13:45:36 +0100

Dear Kit,
Thank you very much for this amazing program code. I am very grateful of your help. I will have a look at it and I am sure this will help me learn a lot about Stata programming. Best, Nat On Apr 6 2011, Christopher Baum wrote:

<> This should come close. Haven't had my morning caffeine fix yet, so it may need a little work. But I think the concept does what you need.

prog drop _all
prog testroll, rclass
reg investment income consumption
scalar lnow = linvestment[$inow]
global inow = $inow + 1
test income = lnow
ret sca f = r(F)
ret sca p = r(p)
ret sca inow = $inow
ret sca lnow = lnow

webuse lutkepohl,clear
global inow 20
ret li

global inow 20
rolling f=r(f) p=r(p) inow=r(inow) lnow=r(lnow) in 21/l, w(12): testroll


On Apr 6, 2011, at 2:33 AM, Nat wrote:

I have been trying to write the program that -rolling- can call in order to do regression and hypothesis testing in one go. However, I am having a problem in the hypothesis testing part as I want to test the significance of the difference between an estimated coefficient and a variable, say, Z which takes on a value that differs by year. So I have rolling windows(20) clear, progname and the program is as follows, program progname
  reg Yt X1t X2t
  test X1t = Zt
  gen p = r(p) // to generate a variable for p values
  gen f = r(F) // to generate a variable for F statistics
end and t is year. If Zt is a constant, then presumably my program would
work fine. However, since the value of Zt varies from from year to year,
Stata interprets Zt as one of the regressors which is always not found
because -rolling- command will not keep Zt when it is executed. I have
spent all day and night to figure out how to write the correct code, but
still completely clueless. I would greatly appreciate any advice on this.

Kit Baum | Boston College Economics & DIW Berlin | An Introduction to Stata Programming | An Introduction to Modern Econometrics Using Stata |

*   For searches and help try:

Nat Tharnpanich
Downing College and Department of Land Economy
University of Cambridge

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index