找回密码
 注册
查看: 925|回复: 0

R语言 wfe包 pwfe()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-10-1 21:03:39 | 显示全部楼层 |阅读模式
pwfe(wfe)
pwfe()所属R语言包:wfe

                                        Fitting the Weighted Fixed Effects Model with Propensity Score Weighting
                                         拟合倾向分数权重的加权固定效应模型

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

pwfe is used to fit weighted fixed effects model for causal inference after transforming outcome variable based on estimated propensity score. pwfe also derives the regression weights for different causal quantity of interest.
pwfe来拟合加权固定效应模型进行因果推理的基础上估计倾向得分,改造后的结果变量。 pwfe也派生的回归权重不同的因果数量利益。


用法----------Usage----------


pwfe(formula, treat = "treat.name", outcome, data, pscore = NULL,
     unit.index, time.index = NULL, method = "unit", within.unit = TRUE,
     qoi = c("ate", "att"), estimator = NULL, C.it = NULL,
     White = TRUE, White.alpha = 0.05,
     hetero.se = TRUE, auto.se = TRUE, unbiased.se = FALSE,
     verbose = TRUE)



参数----------Arguments----------

参数:formula
a symbolic description of the model for estimating propensity score. The formula should not include dummmies for fixed effects. The details of model specifications are given under "Details".  
的符号描述的模型估计倾向得分。公式不应该包括固定效应dummmies为。型号规格的详细信息刊载在“详细信息”。


参数:treat
a character string indicating the name of treatment variable used in the models. The treatment should be binary indicator (integer with 0 for the control group and 1 for the treatment group).  
一个字符串,指示处理变量在模型中使用的名称。治疗指标应该是二进制的(整数为治疗组与对照组为0和1)。


参数:outcome
a character string indicating the name of outcome variable.  
一个字符串,表示结果变量的名称。


参数:data
data frame containing the variables in the model.  
数据框包含在模型中的变量。


参数:pscore
an optional character string indicating the name of estimated propensity score. Note that pre-specified propensity score should be bounded away from zero and one.  
一个可选的字符串表示估计倾向得分的名称。需要注意的是预先指定的倾向得分应界远离零和一。


参数:unit.index
a character string indicating the name of unit variable used in the models. The index of unit should be factor.  
一个字符串,表示单位在模型中使用的变量的名称。单位应该是该指数的因素。


参数:time.index
a character string indicating the name of time variable used in the models. The index of time should be factor.  
一个字符串表示模型所用的时间变量的名称。该指数的时间应的因素。


参数:method
method for weighted fixed effects regression, either unit for unit fixed effects; time for time fixed effects. The default is unit.  
加权固定效应回归的方法,无论是unit为单位的固定效应,“time时间固定效应。默认的unit。


参数:within.unit
a logical value indicating whether propensity score is estimated within unit. The default is TRUE.   
一个逻辑值,该值指示是否倾向得分估计单元内。默认的TRUE。


参数:qoi
one of "ate" or "att". The default is "ate".  
一个"ate"或"att"。默认的"ate"。


参数:estimator
an optional character string indicating the estimating method. One of "fd" or "did".  
一个可选的字符串表示的估计方法。一个"fd"或"did"。


参数:C.it
an optional non-negative numeric vector specifying relative weights for each unit of analysis.  
一个可选的非负数值的相对权重向量确定各单位的分析。


参数:White
a logical value indicating whether White misspecification statistics should be calculated. The default is TRUE.  
一个逻辑值,该值指示是否应计算白误设统计。默认的TRUE。


参数:White.alpha
level of functional specification test. See White (1980) and Imai . The default is 0.05.  
功能规格测试的水平。白(1980年)和今井。默认的0.05。


参数:hetero.se
a logical value indicating whether heteroskedasticity across units is allowed in calculating standard errors. The default is TRUE.  
一个逻辑值,该值指示是否允许异方差性跨部门的计算标准误差。默认的TRUE。


参数:auto.se
a logical value indicating whether arbitrary autocorrelation is allowed in calculating standard errors. The default is TRUE.  
一个逻辑值,该值指示是否允许任意的自相关计算标准误差。默认的TRUE。


参数:unbiased.se
logical. If TRUE, bias-asjusted heteroskedasticity-robust standard errors are used. See Stock and Watson (2008). Should be used only for balanced panel. The default is FALSE.  
逻辑。如果TRUE,偏置asjusted异方差稳健标准误差所使用。 Stock和Watson(2008年)。应仅用于平衡面板。默认的FALSE。


参数:verbose
logical. If TRUE, helpful messages along with a progress report of the weight calculation are printed on the screen. The default is TRUE.  
逻辑。如果TRUE,有用的信息以及权重计算的进度报告显示在屏幕上。默认的TRUE。


Details

详细信息----------Details----------

To fit the weighted unit (time) fixed effects model with propensity score weighting, use the syntax for the formula, ~ x1 + x2, where x1 and x2 are unit (time) varying covariates.
为了适应与倾向得分权重的加权单位(时间)固定效应模型,使用的语法的公式,~ x1 + x2,这里x1和x2单位(时间)变化的协变量。

