楼主: gxlzlxs
52440 85

[面板数据求助] 面板数据分位回归(Quantile)在 stata14中完美实现!   [推广有奖]

11
gxlzlxs 在职认证  发表于 2016-4-25 19:48:06
好久没来论坛了。对不住了。忘记留下联系方式了。QQ:76665290
已有 1 人评分经验 收起 理由
kmrd -100 为什么要留QQ呢?在论坛里与大家一起分享不.

总评分: 经验 -100   查看全部评分

12
万里晴空 发表于 2016-4-27 17:11:25
旧时光是个美人 发表于 2016-4-14 21:48
楼主不要卖关子了,我来告诉大家吧。
首先,下载xtqreg命令,这个命令是基于R语言的,所以你的电脑里要装有 ...
兄弟给力的回答

13
万里晴空 发表于 2016-4-27 17:26:06
旧时光是个美人 发表于 2016-4-14 21:48
楼主不要卖关子了,我来告诉大家吧。
首先,下载xtqreg命令,这个命令是基于R语言的,所以你的电脑里要装有 ...
兄弟给力的回答

14
蓝色 发表于 2016-4-27 17:51:04
还可以

help qregpd
-----------------------------------------------------------------------------------------------------------------------------------------------------------

Title

    qregpd --       Quantile Regression for Panel Data (QRPD)

