R程序下载(https://github.com/lixiongyang/Yang)#包括估计和拐点存在性检验程序
模型介绍拐点回归模型是断点回归模型的一个扩展,即用斜率参数的变化来定义因果效应。但这些模型假设断点值或拐点值已知,造成实证应用的局限。
因此Hansen(2017)将拐点回归模型扩展到了具有未知拐点的拐点回归模型(regression kink with an unknown threshold)。Hansen (2017) model:(rkc.R)[img=100,0][/img]
应用:ZF债务对经济增长的影响
其中,拐点(红色点所示)解释为最优ZF债务水平。
Hansen(2017)的模型具有广泛应用,但拐点为常数有时不符合现实,因此研究具有时变拐点的模型具有重要意义。Yang and Su(2018)认为最优债务水平可能取决于经济增速、通货膨胀和以往的ZF债务,因此,提出具有时变且状态依赖门槛的拐点回归。Yang and Su (2018) model:(rkt.R)[img=100,0][/img][img=100,0][/img]其中[img=100,0][/img]为经济增速、通货膨胀和以往债务等状态变量。
R程序与模拟实证应用Yang and Su(2018)原文为Gauss程序结果:
如下为新编R程序Hansen(2017)模型实证结果:
新编程序Yang and Su(2018)模型实证结果:

不同程序略有偏差,应为所调用基础函数差异导致的计算误差。
拐点存在性检验也已亲测有效。
# Load in Datarm(list=ls())setwd("E:\\R-econometrics\\cthresh-Hansen-2017")growth <- read.table("usdata.txt",header=TRUE)n = nrow(growth)year = growth[2:n,1]gdp = growth[2:n,3]gdp1 = growth[1:(n-1),3]debt1= growth[1:(n-1),2]q = growth[2:n,4]#q = gdp1# Time-Series Data Plots, Figure 1ab in paper#windows()plot(year,gdp,type="l",ylab="GDP Growth Rate")#savePlot(file="fig1a.eps",type="eps",dev.cur())#windows()plot(year,debt1,type="l",ylab="Debt/GDP")#savePlot(file="fig1b.eps",type="eps",dev.cur())# Define variablesy = gdpx = debt1n = length(y)z = cbind(gdp1,matrix(1,n,1)) # controls and constant#load functionssetwd("E:\\R-econometrics\\MyRegressionKink")source("rkt.R")# set grid search paramatersr01 = 10r02 = 71stp1 = 1r11 = -5r12 = 5stp2 = 0.1# estimate the modelrkt <- rkt(y,x,z,q,r01=r01,r02=r02,r11=r11,r12=r12,stp1=stp1,stp2=stp2) # set parameters for bootstrapb0 = rkt[1]$bolsbt = rkt[4]$bt #coefficients for kink model with a varying thresholdgammahat0 = as.numeric(rkt[5])gammahat1 = as.numeric(rkt[6])w2 = rkt[8] # statistic for kink effect (state-dependent threshold)boot = 10 # boostrap replications# testing for kink effect based on Yang and Su (2018, JIMF)testkinkT <- testkinkT(y,x,z,q, boot=boot, b0, bt, gammahat0, gammahat1, w2, level=0.9)
模拟:程序进一步验证为估计上述两个模型,笔者分别写了两个程序(rkc.R & rkt.R)。下面用模拟验证程序的正确性。
模拟中,模型真实参数为(样本量=200):
[img=100,0][/img][img=100,0][/img]

rm(list=ls())#load functionssetwd("E:\\R-econometrics\\MyRegressionKink")source("rkt.R")# generate datan=200x = rnorm(n)q = rnorm(n)rt = 0.2 - 0.5*qz = rnorm(n)x1 = cbind(neg.part(x-rt),pos.part(x-rt),z)b0 =c(1,2,1)y = x1%*%b0 + rnorm(n)# set grid search paramatersr01 = 0r02 = 2stp1 = 0.1r11 = -10r12 = 5stp2 = 0.1# estimate the model with a state-dependent thresholdrkt <- rkt(y,x,z,q,r01=r01,r02=r02,r11=r11,r12=r12,stp1=stp1,stp2=stp2)
[1] Hansen, B.E., 2017. Regression kink with an unknown threshold[J]. J. Bus. Econ. Stat. 35 (2), 228–240.
[2] Lixiong Yang, Jen-Je Su. Debt and growth: Is there a constant tipping point?[J]. Journal of International Money and Finance(SSCI, ABS Grade 3), 2018, 87:133-143.