One can provide his/her own estimated pscore which can be used to transform the outcome varialbe. If so, one does not need to specify formula.
可以提供他/她自己的估计,可以用来pscore变换的结果varialbe。如果是这样,并不需要指定formula。

If pscore is not provided, bayesglm will be used to estimate propensity scores. If within.unit = TRUE, propensity score will be separately estimated within time (unit) when method is unit (time). Otherwise, propensity score will be estimated on entire data at once.
如果pscore,bayesglm将被用于估计倾向得分。 within.unit = TRUE如果,倾向得分将分别估计的时间内(单位)method是unit(time)。否则,将倾向得分在一次对整个数据估计。

The estimated propensity scores will be used to transform the outcome variable as described in Imai and Kim (2011).
估计倾向得分将用于改造outcome变量,,今井和Kim(2011年)中描述的。

pwfe calculates weights based on different underlying causal quantity of interest: Average Treatment Effect (qoi = "ate") or Average Treatment Effect for the Treated (qoi = "att").
pwfe计算的权重根据不同的基础因果关系的关注量:一般治疗效果(qoi = "ate")或平均治疗效果的治疗(qoi = "att")。

One can further set estimating methods: First-Difference (estimator ="fd") or Difference-in-differences (estimator   = "did").
我们可以进一步设置估算方法:一阶差分(estimator ="fd")或差的差异(estimator   = "did")。

To specify different ex-ante weights for each unit of analysis, use non-negative weights C.it. For instance, using the survey weights for C.it enables the estimation fo the average treatement effect for the target population.
要指定不同的权重事前各单位的分析,使用非负权重C.it。例如,使用的调查权重为C.it使估计为的平均treatement影响的目标人群。


值----------Value----------

pwfe returns an object of class "pwfe", a list that contains the components listed below.
pwfe返回一个对象类的“pwfe”,一个列表,包含以下列出的组件。

The function summary (i.e., summary.pwfe) can be used to obtain a table of the results.
该函数summary(即,summary.pwfe)可以用来获得的结果的表。


参数:coefficients
a named vector of coefficients
一个命名的系数向量


参数:residuals
the residuals, that is respons minus fitted values
残差,即反应作者减去拟合值


参数:df
the degree of freedom
的自由度


参数:W
weight matrix calculated from the model. Row and column indices can be found from unit.name, time.name.
模型计算出的权重矩阵。行和列索引,可以发现从unit.name,time.name。


参数:call
the matched call
匹配的呼叫


参数:causal
causal quantity of interest
因果数量利益


参数:estimator
the estimating method
估算方法


参数:unit.name
a vector containing unique unit names
一个向量,包含独特的单位名称


参数:unit.index
a vector containing unique unit index number
一个向量,包含独特的单位索引号


参数:time.name
a vector containing unique time names
一个向量,包含独特的时间名称


参数:time.index
a vector containing unique time index number
一个向量,包含独特的时间索引号


参数:method
call of the method used
要求所使用的方法


参数:vcov
the variance covariance matrix
方差协方差矩阵


参数:White.alpha
the alpha level for White specification test
白规格测试的alpha水平


参数:White.pvalue
the p-value for White specification test
白规格测试的p值


参数:White.stat
the White statistics
白统计


参数:x
the design matrix
设计矩阵


参数:y
the response vector
响应矢量


参数:mf
the model frame
模型框架


(作者)----------Author(s)----------


Kosuke Imai, Princeton University, <a href="mailto:kimai@princeton.edu">kimai@princeton.edu</a>
and In Song Kim, Princeton University, <a href="mailto:insong@princeton.edu">insong@princeton.edu</a>



参考文献----------References----------

Effects Regression Models for Causal Inference.&rdquo; Technical Report, Department of Politics, Princeton University.  available at http://imai.princeton.edu/research/FEmatch.html
Standard Errors for Fixed Effect Panel Data Regression&rdquo; Econometrica, 76, 1.
Regression Functions.&rdquo;  International Economic Review, 21, 1, 149&ndash;170.

参见----------See Also----------

wfe for fitting weighted fixed effect models.
wfe拟合加权固定效应模型。


实例----------Examples----------


### NOTE: this example illustrates the use of wfe function with randomly[##注意:这个例子说明了随机的WFE功能与使用]
### generated panel data with arbitrary number of units and time.[##生成任意数量的面板数据单位和时间。]

## generate panel data with number of units = N, number of time = Time[#生成面板数据的单位数= N,时间=时间]
N &lt;- 10 # number of distinct units[不同的单元的数量]
Time &lt;- 15 # number of distinct time[不同的时间的数量]

## generate treatment variable[#生成处理变量]
treat <- matrix(rbinom(N*Time, size = 1, 0.25), ncol = N)
## make sure at least one observation is treated for each unit[#确保每个单元至少一个观察治疗]
while ((sum(apply(treat, 2, mean) == 0) > 0) | (sum(apply(treat, 2, mean) == 1) > 0) |
       (sum(apply(treat, 1, mean) == 0) > 0) | (sum(apply(treat, 1, mean) == 1) > 0)) {
  treat <- matrix(rbinom(N*Time, size = 1, 0.25), ncol = N)
}
treat.vec <- c(treat)

