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: st: AW: AW: Regressions with constant independent variable
From
Eric Booth <[email protected]>
To
[email protected]
Subject
Re: st: AW: AW: Regressions with constant independent variable
Date
Wed, 11 Apr 2012 07:41:31 -0500
<>
Hi Fabian:
You could change your current code to:
g first = .
forval n = 1/`=_N' {
bys cusip (fyear): replace first = lnsales[`n'] ///
if lnebit[`n']!=0 & mi(first)
}
to get those values.
- Eric
__
Eric A. Booth
Public Policy Research Institute
Texas A&M University
[email protected]
+979.845.6754
On Apr 11, 2012, at 4:45 AM, Fabian Schönenberger wrote:
> Many thanks! I have used:
> By cusip (fyear), sort: generate firstlnsales=lnsales[1] if (lnebit [1]
> !=0). This one works fine.
> However, I would like to adjust the formula, in order to get observation 2
> if lnebit [1] is 0, and then observation 3 if observation 2 is 0 and so on.
> Any suggestions?
>
> Best, Fabian
>
>
>
> -----Ursprüngliche Nachricht-----
> Von: [email protected]
> [mailto:[email protected]] Im Auftrag von Dithmer, Jan
> Gesendet: Mittwoch, 11. April 2012 10:49
> An: [email protected]
> Betreff: st: AW: Regressions with constant independent variable
>
> If you want to create a new variable, s.th like the following may work (if I
> understand you correctly):
>
> by cusip: gen salesinitial = sales if fyear=="first observation of fyear"
> by cusip: replace salesinitial = salesinitial[_n-1] if salesinitial==.
>
> It may be possible to do it in one step, but unfortunately I don't know how
> and would also be interested in a shorter solution.
>
> Best, Jan
>
> -----Ursprüngliche Nachricht-----
> Von: [email protected]
> [mailto:[email protected]] Im Auftrag von Fabian
> Schönenberger
> Gesendet: Wednesday, April 11, 2012 8:55 AM
> An: [email protected]
> Betreff: st: Regressions with constant independent variable
>
> Dear Statalist
> I would like to run a regression like Y=a + b*x + c*z + e for panel data. ID
> is cusip, and t is fyear, x is sales and z is growth of sales.
> I would like to keep x fixed for each cusip at the level of the first
> observation of fyear.
> Do I need to create a new variable or can I adjust my regression formula?
> Many thanks in advance.
>
> FS
>
> *
> * 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/
>
> *
> * 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/
>
>
> *
> * 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/
*
* 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/