全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
16275 5
2015-03-30
再看stata中,发现一个循环命令forval i=1/14 {
        replace da007_w2_1_`i'_=F.da007_w2_1_`i'_  if  ……
……

求问其中F.是什么意思?网上也没有查到,谢谢各位了

二维码

扫码加我 拉你入群

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

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

全部回复
2015-3-30 16:20:38
F应该指的是forward 前一项,对应的是Lag后一项。

您的数据一定是含有时间变量的,之前一定set time variable了。
二维码

扫码加我 拉你入群

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

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

2015-3-30 16:23:02
manual的user guide里面有这些基本的介绍


Title

    [U] 11.4.4 Time-series varlists


Description

    Time-series varlists are a variation on varlists of existing variables.  When a command allows a time-series varlist, you may include time-series
    operators.  For instance, L.gnp refers to the lagged value of variable gnp.  The time-series operators are

        Operator  Meaning
        ---------------------------------------------------------
        L.        lag (x_t-1)
        L2.       2-period lag (x_t-2)
        ...
        F.        lead (x_t+1)
        F2.       2-period lead (x_t+2)
        ...
        D.        difference (x_t - x_t-1)
        D2.       difference of difference (x_t - 2x_t-1 + x_t-2)
        ...
        S.        "seasonal" difference (x_t - x_t-1)
        S2.       lag-2 (seasonal) difference (x_t - x_t-2)
        ...
        ---------------------------------------------------------


Remarks

     1.  Time-series operators may be repeated and combined.  L3.gnp refers to the third lag of variable gnp, as do LLL.gnp, LL2.gnp, and L2L.gnp.

     2.  The lead operator F. is the complement of the lag operator L., so FL.gnp is just gnp.

     3.  Note that D1.gnp equals S1.gnp, but D2.gnp does not equal S2.gnp because

             D2.gnp = (gnp_t - gnp_t-1) - (gnp_t-1 - gnp_t-2)
                   = gnp_t - 2*gnp_t-1 + gnp_t-2

         while

             S2.gnp = (gnp_t - gnp_t-2)

     4.  Operators may be typed in lowercase or uppercase.

     5.  Operators can be typed in any order; Stata will convert the expression to its canonical form.  For example, Stata will convert ld2ls12d.gnp to
         L2D3S12.gnp.

     6.  In addition to operator#, Stata understands operator(numlist) to mean a set of operated variables.  For example, specifying

             L(1/3).gnp

         in a varlist is the same as typing

             L.gnp L2.gnp L3.gnp

     7.  In operator#, making # zero returns the variable itself.  Thus, instead of typing

             regress y x L(1/3).x

         you can save a few keystrokes by typing

             regress y L(0/3).x

     8.  Before using time-series operators, you must declare the time variable using tsset.

             . list l.gnp
             time variable not set
             r(111)
             . tsset time
             (output omitted)
             . list l.gnp
             (output omitted)

     9.  Variable names can be abbreviated subject to the usual Stata conventions.  If the only variable in your dataset that begins with gn is gnp, then
         you can type L.gn instead of L.gnp

    10.  The time-series operators respect the time variable.  L2.gnp refers to gnp_t-2 regardless of missing observations in the dataset.  Notice in the
         following dataset that the observation for 1992 is missing:

                +------------------------+
                | year      gnp   L2.gnp |
                |------------------------|
             1. | 1989   5452.8        . |
             2. | 1990   5764.9        . |
             3. | 1991   5932.4   5452.8 |
             4. | 1993   6560.0   5932.4 | <- Note, filled in correctly
             5. | 1994   6922.4        . |
             6. | 1995   7237.5   6560.0 |
                +------------------------+

    11.  Time-series operators work with panel data as well as pure time-series data.  The only difference is in how you tsset your data.

             . webuse grunfeld
             . tsset company time

    12. The time-series operators L. and F. may be combined with factor variables.

             . sysuse census
             . generate t = _n
             . tsset t
             . regress death medage iL.region [aw=pop]

         You could have specified Li.region instead of iL.region; the results would be the same.


Examples

    . webuse gxmpl1
    . list cpi L.cpi L2.cpi L3.cpi
    . list cpi L(1/3).cpi

    . list cpi L2.cpi LL.cpi

    . list cpi F.cpi F2.cpi F3.cpi
    . list cpi F2.cpi FF.cpi

    . generate cpi_diff = cpi[_n] - cpi[_n-1]
    . list cpi cpi_diff D.cpi

    . list cpi D.cpi S.cpi D2.cpi S2.cpi


Video example

    Time series, part 3: Time-series operators
二维码

扫码加我 拉你入群

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

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

2015-3-30 16:25:17
我做了一个对照。

有12个变量,前11个变量都除以第十二个变量,且同时改变原数据。
复制代码
这个是没问题的。我考虑您的这个F.是不是随意定的一个字母,放到里面尝试,你会发现
复制代码
stata会提示说 :time variable not set

所以我认为您的数据一定含有时间变量,而且这个F.是指的前一项。
二维码

扫码加我 拉你入群

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

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

2015-3-30 17:52:47
蓝色 发表于 2015-3-30 16:23
manual的user guide里面有这些基本的介绍
非常详细,太谢谢你啦~~
二维码

扫码加我 拉你入群

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

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

2015-3-30 17:53:35
SpencerMeng 发表于 2015-3-30 16:25
我做了一个对照。

有12个变量,前11个变量都除以第十二个变量,且同时改变原数据。这个是没问题的。我考 ...
是的,谢谢你亲自做啊~感激不尽~~
二维码

扫码加我 拉你入群

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

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

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

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