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: Re: st: RE: rolling regression and hypothesis testing


From   Nat Tharnpanich <[email protected]>
To   [email protected]
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
end

webuse lutkepohl,clear
global inow 20
testroll
ret li

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

Kit

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 | http://ideas.repec.org/e/pba1.html An Introduction to Stata Programming | http://www.stata-press.com/books/isp.html An Introduction to Modern Econometrics Using Stata | http://www.stata-press.com/books/imeus.html




*
*   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/


--
Nat Tharnpanich
Downing College and Department of Land Economy
University of Cambridge
CB2 1DQ
[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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index