Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

st: difficulties with running own ado.filedue to lagged variables


From   "Catharina Klepsch" <Catharina.Klepsch@gmx.de>
To   statalist@hsphsun2.harvard.edu
Subject   st: difficulties with running own ado.filedue to lagged variables
Date   Fri, 09 Jul 2010 12:41:15 +0200

Dear Stata Users,

I am using Stata Version 11.0 and I have a problem concerning the use of lagged dependend variables under certain constraints.

Regression looks like this:
abc y x1 x2 zx1 zx2 with abc beeing a command of an ado.file

zx1 gives the mean variable of the dependet variables x1, it first will be calculated automatically and than be used in the regression. Therefor I wrote a program, which calculates the mean of all dependent variables I use in the regression. 

(here an abstract:)

tokenize `varlist'
local first "`1'"
macro shift
local rest "`*'"

foreach x of local rest {
by `panelvar', sort: egen z`x' = mean(`x')

Now I need a command how to get lagged variables of x1 and x2 but just if i wish to do this, depending on the structure of the dataset!

The whole program should be implemented as an ado.file.

I already checked the ado.files of xtabond / xtdpd which does similar things with lagged variables but i really don't know hot wo implement this exactly.

I tried something like this :

	tempvar lag stouse 
	qui by `panelvar': gen `stouse' = `rest'
	qui gen `lag' = (L.`stouse'!=`stouse'[_n-1])


or this: 

foreach x of local rest{
*by `panelvar': generate lag`x' = `x'[_n-1]
*}

But both didn't work.

At the end of the ado.file program is:

regress `first'  `rest' z*; whereas `rest' shall than be lagged or not depending on whether I have typed 
abc y x1 x2 zx1 zx2 or abc y l.x1 l.x2 zx1 zx2

So if anyone of you has an idea how I could get this fixed that would be fantastic.

Thanks a lot in advance for your support!

Best regards
Catharina 




-- 
GMX DSL: Internet-, Telefon- und Handy-Flat ab 19,99 EUR/mtl.  
Bis zu 150 EUR Startguthaben inklusive! http://portal.gmx.net/de/go/dsl
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index