# NOT RUN {
set.seed(3)
xgrid1 = seq(0,10,by=0.2)
xgrid2 = seq(10.2,20,by=0.2)
xgrid3 = seq(20.2,30,by=0.2)
ygrid1 = xgrid1^2-xgrid1+1+ rnorm(length(xgrid1),0,3)
ygrid2 = rep(91,length(xgrid2))+ rnorm(length(xgrid2),0,3)
ygrid3 = -10*xgrid3+300+rnorm(length(xgrid3),0,3)
xgrid = c(xgrid1,xgrid2,xgrid3)
ygrid = c(ygrid1,ygrid2,ygrid3)
#Inference of a polynomial regression model with three regimes on these data.
#The degree of the polynomials is fixed to 2 and the parameters are estimated
# under continuity constraint when the times of jump are fixed to 10 and 20.
HKSPOR(xgrid,ygrid,2,3,1,EM = FALSE,c(10,20))
# }
# NOT RUN {
set.seed(3)
xgrid1 = seq(0,10,by=0.2)
xgrid2 = seq(10.2,20,by=0.2)
xgrid3 = seq(20.2,30,by=0.2)
ygrid1 = xgrid1^2-xgrid1+1+ rnorm(length(xgrid1),0,3)
ygrid2 = rep(91,length(xgrid2))+ rnorm(length(xgrid2),0,3)
ygrid3 = -10*xgrid3+300+rnorm(length(xgrid3),0,3)
xgrid = c(xgrid1,xgrid2,xgrid3)
ygrid = c(ygrid1,ygrid2,ygrid3)
#Inference of a polynomial regression model with three regimes (K=3) on these data.
#The degree of the polynomials is fixed to 2 and the parameters are estimated
#under continuity constraint.
HKSPOR(xgrid,ygrid,2,3,1)
#Executed time : 49.70051 mins (intel core i7 processor)
# }
Run the code above in your browser using DataLab