Skip to content

门槛效应模型

强平衡、弱平衡及非平衡面板的一至三重门槛估计、LR 区间与 xthreg2 兼容 Bootstrap。

核心代码

py
    def estimate(self, trims):
        self.base_candidates = self.candidates(trims[0])
        first = self.profile(trims[0])
        profiles = [first]
        stages = [[first['threshold']]]
        if len(trims) >= 2:
            second = self.profile(trims[1], stages[0])
            distance=int(np.floor(len(self.base_candidates)*trims[1]))
            # 原库将第二次搜索返回的局部位置直接用于全网格截尾。
            refined_candidates=self.base_candidates[np.abs(np.arange(len(self.base_candidates))-(second['location']-1))>distance]
            refined = self.profile(trims[1], [second['threshold']],candidates=refined_candidates)
            profiles += [refined, second]
            stages += [[refined['threshold'], second['threshold']]]
        if len(trims) == 3:
            third = self.profile(trims[2], stages[1])
            profiles += [third]
            stages += [[*stages[1], third['threshold']]]
        return profiles, stages

Released under the AGPL-3.0 License.