美文网首页
Stata: 合成控制法 synth 命令无法加载 plugin

Stata: 合成控制法 synth 命令无法加载 plugin

作者: stata连享会 | 来源:发表于2019-07-28 23:53 被阅读0次

作者:陈勇吏 (上海交通大学安泰经济与管理学院)

Stata 连享会: 知乎 | 简书 | 码云 | CSDN

Stata连享会   计量专题 || 精品课程 || 简书推文 || 公众号合集

点击查看完整推文列表

2020寒假Stata现场班 (北京, 1月8-17日,连玉君-江艇主讲),「+助教招聘」

2020寒假Stata现场班

合成控制法的常用命令 synth 在使用过程中,可能会出现一些问题,导致命令无法正常运行。本文列出两种经常出现的问题,并给出解决方案。

1. 第一种出现的报错

运行 synth 命令以后,显示无法加载 synthopt.plugin

  use "smoking.dta",clear
  xtset state year
  
  synth cigsale  lnincome age15to24 retprice beer(1984(1)1988) ///
        cigsale(1988) cigsale(1980) cigsale(1975),             ///
        trunit(3) trperiod(1989) xperiod(1980(1)1988)          ///
        fig nested allopt
*===================== 出现下面报错信息 ======================*
Could not load plugin: D:\stata15/ado\plus\s\synthopt.plugin
(error occurred while loading synth.ado)
r(9999);

这是旧版本文件可能存在的问题,如果电脑里面装了多个版本的 synth 命令相关文件,可能会导致错误调用。

解决方案:
使用 ssc install synth, replace 更新 synth 命令。

. ssc install synth, replace

*========================== 显示结果如下: ========================
the following files will be replaced:
    D:\stata15/ado\plus\s\synth.sthlp
    D:\stata15/ado\plus\s\synthopt.plugin

installing into D:\stata15/ado\plus\...
installation complete.

2. 第二种出现的报错

使用 ssc install synth, replace 更新 synth 命令以后,依然无法加载 synthopt.plugin

报错信息.png

这是 Stata 搜索 adopath 的路径设置问题。如果 adopath + "path" 添加的 adopath 路径中存在其他版本的 synth 命令文件,调用 synth 就会报错。

三种解决办法:
1、从 D:\stata15\ado\plus\s 路径下找到正确的文件 synthopt.plugin ,复制到报错中显示的路径 D:\stata15\ado\personal\PX_C_2019b\C6_synth\adofiles\plus\s 下。
2、删除 D:\stata15\ado\personal\PX_C_2019b\C6_synth\adofiles\plus\s 中的 synth.ado 文件。
3、运行 adopath - D:\stata15\ado\personal\PX_C_2019b\C6_synth\adofiles 命令,将这一路径从 ado 文件的搜索路径中剔除(这一方法将导致该路径下的其他外部命令也无法再使用)。

小结

Stata 使用合成控制法的外部命令 synth 时,如果遇到报错,可尝试运行下列命令解决问题:

ssc install synth, replace

如果依然报错,有两种建议的解决办法:

1、从 D:\stata15\ado\plus\s 文件夹中找到 synthopt.plugin 文件,复制到 D:\stata15\ado\personal\PX_C_2019b\C6_synth\adofiles\plus\s 路径中(替换该路径下的 synthopt.plugin 文件)。

也可以直接运行如下命令达到相同的效果(第二行代码的 PLUS 后面填入 synth 命令报错返回的路径):

local path `c(sysdir_plus)'
sysdir set PLUS "D:\stata15\ado\personal\PX_C_2019b\C6_synth\adofiles" //引号中是报错信息显示的路径
ssc install synth, replace
sysdir set PLUS "`path'"

2、删除 D:\stata15\ado\personal\PX_C_2019b\C6_synth\adofiles\plus\s 路径下的 synth 相关文件。

关于我们

  • Stata连享会 由中山大学连玉君老师团队创办,定期分享实证分析经验。
  • 推文同步发布于 CSDN简书知乎Stata专栏。可在百度中搜索关键词 「Stata连享会」查看往期推文。
  • 点击推文底部【阅读原文】可以查看推文中的链接并下载相关资料。
  • 欢迎赐稿: 欢迎赐稿。录用稿件达 三篇 以上,即可 免费 获得一期 Stata 现场培训资格。
  • E-mail: StataChina@163.com
  • 往期精彩推文:一网打尽

欢迎加入Stata连享会(公众号: StataChina)

相关文章

网友评论

      本文标题:Stata: 合成控制法 synth 命令无法加载 plugin

      本文链接:https://www.haomeiwen.com/subject/gawmrctx.html