# NOT RUN {
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
# }
Run the code above in your browser using DataLab