## unit fixed effects[#机组固定效应]
alphai <- rnorm(N, mean = apply(treat, 2, mean))

## geneate two random covariates[#geneate两个随机协变量]
x1 <- matrix(rnorm(N*Time, 0.5,1), ncol=N)
x2 <- matrix(rbeta(N*Time, 5,1), ncol=N)
pscore <- matrix(runif(N*Time, 0,1), ncol=N)
x1.vec <- c(x1)
x2.vec <- c(x2)
pscore <- c(pscore)

## generate outcome variable[#产生的结果变量]
y <- matrix(NA, ncol = N, nrow = Time)
for (i in 1:N) {
    y[, i] <- alphai[i] + treat[, i] + x1[,i] + x2[,i] + rnorm(Time)
}
y.vec <- c(y)

## generate unit and time index[#生成单元和时间指数]
unit.index <- rep(1:N, each = Time)
time.index <- rep(1:Time, N)

Data.str <- as.data.frame(cbind(y.vec, treat.vec, unit.index, x1.vec, x2.vec))
colnames(Data.str) <- c("y", "tr", "strata.id", "x1", "x2")

Data.obs <- as.data.frame(cbind(y.vec, treat.vec, unit.index, time.index, x1.vec, x2.vec, pscore))
colnames(Data.obs) <- c("y", "tr", "unit", "time", "x1", "x2", "pscore")


############################################################[################################################## #########]
# Example 1: Stratified Randomized Experiments[例1:采用分层随机试验]
############################################################[################################################## #########]

## run the weighted fixed effect regression with strata fixed effect.[#运行的加权固定效应回归与地层固定作用。]
## Note: the quantity of interest is Average Treatment Effect ("ate")[注:关注量平均处理效果(“吃”)]
## and the standard errors allow heteroskedasticity and arbitrary[#和标准误差允许异方差和任意]
## autocorrelation.[#自相关。]


### Average Treatment Effect[##平均处理效果]
ps.ate <- pwfe(~ x1+x2, treat = "tr", outcome = "y", data = Data.str,
               unit.index = "strata.id", method = "unit", within.unit = TRUE,
               qoi = "ate", hetero.se=TRUE, auto.se=TRUE)
## summarize the results[#总结的结果。]
summary(ps.ate)

### Average Treatment Effect for the Treated[##平均处理后的治疗效果]
ps.att <- pwfe(~ x1+x2, treat = "tr", outcome = "y", data = Data.str,
               unit.index = "strata.id", method = "unit", within.unit = TRUE,
               qoi = "att", hetero.se=TRUE, auto.se=TRUE)
## summarize the results[#总结的结果。]
summary(ps.att)


############################################################[################################################## #########]
# Example 2: Observational Studies with Unit Fixed-effects[例2:单位固定效应的观测研究]
############################################################[################################################## #########]

## run the weighted fixed effect regression with unit fixed effect.[#执行单位固定效应的加权固定效应回归。]
## Note: the quantity of interest is Average Treatment Effect ("ate")[注:关注量平均处理效果(“吃”)]
## and the standard errors allow heteroskedasticity and arbitrary[#和标准误差允许异方差和任意]
## autocorrelation.[#自相关。]

### Average Treatment Effect[##平均处理效果]
ps.obs <- pwfe(~ x1+x2, treat = "tr", outcome = "y", data = Data.obs,
               unit.index = "unit", time.index = "time",
               method = "unit", within.unit = TRUE,
               qoi = "ate", hetero.se=TRUE, auto.se=TRUE)

## summarize the results[#总结的结果。]
summary(ps.obs)

## extracting weigths[#提取weigths]
summary(ps.obs)$Weights

### Average Treatment Effect with First-difference[##平均处理效应的一阶差分]

ps.fd <- pwfe(~ x1+x2, treat = "tr", outcome = "y", data = Data.obs,
              unit.index = "unit", time.index = "time",
              method = "unit", within.unit = TRUE,
              qoi = "ate", estimator = "fd", hetero.se=TRUE, auto.se=TRUE)

## summarize the results[#总结的结果。]
summary(ps.fd)


############################################################[################################################## #########]
# Example 3: Estimation with pre-specified propensity score[例3:带有预先指定的倾向评分的估计]
############################################################[################################################## #########]

### Average Treatment Effect with Pre-specified Propensity Scores[##平均治疗效果与预先指定的倾向得分]

mod.ps <- pwfe(treat = "tr", outcome = "y", data = Data.obs, pscore = "pscore",
               unit.index = "unit", time.index = "time",
               method = "unit", within.unit = TRUE,
               qoi = "ate", hetero.se=TRUE, auto.se=TRUE)

## summarize the results[#总结的结果。]
summary(mod.ps)

转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

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

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2024-11-25 12:00 , Processed in 0.039409 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表