楼主: rpg163
17983 5

求助:如何在stata中 cluster 两个变量 [推广有奖]

  • 1关注
  • 0粉丝

已卖:3份资源

教授

20%

还不是VIP/贵宾

-

威望
0
论坛币
3478 个
通用积分
30.4075
学术水平
2 点
热心指数
9 点
信用等级
3 点
经验
3531 点
帖子
207
精华
0
在线时间
2199 小时
注册时间
2007-3-24
最后登录
2024-11-9

楼主
rpg163 发表于 2011-6-10 00:04:23 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
RT
目前在做一个固定效应的模型,大致是这样的
xtset cnstkcd year
xtreg DV IVs, fe cluster(....)

我想cluster cnstkcd year 两个变量,不知应如何处理。

请高手指点下,谢谢!

P.S. 对于这个模型设定,自己也很不明白,究竟Fixed effect 和cluster是什么意思,什么情况下需要cluster?
二维码

扫码加我 拉你入群

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

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

关键词:Cluster Stata tata CLU fixed effect 求助 变量 Stata Cluster

沙发
ywh19860616 发表于 2011-6-10 08:39:31
SE/Robust
      vce(vcetype)        vcetype may be conventional, robust, cluster clustvar, bootstrap, or jackknife

一般是用来产生稳健标准误的
常见是这样使用,vce(cluster,id),id是截面识别符
一份耕耘,一份收获。

藤椅
ywh19860616 发表于 2011-6-10 08:40:43
vce(vcetype) specifies the type of standard error reported, which includes types that are derived from asymptotic theory,that are robust to some kinds of misspecification, and that use bootstrap or jackknife methods; see [XT] vce_options.




help xt_vce_options
----------------------------------------------------------------------------------------------------------------------------------

title

    [XT] vce_options -- Variance estimators


Syntax

        estimation_cmd ... [, xt_vce_options ...]

    xt_vce_options                        description
    ----------------------------------------------------------------------------------------------------------------------------
    vce(oim)                              observed information matrix (OIM)
    vce(opg)                              outer product of the gradient (OPG) vectors
    vce(robust)                           Huber/White/sandwich estimator
    vce(cluster clustvar)                 clustered sandwich estimator
    vce(bootstrap [, bootstrap_options])  bootstrap estimation
    vce(jackknife [, jackknife_options])  jackknife estimation

    nmp                                   use divisor N - P instead of the default N
    scale(x2|dev|phi|#)                   override the default scale parameter; available only with population-averaged models
    ----------------------------------------------------------------------------------------------------------------------------


Description

    This entry describes the xt_vce_options, which are common to most xt estimation commands. Not all the options documented
    below work with all xt estimation commands; see the documentation for the particular estimation command.  If an option is
    listed there, it is applicable.

    The vce() option specifies how to estimate the variance-covariance matrix (VCE) corresponding to the parameter estimates.
    The standard errors reported in the table of parameter estimates are the square root of the variances (diagonal elements) of
    the VCE.


Options

        +-----------+
    ----+ SE/Robust +-----------------------------------------------------------------------------------------------------------

    vce(oim) is usually the default for models fit using maximum likelihood.  vce(oim) uses the observed information matrix
        (OIM); see [R] ml.

    vce(opg) uses the sum of the outer product of the gradient (OPG) vectors; see [R] ml.  This is the default VCE when the
        technique(bhhh) option is specified; see [R] maximize.

    vce(robust) uses the robust or sandwich estimator of variance.  This estimator is robust to some types of misspecification
        so long as the observations are independent; see [U] 20.16 Obtaining robust variance estimates.

        If the command allows pweights and you specify them, vce(robust) is implied; see [U] 20.18.3 Sampling weights.

    vce(cluster clustvar) specifies that the standard errors allow for intragroup correlation, relaxing the usual requirement
        that the observations be independent.  That is to say, the observations are independent across groups (clusters) but not
        necessarily within groups.  clustvar specifies to which group each observation belongs, e.g., vce(cluster personid) in
        data with repeated observations on individuals.  vce(cluster clustvar) affects the standard errors and
        variance-covariance matrix of the estimators but not the estimated coefficients; see [U] 20.16 Obtaining robust variance
        estimates.

    vce(bootstrap [, bootstrap_options]) uses a nonparametric bootstrap; see [R] bootstrap.  After estimation with
        vce(bootstrap), see [R] bootstrap postestimation to obtain percentile-based or bias-corrected confidence intervals.

    vce(jackknife [, jackknife_options]) uses the delete-one jackknife; see [R] jackknife.

    nmp specifies that the divisor N-P be used instead of the default N, where N is the total number of observations and P is
        the number of coefficients estimated.

    scale(x2|dev|phi|#) overrides the default scale parameter.  By default, scale(1) is assumed for the discrete distributions
        (binomial, negative binomial, and Poisson), and scale(x2) is assumed for the continuous distributions (gamma, Gaussian,
        and inverse Gaussian).

        scale(x2) specifies that the scale parameter be set to the Pearson chi-squared (or generalized chi-squared) statistic
        divided by the residual degrees of freedom, which is recommended by McCullagh and Nelder as a good general choice for
        continuous distributions.

        scale(dev) sets the scale parameter to the deviance divided by the residual degrees of freedom. This option provides an
        alternative to scale(x2) for continuous distributions and for over- or underdispersed discrete distributions.

        scale(phi) specifies that the scale parameter be estimated from the data.  xtgee's default scaling makes results agree
        with other estimators and has been recommended by McCullagh and Nelder in the context of GLM.  When comparing results
        with calculations made by other software, you may find that the other packages do not offer this feature.  In such
        cases, specifying scale(phi) should match their results.

        scale(#) sets the scale parameter to #. For example, using scale(1) in family(gamma) models results in
        exponential-errors regression (if you use assume independent correlation structure).


Remarks

    When working with panel-data models, we strongly encourage you to use the vce(bootstrap) or vce(jackknife) options instead
    of the corresponding prefix command.  For example, to obtain jackknife standard errors with xtlogit, type

        . webuse clogitid
        . xtlogit y x1 x2, fe vce(jackknife)

    If you wish to specify more options to the bootstrap or jackknife estimation, you can include them within the vce() option.
    Below we refit our model requesting bootstrap standard errors based on 300 replications, we set the random-number seed so
    that our results can be reproduced, and we suppress the display of the replication dots.

        . xtlogit y x1 x2, fe vce(bootstrap, reps(300) seed(123) nodots)
一份耕耘,一份收获。

板凳
rpg163 发表于 2011-6-10 22:10:09
3# ywh19860616
谢谢!不过还是不太清楚,VCE(cluster var)时好像没有办法同时cluster两个变量,不知这个应该如何解决

报纸
ajun685 发表于 2012-7-17 17:20:05
egen newgroup= group( cnstkcd year)
……
xtreg DV IVs, fe cluster(newgroup)
已有 1 人评分学术水平 收起 理由
adamesky + 5 精彩帖子

总评分: 学术水平 + 5   查看全部评分

生于忧患,死于安乐。

地板
peyzf 发表于 2012-12-5 07:15:50
right.

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

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