为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

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

2020-09-16 4页 doc 90KB 22阅读

用户头像 个人认证

Z视界

暂无简介

举报
安慰剂检验介绍、操作及举例安慰剂检验介绍(Placebotest)安慰剂是一种附加实证检验的思路,并不存在一个具体的特定的操作方法。一般存在两种寻找安慰剂变量的方法。比如,在已有的实证检验中,发现自变量Xi会影响自变量Zi与因变量Yi之间存在相关关系。在其后的实证检验中,采用其他主体(国家,省份,公司)的Xj变量作为安慰剂变量,检验Xj是否影响Zi与Yi之间的相关关系。如果不存在类似于Xi的影响,即可排除Xi的安慰剂效应,使得结果更为稳健。另一种寻找安慰剂变量的方法。已知,Xi是虚拟变量,Xi=1,ift>T;Xi=0ift<T;Xi对Zi...
安慰剂检验介绍、操作及举例
安慰剂检验介绍(Placebotest)安慰剂是一种附加实证检验的思路,并不存在一个具体的特定的操作方法。一般存在两种寻找安慰剂变量的方法。比如,在已有的实证检验中,发现自变量Xi会影响自变量Zi与因变量Yi之间存在相关关系。在其后的实证检验中,采用其他主体(国家,省份,公司)的Xj变量作为安慰剂变量,检验Xj是否影响Zi与Yi之间的相关关系。如果不存在类似于Xi的影响,即可排除Xi的安慰剂效应,使得结果更为稳健。另一种寻找安慰剂变量的方法。已知,Xi是虚拟变量,Xi=1,ift>T;Xi=0ift<T;Xi对Zi对Yi的影响的影响在T时前后有显著差异(DID)。在其后的实证检验中,将Xi`设定为Xi`=1,ift>T+n;Xi`=0ift<T+n,其中n根据实际情况取值,可正可负。检验Xi`是否影响Zi与Yi之间的相关关系。如果不存在类似于Xi的影响,即可排除Xi的安慰剂效应,使得结果更为稳健。举例:以美国市场某种政策冲击识别策略的因果关系考察,在最后部分选取英国同期的因变量,检验是否有类似的特征,就是安慰剂检验。以中国2007年所得税改革作为减税的政策冲击以验证减税对企业创新的影响。亦可以通过把虚拟的政策实施时间往前往后推几年,作为虚拟的政策时点,如果检验发现没有类似的因果,文章的主要结论就更加可信了。以下是详细的例,安慰剂检验在最后。SurvivingGraduateEconometricswithR:Difference-in-DifferencesEstimation—2of 8Thefollowingreplicationexercisecloselyfollowsthehomeworkassignment#2inECNS562.Thedataforthisexercisecanbefound here.ThedataisabouttheexpansionoftheEarnedIncomeTaxCredit.Thisisalegislationaimedatprovidingataxbreakforlowincomeindividuals. Forsomebackgroundonthesubject,seeEissa,Nada,andJeffreyB.Liebman.1996.LaborSupplyResponsestotheEarnedIncomeTaxCredit.QuarterlyJournalofEconomics. 111(2):605-637.Thehomeworkquestions(abbreviated):1.Describeandsummarizedata.2.Calculatethesamplemeansofallvariablesfor(a)singlewomenwithnochildren,(b)singlewomenwith1child,and(c)singlewomenwith2+children.3.Createanewvariablewithearningsconditionalonworking(missingfornon-employed)andcalculatethemeansofthisbygroupaswell.4.Constructavariableforthe“treatment”calledANYKIDSandavariableforaftertheexpansion(calledPOST93—shouldbe1for1994andlater).5.Createagraphwhichplotsmeanannualemploymentratesbyyear(1991-1996)forsinglewomenwithchildren(treatment)andwithoutchildren(control).6.Calculatetheunconditionaldifference-in-differenceestimatesoftheeffectofthe1993EITCexpansiononemploymentofsinglewomen.7.Nowrunaregressiontoestimatetheconditionaldifference-in-differenceestimateoftheeffectoftheEITC.Useallwomenwithchildrenasthetreatmentgroup.8.Reestimatethismodelincludingdemographiccharacteristics.9.Addthestateunemploymentrateandallowitseffecttovarybythepresenceofchildren.10.Allowthetreatmenteffecttovarybythosewith1or2+children.11. Estimatea“placebo”treatmentmodel.Takedatafromonlythepre-reformperiod.Usethesametreatmentandcontrolgroups.Introduceaplacebopolicythatbeginsin1992(so1992and1993bothhavethisfakepolicy).Areview:LoadingyourdataRecallthecodeforimportingyourdata:STATA:/*Lastmodified1/11/2011*/**************************************************************************Thefollowingblockofcommandsgoatthestartofnearlyalldofiles*/*Bracketcommentswith/**/orjustuseanasteriskatlinebeginningclear/*Clearsmemory*/setmem50m/*Adjustthisforyourparticulardataset*/cd"C:\DATA\Econ562\homework"/*Changethisforyourfilestructure*/logusing,replace/*Logfilerecordsallcommands&results*/display"$S_DATE$S_TIME"setmoreoffinsheetusing,clear*************************************************************************R: 123456789101112131415 #KevinGoulding#ECNS562-Assignment2 ###########################################################################Loadtheforeignpackagerequire(foreign) #Importdatafromwebsite#update:firstdownloadthefilefromthislink:#Thenimportfromyourharddrive:eitc=("C:/link/to/my/download/folder/")</pre>NotethatanycommentscanbeembeddedintoRcode,simplybyputtinga<code>#</code>totheleftofyourcomments.anythingtotherightof<code>#</code>willbeignoredbyR).Alternately,youcandownloadthedatafile,andimportitfromyourharddrive: eitc=("C:\DATA\Courses\Econ562\homework\")DescribeandsummarizeyourdataRecallfrompart1ofthisseries,thefollowingcodetodescribeandsummarizeyourdata:STATA:dessumR:InR,eachcolumnofyourdataisassignedaclasswhichwilldeterminehowyourdataistreatedinvariousfunctions.ToseewhatclassRhasinterpretedforallyourvariables,runthefollowingcode: 1234 sapply(eitc,class)summary(eitc)source('')sumstats(eitc)TooutputthesummarystatisticstabletoLaTeX,usethefollowingcode: 12 require(xtable)                  #xtablepackagehelpscreateLaTeXcodefromR.xtable(sumstats(eitc))Note:Youwillneedtore-runthecodefor sumstats() whichyoucanfindinan earlierpost.CalculateConditionalSampleMeansSTATA:summarizeifchildren==0summarizeifchildren==1summarizeifchildren>=1summarizeifchildren>=1&year==1994meanworkifpost93==0&anykids==1R: 1234567891011121314 #Thefollowingcodeutilizesthesumstatsfunction(youwillneedtore-runthiscode)sumstats(eitc[eitc$children==0,])sumstats(eitc[eitc$children==1,])sumstats(eitc[eitc$children>=1,])sumstats(eitc[eitc$children>=1&eitc$year==1994,]) #Alternately,youcanusethebuilt-insummaryfunctionsummary(eitc[eitc$children==0,])summary(eitc[eitc$children==1,])summary(eitc[eitc$children>=1,])summary(eitc[eitc$children>=1&eitc$year==1994,]) #Anotherexample:Summarizevariable'work'forwomenwithonechildfrom1993onwards.summary(subset(eitc,year>=1993&children==1,select=work))Thecodeaboveincludesallsummarystatistics–butsayyouareonlyinterestedinthemean.Youcouldthenbemorespecificinyourcoding,likethis: 123 mean(eitc[eitc$children==0,'work'])mean(eitc[eitc$children==1,'work'])mean(eitc[eitc$children>=1,'work'])Tryoutanyoftheotherheadingswithinthesummaryoutput,theyshouldalsowork: min() forminimumvalue, max() formaximumvalue, stdev() forstandarddeviation,andothers.CreateaNewVariableTocreateanewvariablecalled“”equaltoearningsconditionalonworking(if“work”=1),“NA”otherwise(“work”=0)–usethefollowingcode:STATA:gencearn=earnifwork==1R: 1234567 eitc$=eitc$earn*eitc$workz=names(eitc)X==lapply(X,function(x){replace(x,x==0,NA)})eitc=cbind(eitc,X)eitc$=NULLnames(eitc)=zConstructaTreatmentVariableConstructavariableforthetreatmentcalled“anykids”=1fortreatedindividual(hasatleastonechild);andavariableforaftertheexpansioncalled“post93”=1for1994andlater.STATA:genanykids=(children>=1)genpost93=(year>=1994)R: 12 eitc$post93=(eitc$year>=1994)eitc$anykids=(eitc$children>0)CreateaplotCreateagraphwhichplotsmeanannualemploymentratesbyyear(1991-1996)forsinglewomenwithchildren(treatment)andwithoutchildren(control).STATA:preservecollapsework,by(yearanykids)genwork0=workifanykids==0labelvarwork0"Singlewomen,nochildren"genwork1=workifanykids==1labelvarwork1"Singlewomen,children"twoway(linework0year,sort)(linework1year,sort),ytitle(LaborForceParticipationRates)graphsaveGraph"homework\",replaceR: 123456789101112131415 #Takeaveragevalueof'work'byyear,conditionalonanykidsminfo=aggregate(eitc$work,list(eitc$year,eitc$anykids==1),mean) #renamecolumnheadings(variables)names(minfo)=c("YR","Treatment","LFPR") #Attachanewcolumnwithlabelsminfo$Group[1:6]="Singlewomen,nochildren"minfo$Group[7:12]="Singlewomen,children"minfo require(ggplot2)   #packageforcreatingniceplots qplot(YR,LFPR,data=minfo,geom=c("point","line"),colour=Group,        xlab="Year",ylab="LaborForceParticipationRate")Theggplot2packageproducessomenicelookingcharts.CalculatetheD-I-DEstimateoftheTreatmentEffectCalculatetheunconditionaldifference-in-differenceestimatesoftheeffectofthe1993EITCexpansiononemploymentofsinglewomen.STATA:meanworkifpost93==0&anykids==0meanworkifpost93==0&anykids==1meanworkifpost93==1&anykids==0meanworkifpost93==1&anykids==1R: 12345 a=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==1,select=work))(d-c)-(b-a)RunasimpleD-I-DRegressionNowwewillrunaregressiontoestimatetheconditionaldifference-in-differenceestimateoftheeffectoftheEarnedIncomeTaxCrediton“work”,usingallwomenwithchildrenasthetreatmentgroup.Theregressionequationisasfollows:Where  isthewhitenoiseerrorterm.STATA:geninteraction=post93*anykidsregworkpost93anykidsinteractionR: 12 reg1=lm(work~post93+anykids+post93*anykids,data=eitc)summary(reg1)IncludeRelevantDemographicsinRegressionAddingadditionalvariablesisamatterofincludingtheminyourcodedregressionequation,asfollows:STATA:genage2=age^2/*Createage-squaredvariable*/gennonlaborinc=finc-earn/*Non-laborincome*/regworkpost93anykidsinteractionnonwhiteageage2edfincnonlaborincR: 123 reg2=lm(work~anykids+post93+post93*anykids+nonwhite                +age+I(age^2)+ed+finc+I(finc-earn),data=eitc)summary(reg2)CreatesomenewvariablesWewillcreatetwonewinteractionvariables:1.Thestateunemploymentrateinteractedwithnumberofchildren.2.Thetreatmentterminteractedwithindividualswithonechild,ormorethanonechild.STATA:geninteru=urate*anykidsgenonekid=(children==1)gentwokid=(children>=2)genpostXone=post93*onekidgenpostXtwo=post93*twokidR: 123456789101112 #Thestateunemploymentrateinteractedwithnumberofchildreneitc$=eitc$urate*eitc$anykids ###Creatinganewtreatmentterm: #First,we'llcreateanewdummyvariabletodistinguishbetweenonechildand2+.eitc$manykids=(eitc$children>=2) #Next,we'llcreateanewvariablebyinteractingthenewdummy#variablewiththeoriginalinteractionterm.eitc$tr2=eitc$*eitc$manykidsEstimateaPlaceboModelTestingaplacebomodeliswhenyouarbitrarilychooseatreatmenttimebeforeyouractualtreatmenttime,andtesttoseeifyougetasignificanttreatmenteffect.STATA:genplacebo=(year>=1992)genplaceboXany=anykids*placeboregworkanykidsplaceboplaceboXanyifyear<1994InR,firstwe’llsubsetthedatatoexcludethetimeperiodaftertherealtreatment(1993andlater).Next,we’llcreateanewtreatmentdummyvariable,andrunaregressionasbeforeonourdatasubset.R: 12345678910 #subsetthedata,includingonlyyearsbefore1994.=eitc[eitc$year<=1993,] #Createanew"aftertreatment"dummyvariable#andinteractionterm$post91=$year>=1992) #Runaplaceboregressionwhereplacebotreatment=post91*anykidsreg3<-lm(work~anykids+post91+post91*anykids,data=summary(reg3)Theentirecodeforthispostisavailable here (File–>SaveAs).Ifyouhaveanyquestionsorfindproblemswithmycode,youcane-mailmedirectlyat kevingoulding{at}gmail[dot]com.TocontinueontoPart3ofourseries,FixedEffectsestimation, clickhere.
/
本文档为【安慰剂检验介绍、操作及举例】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索