Dear Statalisters,
I don't quite understand where my logic is wrong in the following example, but I would be happy if you could point that out:
I want to create a lagged variable and regress on that.
In the helpfile of the "time series operators" it says "For instance, L.gnp refers to the lagged value of variable gnp."
So what I take from this is that if I want to run a model with a lagged dependent variable I go with "regress variable L.variable"
However, creating a variable with "L.variable" this actually contains the lead of this variable?
*minimal working example
***************************************
sysuse uslifeexp, clear
keep if year < 1903
keep year le
tsset year
gen lead_le = F.le // operator meaning: F. lead (x_t+1)
gen lag_le = L.le // operator meaning: L. lag (x_t-1)
list
**************
=> output
+-----------------------------------------+
| year le lead_le lag_le |
|------------------------------------------|
1. | 1900 47.3 49.1 . |
2. | 1901 49.1 51.5 47.3 |
3. | 1902 51.5 . 49.1 |
***************************************
In the output above, the variable created with L.le contains the values of le in t+1 [and not t-1 as I expected]. Vice versa the variable F.le contains values of le in t-1 [which is the lag I want to use].
So what I take from this is that if I want to regress a variable on its value in t-1 I would have to use "regress variable F.variable"?
Am I going wrong here?
Thanks and best
Lukas
I don't quite understand where my logic is wrong in the following example, but I would be happy if you could point that out:
I want to create a lagged variable and regress on that.
In the helpfile of the "time series operators" it says "For instance, L.gnp refers to the lagged value of variable gnp."
So what I take from this is that if I want to run a model with a lagged dependent variable I go with "regress variable L.variable"
However, creating a variable with "L.variable" this actually contains the lead of this variable?
*minimal working example
***************************************
sysuse uslifeexp, clear
keep if year < 1903
keep year le
tsset year
gen lead_le = F.le // operator meaning: F. lead (x_t+1)
gen lag_le = L.le // operator meaning: L. lag (x_t-1)
list
**************
=> output
+-----------------------------------------+
| year le lead_le lag_le |
|------------------------------------------|
1. | 1900 47.3 49.1 . |
2. | 1901 49.1 51.5 47.3 |
3. | 1902 51.5 . 49.1 |
***************************************
In the output above, the variable created with L.le contains the values of le in t+1 [and not t-1 as I expected]. Vice versa the variable F.le contains values of le in t-1 [which is the lag I want to use].
So what I take from this is that if I want to regress a variable on its value in t-1 I would have to use "regress variable F.variable"?
Am I going wrong here?
Thanks and best
Lukas
Comment