微观计量经济学模型(Model-of-Microeconometrics)_第1页
微观计量经济学模型(Model-of-Microeconometrics)_第2页
微观计量经济学模型(Model-of-Microeconometrics)_第3页
微观计量经济学模型(Model-of-Microeconometrics)_第4页
微观计量经济学模型(Model-of-Microeconometrics)_第5页
已阅读5页,还剩13页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、阅读使人充实,会谈使人敏捷,写作使人精确。培根微观计量经济学模型( Model of Microeconometrics)1.1 Generalized Linear Mod elsThree aspects of the lin ear regressi on model for a con diti on ally no rmallydistributed resp onse y are:(1)The linear predictor i xT - through which 二 E(yi|xj.2(2) yi | Xi is N (叫,二)(3) iGLMs: extends (2)an

2、d(3) to more general families of distributions for y.Specifically, y | x may follow a density:f (y;日冲)=expt y日+ c(y;$)二:canonical parameter, depends on the linear predictor.:dispersion parameter, is often known.Also i and 叫 are related by a monotonic transformation,g(m iCalled the link fun ction of

3、the GLM.Selected GLM families and their canonical linkFamilyCanonical linkNamebi no miallog(曰(1 一巴)logitgaussia nide ntitypoiss onlog卩log1.2 Binary Depend ent VariablesModel:E(% |人)=Pi =F(x),i =1,2,nIn the probit case: f equals the standard normal CDFIn the logit case: F equals the logistic CDFExamp

4、le:DataConsidering female labor participation for a sample of 872 women fromSwitzerla nd.The depe ndent variable: participati onThe expla in variables:in come,age,educatio n,youn gkids,oldkids,foreig ny esa ndageH.R:library(AER)data(SwissLabor)summary(SwissLabor)participation no :471 yes:401incomeMi

5、n. : 7.187 1st Qu.:10.472ageMin. :2.0001st Qu.:3.200educationMin. : 1.0001st Qu.: 8.000youngkidsMin. :0.00001st Qu.:0.0000Median :0.0000Median :10.643Mean :10.6863rd Qu.:10.887Max. :12.376 oldkidsMin. :0.00001st Qu.:0.0000Median :1.0000Median :3.900Mean :3.9963rd Qu.:4.800Max. :6.200 foreign no :656

6、 yes:216Median : 9.000Mean : 9.307 3rd Qu.:12.000 Max. :21.000Mean :0.3119Mean :0.98283rd Qu.:0.0000Max. :3.00003rd Qu.:2.0000Max. :6.0000(2) EstimationR:swiss_prob=glm(participatio n.+l(ageA2),data=SwissLabor,family=bi no mial(li nk=pro bit)summary(swiss_prob)Call:glm(formula = participatio n . + I

7、(ageA2), family = bi no mial(li nk = probit),data = SwissLabor)Deviance Residuals:Min1Q Median3Q Max-1.9191 -0.9695 -0.4792 1.0209 2.4803Coefficients:Estimate Std. Error z value Pr(|z|)(Intercept) 3.749091.406952.665 0.00771 *income-0.666940.13196-5.054 4.33e-07 *age2.075300.405445.119 3.08e-07 *edu

8、cation0.019200.017931.071 0.28428youngkids-0.714490.10039-7.117 1.10e-12 *oldkids-0.146980.05089-2.888 0.00387 *foreignyes0.714370.121335.888 3.92e-09 *I(ageA2)-0.294340.04995-5.893 3.79e-09 *学冋是异常珍贵的东西,从任何源泉吸收都不可耻。阿卜日法拉兹阅读使人充实,会谈使人敏捷,写作使人精确。培根6学冋是异常珍贵的东西,从任何源泉吸收都不可耻。阿卜日法拉兹Signif. codes: 0 * 0.001 *

9、 0.01 *0.05. 0.1 1(Dispersio n parameter for bi no mial family take n to be 1)Null devia nee: 1203.2 on 871 degrees of freedomResidual devia nee: 1017.2 on 864 degrees of freedomAIC: 1033.2Number of Fisher Seoring iterations: 4(3) VisualizationPlott ing partieipatio n versus ageR:plot(partieipati on

10、 age,data=SwissLabor,ylevels=2:1)oQUscda4e g a阅读使人充实,会谈使人敏捷,写作使人精确。培根(x)(4) Effects:Xj学冋是异常珍贵的东西,从任何源泉吸收都不可耻。阿卜日法拉兹(x)rAverage margi nal effects:The average of the sample marg inal effects:R:fav=mea n(d no rm(predict(swiss_prob,type=li nk) fav*coef(swiss_prob)(In tercept)in comeageeducati onyoun gki

11、dsoldkidsforeig nyesI(ageA2)The average marginal effects at the average regressor:Rav=colMea ns(SwissLabor,-c(1,7)av=data.frame(rbi nd(swiss=av,foreig n=av),foreig n=factor(c( no,yes|) av=predict(swiss_prob, newdata=av,type=li nk)av=d no rm(av)avswiss*coef(swiss_prob)-7avforeig n*coef(swiss_prob)-7s

12、wiss:(In tercept)in comeage educati on youn gkidsoldkids I(ageA2)阅读使人充实,会谈使人敏捷,写作使人精确。培根Foreig n:(In tercept)in comeageeducati onyoun gkidsoldkidsI(ageA2)(5) Goodness of fit and predictionPseudo-R2:R2=1C)(?) as the log-likelihood for the fitted model, 0 )( ?) as the log-likelihood for the model cont

13、aining only a constant term.R:swiss_prob0=update(swiss_prob,formula=.1)1- as.vector(logLik(swiss_prob)/logLik(swiss_prob0) 1 0.1546416Perce nt correctly predicted:R:table(true=SwissLabor$participatio n,pred=ro un d(fitted(swiss_prob)predtrue01no337134yes14625567.89%ROC curve:TPR(c):the nu mber of wo

14、me n participati ng in the labor force that areclassified as participat ing compared with the total nu mber of wome n participati ng.FPR(c):the nu mber of wome n not participati ng in the labor force that are classified as participat ing compared with the total nu mber of wome n not participati ng.R

15、:lbrary(ROCR)pred=predictio n(fitted(swiss_prob),SwissLabor$participatio n)plot(performa nce(pred,acc)plot(performa nce(pred,tpr,fpr)ablin e(0,1,lty=2)Cutoff010s.oi ggo A 昌nCJov0.0O0.00.8False positive rate1.0QLIcoogo寸ofo 欝cltAESUdCItnHExtensions: Multinomial responsesFor illustrat ing the

16、most basic vers ion of the mult ino mial logit model, a model with only in dividual-specific covariates,.data(Ba nkWages)It contains, for employees of a US bank, an ordered factor job with levelscustodial, admin(for administration), and manage (forman ageme nt), to be modeled as afun cti on of educa

17、ti on (in years) and a factor min ority in dicati ng mi no rity status. There also exists a factor gender, but since there are no women in the category custodial, only a subset of the data corresponding to males is used for parametric modeling below.summary(BankWages)job education gender minority cu

18、stodial: 27 Min. : 8.00 male :258 no :370 admin :363 1st Qu.:12.00 female:216 yes:104 manage : 84 Median :12.00Mean :13.493rd Qu.:15.00 Max. :21.00summary(BankWages) edcat - factor(BankWages$education) edcat levels(edcat)3:10 - rep(c(14-15, 16-18, 19-21), + c(2, 3, 3) head(edcat)tab - xtabs( edcat +

19、 job, data = BankWages) head(tab) prop.table(tab, 1) head(BankWages)library(nnet) bank_mn2 |z|)(Intercept)0.2649934 0.0937222 2.8274 0.004692 *quality0.4717259 0.0170905 27.6016 2.2e-16 *skiyes0.4182137 0.0571902 7.3127 2.619e-13 *income-0.1113232 0.0195884 -5.6831 1.323e-08 *userfeeyes0.8981653 0.0

20、789851 11.3713 2.2e-16 *costC-0.0034297 0.0031178 -1.1001 0.271309costS-0.0425364 0.0016703 -25.4667 2.2e-16 *costH0.0361336 0.0027096 13.3353 0 and underdispersion to a 0.Com mon specificati ons of the tran sformatio n fun cti on h are h( 2 or卩)= 卩h( ) = . The former corresponds to a negative binom

21、ial (NB) model (seebelow) with quadratic variance function (called NB2 by Cameron andTrivedi 1998), the latter to an NB model with linear variance function(called NB1 by Cameron and Trivedi 1998). In the statistical literature,the reparameterizationVar(yi|xi) = (1 + a) 卩 i = dispersion of the NB1 mo

22、del is often called a quasi-Poisson model with dispersion parameter.R: dispersiontest(rd_pois)Overdispersion test data: rd_pois z = 2.4116, p-value = 0.007941 alternative hypothesis: true dispersion is greater than 1 sample estimates: dispersion6.5658R:dispersiontest(rd_pois, trafo = 2) Overdispersi

23、on testdata: rd_pois z = 2.9381, p-value = 0.001651 alternative hypothesis: true alpha is greater than 0 sample estimates:alpha 1.316051Both suggest that the Poisson model for the trips data is not wellspecified.One possible remedy is to consider a more flexible distribution that does not impose equ

24、ality of mean and variance.The most widely used distribution in this context is the negative binomial. It may be considered a mixture distribution arising from a Poisson distribution with random scale, the latter following a gamma distribution. Its probability mass function isR: library(MASS)rd_nb -

25、 glm.nb(trips ., data = RecreationDemand)coeftest(rd_nb)0.05 . 0.1z test of coefficients:quality0.72199900.040116517.9976 2.2e-16 *skiyes0.61213880.15030294.0727 4.647e-05 *income-0.02605880.0424527-0.6138 0.53933userfeeyes0.66916760.35302111.8955 0.05802 .costC0.04800870.00918485.2270 1.723e-07 *co

26、stS-0.09269100.0066534 -13.9314 |z|)(Intercept) -1.1219363 0.2143029 -5.2353 1.647e-07 *Signif. codes: 0 * 0.001* 0.01R:logLik(rd_nb)log Lik. -825.5576 (df=9)0 1 2 3 4 5 6 7 8 9学问是异常珍贵的东西,从任何源泉吸收都不可耻。阿卜 日 法拉兹阅读使人充实,会谈使人敏捷,写作使人精确。培根obs 417 68 38 34 17 13 11 2 8 1exp 370 87 37 26 21 17 14 11 9 8(4) Ze

27、ro-inflated Poisson and negative binomial modelsrbind(obs = table(RecreationDemand$trips)1:10, exp = round(+ sapply(0:9, function(x) sum(dpois(x, fitted(rd_pois)01 23456 78 9obs 41768 3834171311 281exp 277 146 68 41 30 23 17 13 1 0 7One such model is the zero-inflated Poisson (ZIP) model (Lambert 19

28、92), which suggests a mixture specification with a Poisson count component and an additional point mass at zero. With AI(y) denoting the indicator function, the basic idea isfzeroinfl (y) = Pi 1 0 (y) + (1 - Pi) fcount(y; ),we consider a regression of trips on all further variables for the count part (using a negative binomial distribution) and model the inflation Part as a function of quality and income:library(pscl)rd_zinb = zeroinfl(trips . | quality + income, data=RecreationDemand, dist=negbin) summary(rd_zinb )Call:ze

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论