全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件
36380 21
2006-04-30
<P>刚使用stata不久,在利用stata软件做分析中,如果我有一个变量是gdp的话,那么我想产生该变量的一阶滞后变量Lag_gdp,那么我可以采用如下命令:<BR><STRONG>gen Lag_gdp= L.gdp</STRONG></P>
<P>那么,我要产生gdp的二阶,三阶滞后变量如何些命令呢,请知道的高手指教啊</P>
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2006-4-30 07:50:00
How do I create a lag variable?
Title Stata 5: Creating lagged variables
Author James Hardin, StataCorp
Date January 1996

Create lag (or lead) variables using subscripts.
 . gen lag1 = x[_n-1] . gen lag2 = x[_n-2] . gen lead1 = x[_n+1] 

You can create lag (or lead) variables for different subgroups using the by prefix. For example,

 . sort state year . by state: gen lag1 = x[_n-1] 
If there may be gaps in your records and you only want to lag successive years, you can specify
 . sort state year . by state: gen lag1 = x[_n-1] if year==year[_n-1]+1 

See [R] egen for details on creating variables of moving averages.

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2006-4-30 07:53:00

I am trying to create a lag variable

y(t) = x(t-1)
I searched for a lag function but could not find. Any suggestions?

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2006-4-30 07:54:00
以下是引用Trevor在2006-4-30 7:53:00的发言:

I am trying to create a lag variable

y(t) = x(t-1)
I searched for a lag function but could not find. Any suggestions?

In addition to other suggestions, this
raises the question of how you are
searching.

A literal

. search lag function

does point to several sources on information.
However, as Kit Baum pointed out if your
data are time series then using -tsset- is
preferable to subscripting (e.g. using [_n-1]).

Nick
n.j.cox@durham.ac.uk

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2007-9-29 19:59:00

好帖子,俺也在愁这个问题,现在终于解决啦

感谢楼上的兄弟!

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2008-11-30 10:53:00
谢谢楼上的回答,俺也在寻找问题的答案,学习喽。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群