# \donttest{
library(grpreg)
# Generate simulated data with 500 samples and normal error distribution
dataset <- MTAFT_simdata(n = 500, err = "normal")
Y <- dataset[, 1]
delta <- dataset[, 2]
Tq <- dataset[, 3]
X <- dataset[, -c(1:3)]
n1 = sum(delta)
c=seq(0.5,1.5,0.1)
m=ceiling(c*sqrt(n1))
bicy= rep(NA,length(c))
tsmc=NULL
p = ncol(X)
for(i in 1:length(c)){
tsm=try(TSMCP(Y,X,delta,c[i],penalty = "scad"),silent=TRUE)
if(is(tsm,"try-error")) next()
bicy[i]=log(n)*((length(tsm[[1]])+1)*(p+1))+n*log(tsm[[3]])
tsmc[[i]]=tsm
}
if((any(!is.na(bicy)))){
tsmcp=tsmc[[which(bicy==min(bicy))[1]]]
thre.LJ = Tq[tsmcp[[1]]]
thre.num.Lj = length(thre.LJ)
thre.LJ
thre.num.Lj
}
# }
Run the code above in your browser using DataLab