# NOT RUN {
set.seed(123)
library(MASS)
library(survival)
numbeta=50
N=100
beta0=matrix(0, numbeta, 1)
sigma1=0.5^abs(outer(1:numbeta, 1:numbeta, "-"))
W1=mvrnorm(N, beta0, sigma1, tol=1e-8, empirical=FALSE)
Z1=W1^2-1
### produce quadratic and two-way interaction effects ###
tempZZ1=matrix(Z1^2, N, numbeta)
tempZZ2=model.matrix(~(.)^2 - . -1, data=data.frame(Z1))
AZ=cbind(Z1, cbind(tempZZ1, tempZZ2))
### identify true predictors: G1, G10, G1&G1, G10&G10, G1&G10, G10&G20 ###
a=3
beta=matrix(0, dim(AZ)[2], 1)
beta[1,]=-0.8*a
beta[10,]=a
beta[51,]=1.2*a
beta[60,]=a
beta[109,]=-1.2*a
beta[515,]=a
### simulate survival time follows linear transformation model ###
C=matrix(runif(N,0,1), N, 1)
ST=X=S=matrix(0, N, 1)
temp=rexp(N)
ST=as.numeric(0.5*log(2*temp*exp(-AZ%*%beta)+1))
X=pmin(ST, C)
S=(ST==X)
survdata=cbind(X, S, Z1)
### perform IPCWK function ###
test=IPCWK(data=survdata, standarize="FALSE")
true=which(beta!=0)
sum(order(-abs(test$CORR[1,]))[1:20] %in% true) ### IPCW-tau
sum(order(-abs(test$CORR[2,]))[1:20] %in% true) ### Kendall's tau
sum(order(-abs(test$CORR[3,]))[1:20] %in% true) ### PC-IPCW-tau
# }
Run the code above in your browser using DataLab