Syntax

        qregpd depvar indepvars [if] [in] [weight] , [quantile(#) instruments(varlist) identifier(varlist) fix(varlist) optimize(string) MCMC options
               Grid-search options ]

Description

    qregpd can be used to fit the quantile regression for panel data (QRPD) estimator developed in Powell (2015).  The estimator addresses a fundamental
    problem posed by alternative fixed-effect quantile estimators: inclusion of indiviudal fixed effects alters the interpretation of the estimated
    coefficient on the treatment variable. As detailed in Powell (2016), the QRPD estimator is a special case of the generalized quantile estimator
    implemented by genqreg.

    Numerical optimization proceeds via a Nelder-Mead algorithm. As estimation and calculation of standard errors can sometimes pose numerical
    challenges, the user can estimate generalized quantile regressions using Markov Chain Monte Carlo methods or grid-search methods.

Syntax

    genqreg is invoked in the usual way - the command name, followed by the dependent variable, followed by control variables. One can then specify
    options after a comma.

Options

    quantile(#) specifies the quantile to be estimated and should be a number between 0 and 1, exclusive.  Numbers larger than 1 are interpreted as
        percentages.  The default value of 0.5 corresponds to the median.

    instruments(varlist) All exogenous explanitory variables and any addtional instrumental variables must be included in instruments(varlist). If no
        variables are included in instruments(varlist), then it is assumed all the RHS variables are exogenous.

    identifier(varlist) This option must be specified as it defines the unit of observation that we observe over multiple time periods. Think of
        identifier(varlist) as the panelvar in xtset.  "Time" is defined in fix(varlist).

    fix(varlist) This is the "time" fixed effect. Think of fix(varlist) as the timevar in xtset.

    optimize(string) Three optimization techniques can be used to estimate qregpd:  Nelder-Mead (default), adaptive MCMC and Grid-search.

Nelder-Mead Options

    nmsimplex(string) A Stata matrix for the NM simplex. See moptimize Nelder-Mead

MCMC Options

    To use the adaptive MCMC optimization procedure specify optimize("mcmc").  For further help see help mf_amcmc if installed.

    draws(#) tells the algorithm how many draws to perform

    burn(#) tells the algorithm how many draws to drop as a burn-in period; accordingly, the algorithm returns only the last draws(#)-burn(#) draws.

    arate(#) acceptance rates of the algorithm. Must be between 0 and 1.  The default is 0.234.

    sampler(string) a string scalar specifying the drawing scheme desired by the user.  sampler("mwg") is Metropolis-within-Gibbs sampling (each
    component of the function is sampled alone and in order).  sampler("global") is global, all-at-once sampling (defualt).

    dampparm(#) is an adjustment parameter telling the algorithm how agressively or conservatively to adapt the proposal distribution to achieve the
    acceptance rate specified by the user in arate(#). dampparm(#) should lie between zero and one, with values closer to zero corresponding with slower
    adaptation, and values closer to one corresponding to more rapid adaptation to the proposal history. The defualt is 0.234.

    from(string) initial parameter values EXCLUDING the constant. This must be a Stata matrix.  If left blank, starting values are from qreg.

    fromvariance(#) initial covariance matrix EXCLUDING the constant. This must be a Stata matrix.  If left blank, starting values are from qreg.

    saving(string) specifies a location to store the draws of the parameters. The file will contain just the draws after any burn-in period or thinning
    of values is applied.

    replace specifies that an existing file is to be overwritten with parameter draws.

    append specifies that an existing file is to be appended with parameter draws.

    thin(int) specifies that only every #th draw is to be retained, so if thin(3) is specified, only every third draw is retained. This option is
    designed to help ease autocorrelation in the resulting draws, as is the option jumble, which randomly mixes draws. Both options may be applied.

    jumble specifies that retained draws are to be jumbled. This helps reduce autocorrelation between draws.

    noisy If specified, the algorithm produces feedback - each time the target distribution is evaluated, it produces a "." as output, while after 50
    calls, it produces the value of the target distribution.

    usemax By default, the mean of the MCMC draws are reported as the coefficient "estimates" to match Stata conventional output.  By specifying the
    option usemax, the set of draws that correspond to the maximum objective function value are reported.

    analytic By default, the variance of the MCMC draws are used to calculate the standard errors to match Stata conventional output.  By specifying the
    option analytic, analytic standard errors are reported (See, Powell (2014b)).

Grid-search Options

    To use the grid-search optimization procedure specify optimize("grid").  A maximum of two RHS variables may be used with the grid-search optimization
    procedure.  As such, you will need to specify the minimum, maximum and interval for each variable's grid.

    grid1(numlist) Grid for first independent variable.

    grid2(numlist) Grid for second independent variable.

Examples

    -------------------------------------------------------------------------------------------------------------------------------------------------------
    Setup
        . webuse nlswork

    Robust quantile regression for panel data
        . qregpd ln_wage tenure union, id(idcode) fix(year)


    Same as above, but using MCMC methods
        . qregpd ln_wage tenure union, id(idcode) fix(year) optimize(mcmc) noisy draws(1000) burn(100) arate(.5)
        . mat list e(gamma)


    Robust instrumental variable quantile regression for panel data. MCMC optimization.
        . qregpd ln_wage tenure union, id(idcode) fix(year) optimize(mcmc) noisy draws(1000) burn(100) arate(.5) instruments(ttl_exp wks_work union)
        . mat list e(gamma)


    Robust instrumental variable quantile regression for panel data. Grid-search optimization.
        . qregpd ln_wage tenure union, id(idcode) fix(year) optimize(grid) min1(0) max1(0.06) intvl1(0.005) min2(0.05) max2(0.1) intvl2(0.005)
            instruments(ttl_exp wks_work union)
        . mat list e(gamma)
               
      
Saved results

    qregpd saves the following in e():

    Scalars        
      e(N)                number of observations

    Macros         
      e(cmd)              "qregpd"
      e(title)            "Quantile Regression for Panel Data"
      e(indepvars)         Righ-hand side variables
      e(depvar)            Left-hand side variable
      e(gamma)             Values on the gamma vector

    Matrices      
      e(b)                Parameter values
      e(V)                Variance-covariance matrix of parameters
      e(solutions)        Parameter values from grid search; may contain multiple solutions.

    Functions      
      e(sample)           marks estimation sample
               
Reference

    Powell, David. 2015.  Quantile Regression with Nonadditive Fixed Effects.  RAND Labor and Population Working Paper.

    Powell, David. 2016.  Quantile Treatment Effects in the Presence of Covariates. RAND Labor and Population Working Paper.


    Powell, David. 2014b.  Did the Economic Stimulus Payments of 2008 Reduce Labor Supply?  Evidence from Quantile Panel Data Estimation.  RAND Labor and
        Population Working Paper 710-3.

Authors

    This command was written by Matthew J. Baker (matthew.baker@hunter.cuny.edu), David Powell (dpowell@rand.org), and Travis Smith (tasmith@uga.edu).
        Comments, criticisms, and suggestions for improvement are welcome.

Also see

    Manual: quantile

    Other: Generalized Quantile Regression (GQR), if installed:  genqreg
已有 5 人评分经验 论坛币 学术水平 热心指数 信用等级 收起 理由
葫芦娃大王 + 10 + 10 精彩帖子
Stakiny + 2 + 2 + 2 热心帮助其他会员
enoch29067 + 5 + 5 + 5 精彩帖子
opeia + 1 + 1 + 1 + 1 精彩帖子
h3327156 + 1 + 1 + 1 + 1 精彩帖子

总评分: 经验 + 10  论坛币 + 12  学术水平 + 9  热心指数 + 9  信用等级 + 9   查看全部评分

15
h3327156 发表于 2016-6-22 22:34:36
蓝色 发表于 2016-4-27 17:51
还可以

help qregpd
我的硕士班学妹硕士论文即采用此法。
虽说qregpd主要是固定效应模型。
但它与xtqreg最大的不同点即qregpd有采用工具变数。
在实际估计时,qregpd有点慢

第一次灌时,
我习惯
findit qregpd

16
scorpiosilence 发表于 2016-7-25 21:52:20
旧时光是个美人 发表于 2016-4-14 21:48
楼主不要卖关子了,我来告诉大家吧。
首先,下载xtqreg命令,这个命令是基于R语言的,所以你的电脑里要装有 ...
你好,麻烦请问一下,在do文档里面修改里面关于R语言的路径,global Rterm_path "C:\Program Files\R\R-3.2.2\bin\i386\Rterm.exe"  路径以及R的版本请改成自己的。
正在学习r,不太懂,麻烦方便的时候回复我一下,谢谢,鞠躬。

17
旧时光是个美人 发表于 2016-7-26 10:11:11
scorpiosilence 发表于 2016-7-25 21:52
你好,麻烦请问一下,在do文档里面修改里面关于R语言的路径,global Rterm_path "C:\Program Files\R\R-3 ...
这条命令是加入到stata的do文档里面的,告诉stata R的安装位置,使得后面stata能够调用R来进行估计,和R本身没太大关系,甚至你不会R也一点关系也没有。
已有 1 人评分学术水平 热心指数 信用等级 收起 理由
Stakiny + 2 + 2 + 2 热心帮助其他会员

总评分: 学术水平 + 2  热心指数 + 2  信用等级 + 2   查看全部评分

18
scorpiosilence 发表于 2016-7-26 14:12:29
旧时光是个美人 发表于 2016-7-26 10:11
这条命令是加入到stata的do文档里面的,告诉stata R的安装位置,使得后面stata能够调用R来进行估计,和R本 ...
[img][/img]

19
scorpiosilence 发表于 2016-7-26 14:14:52
scorpiosilence 发表于 2016-7-26 14:12
[/img]
我在我的stata 中new doedit file 中输入了global Rterm_path "C:\Program Files\R\R-3.3.1\bin\i386\Rterm.exe,这是按照我的安装目录修改的,然后把这个do文件保存吗,然后应该怎么处理?特别麻烦你,谢谢啦。

20
旧时光是个美人 发表于 2016-7-27 09:36:35
scorpiosilence 发表于 2016-7-26 14:14
我在我的stata 中new doedit file 中输入了global Rterm_path "C:\Program Files\R\R-3.3.1\bin\i386\Rte ...
把这条命令添加到你的论文里的do file里面
然后你可以help xtqreg,跑一下里面的测试命令,看看能不能用

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2025-12-29 15:00