博客
关于我
MatchingFrontier包简介及R实现
阅读量:804 次
发布时间:2023-02-07

本文共 1916 字,大约阅读时间需要 6 分钟。

MatchingFrontier 包简介

由哈佛大学的 Gary King 和 Christopher Lucas 以及 MIT 的 Richard Nielsen 三位学者共同开发的 MatchingFrontier 包于 2015 年首次发布在 GitHub 上,现已可在 CRAN 上方便下载。该包提供了一种用于因果推断的优化分组匹配效率的算法。

传统的 PSM 方法仅通过倾向得分本身进行匹配,在匹配组与对照组的相似度、模型依赖度、统计效率及偏误等多方面表现欠佳。研究者长期面临偏误与方差之间的权衡困境:通过修剪数据以降低不平衡,从而减少模型依赖度,但同时也会减少样本量,进而增大估计值的方差。

MatchingFrontier 算法通过同步优化不平衡(在处理组与对照组之间)和样本大小,实现了对分组匹配效率的最大化。此外,该包的核心用途在于生产最优的匹配样本,标准的 PSM 分析流程在计算出 ATT 值后已实质上结束。

核心功能

该包主要由以下四个函数模块构成:

  • 构造匹配边界 makeFrontier
  • 估计边界效应 estimateEffects
  • 可视化分析 Visualize the full frontier
  • 生成优化后的匹配样本
  • 使用步骤

    1. 载入所需程序包和数据集

    library(MatchingFrontier)  data(lalonde)  lalonde <- as.data.frame(lalonde)  attach(lalonde)

    2. 数据集简介

    数据集 lalonde 包含以下变量:

    • re78:1978 年实际收入(结果变量)
    • treat:是否参加就业培训(处理变量)
    • age:年龄
    • educ:教育年限
    • black:是否为黑人
    • hisp:是否为拉丁族
    • married:是否结婚
    • nodegree:是否有学位
    • re74re75:1974 年和 1975 年的实际收入
    • u74u75:1974 年和 1975 年是否失业

    样本共计 1185 个观测。

    3. 计算匹配边界

    match.on <- colnames(lalonde)[!(colnames(lalonde) %in% c('re78', 'treat'))]  my.frontier <- makeFrontier(    dataset = lalonde,    treatment = 'treat',    outcome = 're78',    match.on = match.on  )  # 返回结果显示,997 个观测值被移除,最终保留 188 个优化样本。

    4. 估计效应

    my.form <- as.formula(re78 ~ treat + age + black + education + hispanic + married + nodegree + re74 + re75)  my.estimates <- estimateEffects(    my.frontier,    're78 ~ treat',    mod.dependence.formula = my.form,    continuous.vars = c('age', 'education', 're74', 're75'),    prop.estimated = 0.1,    means.as.cutpoints = TRUE  )

    5. 可视化分析

    plotFrontier(    my.frontier,    cex.lab = 1.4,    cex.axis = 1.4,    type = 'l',    panel.first = grid(NULL, NULL, lwd = 2)  )  plotEstimates(    my.estimates,    ylim = c(-10000, 3000),    cex.lab = 1.4,    cex.axis = 1.4,    panel.first = grid(NULL, NULL, lwd = 2)  )  plotMeans(my.frontier)

    6. 生成优化后的匹配样本

    n <- 180  matched.data <- generateDataset(my.frontier, N = n)  # 可选择部分或全部观测本文选择了 180 个观测。

    总结

    MatchingFrontier 包通过创新性的算法解决了传统 PSM 方法在偏误与方差权衡上的缺陷,帮助研究者高效完成因果推断任务。

    转载地址:http://ezyfk.baihongyu.com/

    你可能感兴趣的文章
    No mapping found for HTTP request with URI [/logout.do] in DispatcherServlet with name 'springmvc'
    查看>>
    No module named 'crispy_forms'等使用pycharm开发
    查看>>
    No module named 'pandads'
    查看>>
    No module named cv2
    查看>>
    No module named tensorboard.main在安装tensorboardX的时候遇到的问题
    查看>>
    No module named ‘MySQLdb‘错误解决No module named ‘MySQLdb‘错误解决
    查看>>
    No new migrations found. Your system is up-to-date.
    查看>>
    No qualifying bean of type XXX found for dependency XXX.
    查看>>
    No qualifying bean of type ‘com.netflix.discovery.AbstractDiscoveryClientOptionalArgs<?>‘ available
    查看>>
    No resource identifier found for attribute 'srcCompat' in package的解决办法
    查看>>
    no session found for current thread
    查看>>
    No static resource favicon.ico.
    查看>>
    no such file or directory AndroidManifest.xml
    查看>>
    No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android
    查看>>
    NO.23 ZenTaoPHP目录结构
    查看>>
    no1
    查看>>
    NO32 网络层次及OSI7层模型--TCP三次握手四次断开--子网划分
    查看>>
    NOAA(美国海洋和大气管理局)气象数据获取与POI点数据获取
    查看>>
    NoClassDefFoundError: org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadata
    查看>>
    node
    查看>>