版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、微观计量经济学模型(Model of Microeconometrics)1.1 Generalized Linear ModelsThree aspects of the linear regression model for a conditionally normally distributed response y are:(1) The linear predictor through which .(2) is (3)GLMs: extends (2)and(3) to more general families of distributions for y. Specifical
2、ly, may follow a density:canonical parameter, depends on the linear predictor.:dispersion parameter, is often known.Also and are related by a monotonic transformation,Called the link function of the GLM.Selected GLM families and their canonical linkFamilyCanonical linkNamebinomiallogitgaussianidenti
3、typoissonlog1.2 Binary Dependent VariablesModel:In the probit case: equals the standard normal CDFIn the logit case: equals the logistic CDFExample:(1)DataConsidering female labor participation for a sample of 872 women from Switzerland.The dependent variable: participationThe explain variables:inco
4、me,age,education,youngkids,oldkids,foreignyesandage2.R:library("AER")data("SwissLabor")summary(SwissLabor)participation income age education no :471 Min. : 7.187 Min. :2.000 Min. : 1.000 yes:401 1st Qu.:10.472 1st Qu.:3.200 1st Qu.: 8.000 Median :10.643 Median :3.900 Median : 9.0
5、00 Mean :10.686 Mean :3.996 Mean : 9.307 3rd Qu.:10.887 3rd Qu.:4.800 3rd Qu.:12.000 Max. :12.376 Max. :6.200 Max. :21.000 youngkids oldkids foreign Min. :0.0000 Min. :0.0000 no :656 1st Qu.:0.0000 1st Qu.:0.0000 yes:216 Median :0.0000 Median :1.0000 Mean :0.3119 Mean :0.9828 3rd Qu.:0.0000 3rd Qu.:
6、2.0000 Max. :3.0000 Max. :6.0000 (2) EstimationR:swiss_prob=glm(participation.+I(age2),data=SwissLabor,family=binomial(link="probit")summary(swiss_prob)Call:glm(formula = participation . + I(age2), family = binomial(link = "probit"), data = SwissLabor)Deviance Residuals: Min 1Q M
7、edian 3Q Max -1.9191 -0.9695 -0.4792 1.0209 2.4803 Coefficients: Estimate Std. Error z value Pr(>|z|) (Intercept) 3.74909 1.40695 2.665 0.00771 * income -0.66694 0.13196 -5.054 4.33e-07 *age 2.07530 0.40544 5.119 3.08e-07 *education 0.01920 0.01793 1.071 0.28428 youngkids -0.71449 0.10039 -7.117
8、1.10e-12 *oldkids -0.14698 0.05089 -2.888 0.00387 * foreignyes 0.71437 0.12133 5.888 3.92e-09 *I(age2) -0.29434 0.04995 -5.893 3.79e-09 *-Signif. codes: 0 * 0.001 * 0.01 * 0.05 . 0.1 1 (Dispersion parameter for binomial family taken to be 1) Null deviance: 1203.2 on 871 degrees of freedomResidual de
9、viance: 1017.2 on 864 degrees of freedomAIC: 1033.2Number of Fisher Scoring iterations: 4(3) VisualizationPlotting participation versus ageR:plot(participationage,data=SwissLabor,ylevels=2:1)(4) EffectsAverage marginal effects:The average of the sample marginal effects: R:fav=mean(dnorm(predict(swis
10、s_prob,type="link")fav*coef(swiss_prob)(Intercept) income age education youngkids 1.241929965 -0.220931858 0.687466185 0.006358743 -0.236682273 oldkids foreignyes I(age2) -0.048690170 0.236644422 -0.097504844The average marginal effects at the average regressor:R:av=colMeans(SwissLabor,-c(
11、1,7)av=data.frame(rbind(swiss=av,foreign=av),foreign=factor(c("no","yes")av=predict(swiss_prob,newdata=av,type="link")av=dnorm(av)av"swiss"*coef(swiss_prob)-7av"foreign"*coef(swiss_prob)-7swiss: (Intercept) income age education youngkids 1.495137092
12、-0.265975880 0.827628145 0.007655177 -0.284937521 oldkids I(age2) -0.058617218 -0.117384323Foreign:(Intercept) income age education youngkids 1.136517140 -0.202179551 0.629115268 0.005819024 -0.216593099 oldkids I(age2) -0.044557434 -0.089228804(5) Goodness of fit and predictionPseudo-R2:as the log-
13、likelihood for the fitted model, as the log-likelihood for the model containing only a constant term.R: swiss_prob0=update(swiss_prob,formula=.1)1- as.vector(logLik(swiss_prob)/logLik(swiss_prob0)1 0.1546416Percent correctly predicted:R:table(true=SwissLabor$participation,pred=round(fitted(swiss_pro
14、b) predtrue 0 1no 337 134yes 146 25567.89%ROC curve:TPR(c):the number of women participating in the labor force that are classified as participating compared with the total number of women participating.FPR(c):the number of women not participating in the labor force that are classified as participat
15、ing compared with the total number of women not participating.R:library("ROCR")pred=prediction(fitted(swiss_prob),SwissLabor$participation)plot(performance(pred,"acc")plot(performance(pred,"tpr","fpr")abline(0,1,lty=2)l Extensions: Multinomial responsesFor ill
16、ustrating the most basic version of the multinomial logit model, a model with only individual-specific covariates,.data("BankWages")It contains, for employees of a US bank, an ordered factor job with levels "custodial", "admin"(for administration), and "manage"
17、; (for management), to be modeled as afunction of education (in years) and a factor minority indicating minority 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 mode
18、ling below.summary(BankWages) job education gender minority custodial: 27 Min. : 8.00 male :258 no :370 admin :363 1st Qu.:12.00 female:216 yes:104 manage : 84 Median :12.00 Mean :13.49 3rd Qu.:15.00 Max. :21.00 summary(BankWages)edcat <- factor(BankWages$education)edcatlevels(edcat)3:10 <- re
19、p(c("14-15", "16-18", "19-21"),+ c(2, 3, 3)head(edcat)tab <- xtabs( edcat + job, data = BankWages)head(tab)prop.table(tab, 1)head(BankWages)library("nnet")bank_mn2 <- multinom(job education + minority+gender, data=BankWages,trace = FALSE)summary(bank_mn2
20、)1.3 Regression Models for Count DataWe begin with the standard model for count data, a Poisson regression.Poisson Regression Model:Canonical link: the log linkExample:Trips to Lake Somerville,Texas,1980. based on a survey administered to 2,000 registered leisure boat owners in 23 counties in easter
21、n Texas.The dependent variable is trips, and we want to regress it on all further variables: a (subjective) quality ranking of the facility (quality), a factor indicating whether the individual engaged in water-skiing at the lake (ski),household income (income), a factor indicating whether the indiv
22、idual paid a users fee at the lake (userfee), and three cost variables (costC, costS,costH) representing opportunity costs.(1)Datadata("RecreationDemand")summary(RecreationDemand) trips quality ski income userfee Min. : 0.000 Min. :0.000 no :417 Min. :1.000 no :646 1st Qu.: 0.000 1st Qu.:0
23、.000 yes:242 1st Qu.:3.000 yes: 13 Median : 0.000 Median :0.000 Median :3.000 Mean : 2.244 Mean :1.419 Mean :3.853 3rd Qu.: 2.000 3rd Qu.:3.000 3rd Qu.:5.000 Max. :88.000 Max. :5.000 Max. :9.000 costC costS costH Min. : 4.34 Min. : 4.767 Min. : 5.70 1st Qu.: 28.24 1st Qu.: 33.312 1st Qu.: 28.96 Medi
24、an : 41.19 Median : 47.000 Median : 42.38 Mean : 55.42 Mean : 59.928 Mean : 55.99 3rd Qu.: 69.67 3rd Qu.: 72.573 3rd Qu.: 68.56 Max. :493.77 Max. :491.547 Max. :491.05 head(RecreationDemand) trips quality ski income userfee costC costS costH1 0 0 yes 4 no 67.59 68.620 76.8002 0 0 no 9 no 68.86 70.93
25、6 84.7803 0 0 yes 5 no 58.12 59.465 72.1104 0 0 no 2 no 15.79 13.750 23.6805 0 0 yes 3 no 24.02 34.033 34.5476 0 0 yes 5 no 129.46 137.377 137.850(2) Estimationrd_pois=glm(trips.,data=RecreationDemand,family=poisson)coeftest(rd_pois)z test of coefficients: Estimate Std. Error z value Pr(>|z|) (In
26、tercept) 0.2649934 0.0937222 2.8274 0.004692 * quality 0.4717259 0.0170905 27.6016 < 2.2e-16 *skiyes 0.4182137 0.0571902 7.3127 2.619e-13 *income -0.1113232 0.0195884 -5.6831 1.323e-08 *userfeeyes 0.8981653 0.0789851 11.3713 < 2.2e-16 *costC -0.0034297 0.0031178 -1.1001 0.271309 costS -0.04253
27、64 0.0016703 -25.4667 < 2.2e-16 *costH 0.0361336 0.0027096 13.3353 < 2.2e-16 *Signif. codes: 0 * 0.001 * 0.01 * 0.05 . 0.1 R:logLik(rd_pois)the log-likelihood of the fitted model:'log Lik.' -1529.431 (df=8)rbind(obs = table(RecreationDemand$trips)1:10, exp = round(+ sapply(0:9, functio
28、n(x) sum(dpois(x, fitted(rd_pois) 0 1 2 3 4 5 6 7 8 9obs 417 68 38 34 17 13 11 2 8 1exp 277 146 68 41 30 23 17 13 10 7table(true=RecreationDemand$trips,pred=round(fitted(rd_nb)NOT WELL(3)Dealing with overdispersionPoisson distribution has the property that the variance equals the mean. In econometri
29、cs, Poisson regressions are often plagued by overdispersion.One way of testing for overdispersion is to consider the alternative hypothesis(Cameron and Trivedi 1990)Var(yi|xi) = i + a*h(i)where h is a positive function of i.Overdispersion corresponds to a > 0 and underdispersion to a < 0. Comm
30、on specifications of the transformation function h are h() = 2 or h() = . The former corresponds to a negative binomial (NB) model (see below) with quadratic variance function (called NB2 by Cameron and Trivedi 1998), the latter to an NB model with linear variance function (called NB1 by Cameron and
31、 Trivedi 1998). In the statistical literature, the reparameterization Var(yi|xi) = (1 + a) · i = dispersion · iof the NB1 model is often called a quasi-Poisson model with dispersion parameter.R: dispersiontest(rd_pois) Overdispersion testdata: rd_pois z = 2.4116, p-value = 0.007941alternat
32、ive hypothesis: true dispersion is greater than 1 sample estimates:dispersion 6.5658R:dispersiontest(rd_pois, trafo = 2) Overdispersion testdata: rd_pois z = 2.9381, p-value = 0.001651alternative hypothesis: true alpha is greater than 0 sample estimates: alpha 1.316051Both suggest that the Poisson m
33、odel for the trips data is not well specified.One possible remedy is to consider a more flexible distribution that does not impose equality 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 Pois
34、son distribution with random scale, the latter following a gamma distribution. Its probability mass function isR: library("MASS")rd_nb <- glm.nb(trips ., data = RecreationDemand)coeftest(rd_nb)z test of coefficients: Estimate Std. Error z value Pr(>|z|) (Intercept) -1.1219363 0.21430
35、29 -5.2353 1.647e-07 *quality 0.7219990 0.0401165 17.9976 < 2.2e-16 *skiyes 0.6121388 0.1503029 4.0727 4.647e-05 *income -0.0260588 0.0424527 -0.6138 0.53933 userfeeyes 0.6691676 0.3530211 1.8955 0.05802 . costC 0.0480087 0.0091848 5.2270 1.723e-07 *costS -0.0926910 0.0066534 -13.9314 < 2.2e-1
36、6 *costH 0.0388357 0.0077505 5.0107 5.423e-07 *-Signif. codes: 0 * 0.001 * 0.01 * 0.05 . 0.1 R:logLik(rd_nb)'log Lik.' -825.5576 (df=9) 0 1 2 3 4 5 6 7 8 9obs 417 68 38 34 17 13 11 2 8 1exp 370 87 37 26 21 17 14 11 9 8(4) Zero-inflated Poisson and negative binomial modelsrbind(obs = table(Re
37、creationDemand$trips)1:10, exp = round(+ sapply(0:9, function(x) sum(dpois(x, fitted(rd_pois) 0 1 2 3 4 5 6 7 8 9obs 417 68 38 34 17 13 11 2 8 1exp 277 146 68 41 30 23 17 13 1 0 7One such model is the zero-inflated Poisson (ZIP) model (Lambert 1992),which suggests a mixture specification with a Pois
38、son count component and an additional point mass at zero. With IA(y) denoting the indicator function, the basic idea isfzeroinfl(y) = pi · I0(y) + (1 pi) · fcount(y; i),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(
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 意识的课件教学课件
- 2024年建筑工程施工合同详细描述
- 2024年度战略合作合同(含合作领域)
- 春艾青课件教学课件
- 2024年度水果品牌授权合同:授权生产和销售的具体条款
- 2024年度金融服务合同:银行为客户提供2024年度综合金融服务
- 2024年专利实施许可合同:生物医药产品专利应用
- 2024年度航空器材买卖合同
- 幼儿清明课件教学课件
- 毛笔楷体课件教学课件
- 浙教版(2023)四年级上册信息科技-教学计划
- (新版)糖尿病知识竞赛考试题库300题(含答案)
- 技术创新课件教学课件
- 第四章 光现象章节练习2024-2025学年人教版八年级物理上册
- 《中国肿瘤防治核心科普知识(2024)》解读
- 2024年新人教版七年级上册历史教学课件 第10课 秦末农民大起义
- 2024年北师大版小升初数学试卷及答案
- 银行业法律法规考试试卷(共四套)
- 人工智能教学设计《图像识别教学设计》
- 2024年甘肃省职业院校技能大赛物联网应用开发赛项样题2
- 《精益生产之ECRS分析法》课件
评论
0/150
提交评论