好文档就是一把金锄头!
欢迎来到金锄头文库![会员中心]
电子文档交易市场
安卓APP | ios版本
电子文档交易市场
安卓APP | ios版本

安慰剂检验介绍、操作及举例.docx

9页
  • 卖家[上传人]:油条
  • 文档编号:1238645
  • 上传时间:2017-06-04
  • 文档格式:DOCX
  • 文档大小:64.19KB
  • / 9 举报 版权申诉 马上下载
  • 文本预览
  • 下载提示
  • 常见问题
    • 安慰剂检验介绍(Placebo test)安慰剂是一种附加实证检验的思路,并不存在一个具体的特定的操作方法一般存在两种寻找安慰剂变量的方法比如,在已有的实证检验中,发现自变量 Xi 会影响自变量 Zi 与因变量 Yi 之间存在相关关系在其后的实证检验中,采用其他主体(国家,省份,公司)的 Xj 变量作为安慰剂变量,检验 Xj 是否影响 Zi 与 Yi 之间的相关关系如果不存在类似于 Xi 的影响,即可排除 Xi 的安慰剂效应,使得结果更为稳健另一种寻找安慰剂变量的方法已知,Xi 是虚拟变量,Xi=1, if t>T;Xi=0 if tT+n;Xi`=0 if tNote that any comments can be embedded into R code, simply by putting a # to the left of your comments (e.g. anything to the right of # will be ignored by R). Alternately, you can download the data file, and import it from your hard drive:eitc = read.dta("C:\DATA\Courses\Econ 562\homework\eitc.dta")Describe and summarize your dataRecall from part 1 of this series, the following code to describe and summarize your data:STATA:dessumR:In R, each column of your data is assigned a class which will determine how your data is treated in various functions. To see what class R has interpreted for all your variables, run the following code:1234sapply(eitc,class)summary(eitc)source('sumstats.r')sumstats(eitc)To output the summary statistics table to LaTeX, use the following code:12require(xtable) # xtable package helps create LaTeX code from R.xtable(sumstats(eitc))Note: You will need to re-run the code for sumstats() which you can find in an earlier post.Calculate Conditional Sample MeansSTATA:summarize if children==0summarize if children == 1summarize if children >=1summarize if children >=1 & year == 1994mean work if post93 == 0 & anykids == 1R:123456789# The following code utilizes the sumstats function (you will need to re-run this code)sumstats(eitc[eitc$children == 0, ])sumstats(eitc[eitc$children == 1, ])sumstats(eitc[eitc$children >= 1, ])sumstats(eitc[eitc$children >= 1 & eitc$year == 1994, ])# Alternately, you can use the built-in summary functionsummary(eitc[eitc$children == 0, ])summary(eitc[eitc$children == 1, ])1011121314summary(eitc[eitc$children >= 1, ])summary(eitc[eitc$children >= 1 & eitc$year == 1994, ])# Another example: Summarize variable 'work' for women with one child from 1993 onwards.summary(subset(eitc, year >= 1993 & children == 1, select=work))The code above includes all summary statistics – but say you are only interested in the mean. You could then be more specific in your coding, like this:123mean(eitc[eitc$children == 0, 'work'])mean(eitc[eitc$children == 1, 'work'])mean(eitc[eitc$children >= 1, 'work'])Try out any of the other headings within the summary output, they should also work: min() for minimum value, max() for maximum value, stdev() for standard deviation, and others.Create a New VariableTo create a new variable called “c.earn” equal to earnings conditional on working (if “work” = 1), “NA” otherwise (“work” = 0) – use the following code:STATA:gen cearn = earn if work == 1R:1234567eitc$c.earn=eitc$earn*eitc$workz = names(eitc)X = as.data.frame(eitc$c.earn)X[] = lapply(X, function(x){replace(x, x == 0, NA)})eitc = cbind(eitc,X)eitc$c.earn = NULLnames(eitc) = zConstruct a Treatment VariableConstruct a variable for the treatment called “anykids” = 1 for treated individual (has at least one child); and a variable for after the expansion called “post93” = 1 for 1994 and later.STATA:gen anykids = (children >= 1)gen post93 = (year >= 1994)R:12eitc$post93 = as.numeric(eitc$year >= 1994)eitc$anykids = as.numeric(eitc$children > 0)Create a plotCreate a graph which plots mean annual employment rates by year (1991-1996) for single women with children (treatment) and without children (control).STATA:preservecollapse work, by(year anykids)gen work0 = work if anykids==0label var work0 "Single women, no children"gen work1 = work if anykids==1label var work1 "Single women, children"twoway (line work0 year, sort) (line work1 year, sort), ytitle(Labor Force Participation Rates)graph save Graph "homework\eitc1.gph", replaceR:123456789101112131415# Take average value of 'work' by year, conditional on anykidsminfo = aggregate(eitc$work, list(eitc$year,eitc$anykids == 1), mean)# rename column headings (variables)names(minfo) = c("YR","Treatment","LFPR")# Attach a new column with labelsminfo$Group[1:6] = "Single women, no children"minfo$Group[7:12] = "Single women, children"minforequire(ggplot2) #package for creating nice plotsqplot(YR, LFPR, data=minfo, geom=c("point","line"), colour=Group,xlab="Year", ylab="Labor Force Participation Rate")The ggplot2 package produces some nice looking charts.Calculate the D-I-D Estimate of the Treatment EffectCalculate the unconditional difference-in-difference estimates of the effect of the 1993 EITC expansion on employment of single women.STATA:mean work if post93==0 & anykids==0mean work if post93==0 & anykids==1mean work if post93==1 & anykids==0mean work if post93==1 & anykids==1R:12345a = colMeans(subset(eitc, post93 == 0 & anykids == 0, select=work))b = colMeans(subset(eitc, post93 == 0 & anykids == 1, select=work))c = colMeans(subset(eitc, post93 == 1 & anykids == 0, select=work))d = colMeans(subset(eitc, post93 == 1 & anykids 。

      点击阅读更多内容
      关于金锄头网 - 版权申诉 - 免责声明 - 诚邀英才 - 联系我们
      手机版 | 川公网安备 51140202000112号 | 经营许可证(蜀ICP备13022795号)
      ©2008-2016 by Sichuan Goldhoe Inc. All Rights Reserved.