Title: | Regression Kink with a Time-Varying Threshold |
---|---|
Description: | An algorithm is proposed to estimate regression kink model proposed by the paper, Lixiong Yang and Jen-Je Su (2018) <doi:10.1016/j.jimonfin.2018.06.002>. |
Authors: | Lixiong Yang [aut, cre] |
Maintainer: | Lixiong Yang <[email protected]> |
License: | GPL |
Version: | 0.1.0 |
Built: | 2024-12-24 06:31:00 UTC |
Source: | CRAN |
This is a function computing the negtive part of a variable.
neg.part(x)
neg.part(x)
x |
A vector of response. |
ne |
The negative part of a variable. |
pt1 <- proc.time() ##Simulated data set.seed(12345) n=200 x = rnorm(n) obj <- neg.part(x) proc.time() - pt1
pt1 <- proc.time() ##Simulated data set.seed(12345) n=200 x = rnorm(n) obj <- neg.part(x) proc.time() - pt1
This is a function computing the positive part of a variable.
pos.part(x)
pos.part(x)
x |
A vector of response. |
ps |
The positive part of a variable. |
pt1 <- proc.time() ##Simulated data set.seed(12345) n=200 x = rnorm(n) obj <- pos.part(x) proc.time() - pt1
pt1 <- proc.time() ##Simulated data set.seed(12345) n=200 x = rnorm(n) obj <- pos.part(x) proc.time() - pt1
This is a function computing OLS estimates of linear model.
reg(X,y)
reg(X,y)
y |
A vector of response. |
X |
data matrix |
bols |
The ols estimates of a linear regression model. |
pt1 <- proc.time() ##Simulated data set.seed(12345) n=200 e = rnorm(n) X = cbind(1,rnorm(n)) b0 =c(1,2) y = X obj <- reg(X,y) proc.time() - pt1
pt1 <- proc.time() ##Simulated data set.seed(12345) n=200 e = rnorm(n) X = cbind(1,rnorm(n)) b0 =c(1,2) y = X obj <- reg(X,y) proc.time() - pt1
This is a function estimating regression kink with a time-varying threshold.
rkt(y,x,z,q,r01,r02,r11,r12,stp1,stp2)
rkt(y,x,z,q,r01,r02,r11,r12,stp1,stp2)
y |
A vector of response. |
x |
A vector of regressor |
z |
A data matrix of control variables |
q |
A vector of variable affecting threshold |
r01 |
Lower bounder of parameter space for r0 |
r02 |
Upper bounder of parameter space for r0 |
r11 |
Lower bounder of parameter space for r1 |
r12 |
Upper bounder of parameter space for r1 |
stp1 |
Step used in grid search of r0 |
stp2 |
Step used in grid search of r1 |
A list with the elements
bols |
The OLS estimates when a kink effect is ignored. |
bt |
The regression coefficients when a kink effect is included in the model. |
gammahat0 |
The estimated threshold of the constant one in threshold parameters. |
gammahat1 |
The estimated threshold of the slop in threshold parameters. |
sig |
The sum of squred errors of the kink model. |
sta <- proc.time() ##Simulated data set.seed(12345) n=200 x = rnorm(n) q = rnorm(n) rt = 0.2 - 0.5*q z = rnorm(n) x1 = cbind(neg.part(x-rt),pos.part(x-rt),z) b0 =c(1,2,1) y = b0[1]*x1[,1]+b0[2]*x1[,2]+b0[3]*x1[,3]+ rnorm(n) # set grid search paramaters r01 = 0 r02 = 2 stp1 = 0.1 r11 = -10 r12 = 5 stp2 = 0.1 # estimate the model with a state-dependent threshold est1 <- rkt(y,x,z,q,r01,r02,r11,r12,stp1,stp2) proc.time() - sta
sta <- proc.time() ##Simulated data set.seed(12345) n=200 x = rnorm(n) q = rnorm(n) rt = 0.2 - 0.5*q z = rnorm(n) x1 = cbind(neg.part(x-rt),pos.part(x-rt),z) b0 =c(1,2,1) y = b0[1]*x1[,1]+b0[2]*x1[,2]+b0[3]*x1[,3]+ rnorm(n) # set grid search paramaters r01 = 0 r02 = 2 stp1 = 0.1 r11 = -10 r12 = 5 stp2 = 0.1 # estimate the model with a state-dependent threshold est1 <- rkt(y,x,z,q,r01,r02,r11,r12,stp1,stp2) proc.time() - sta