Help for package RegKink (original ) (raw )
Type:
Package
Version:
0.1.0
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 >.
Imports:
MASS
Depends:
R (≥ 3.5.0)
License:
GPL-2 | GPL-3 [expanded from: GPL]
Encoding:
UTF-8
RoxygenNote:
7.1.1
Author:
Lixiong Yang [aut, cre]
Maintainer:
Lixiong Yang ylx@lzu.edu.cn
NeedsCompilation:
no
Packaged:
2021-04-13 07:58:25 UTC; ylx
Repository:
CRAN
Date/Publication:
2021-04-15 07:30:06 UTC
negtive part of a variable DescriptionThis is a function computing the negtive part of a variable.
Usageneg.part(x)
Arguments Value
ne
The negative part of a variable.
Examples
pt1 <- proc.time()
##Simulated data
set.seed(12345)
n=200
x = rnorm(n)
obj <- neg.part(x)
proc.time() - pt1
positive part of a variable DescriptionThis is a function computing the positive part of a variable.
Usagepos.part(x)
Arguments Value
ps
The positive part of a variable.
Examples
pt1 <- proc.time()
##Simulated data
set.seed(12345)
n=200
x = rnorm(n)
obj <- pos.part(x)
proc.time() - pt1
linear regression DescriptionThis is a function computing OLS estimates of linear model.
Usagereg(X,y)
Arguments
y
A vector of response.
X
data matrix
Value
bols
The ols estimates of a linear regression model.
Examples
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
Estimation for regression kink with a time-varying threshold DescriptionThis is a function estimating regression kink with a time-varying threshold.
Usagerkt(y,x,z,q,r01,r02,r11,r12,stp1,stp2)
Arguments
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
ValueA 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.
Examples
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