thr_sse <- function(y,q,r){
nq <- nrow(q)
sse <- matrix(c(0),nq,1)
for (qi in 1:nq){
if (r[1]==0) {rr <- q[qi]
}else{ rr <- rbind(r,q[qi])}
rr <- as.matrix(sort(rr))
xx <- cbind(xt,ct)
for (j in 1:nrow(rr)){
d <- (thresh < rr[j])
xx <- cbind(xx,tr(cf*d))
}
sse[qi] <- sse_calc(y,xx)
}
sse
}