# \donttest{
# Toy data example to illustrate implementation
n = 300
beta = c(0.5)
lambd = 0.35
eta = c(0.9,0.4)
X = cbind(rbinom(n,1,0.5))
W = cbind(rep(1,n),rbinom(n,1,0.5))
# generate dependency structure from Frank
frank.cop <- copula::frankCopula(param = 5,dim = 2)
U = copula::rCopula(n,frank.cop)
T1 = (-log(1-U[,1]))/(lambd*exp(X*beta)) # Survival time
T2 = (-log(1-U[,2]))^(1.1)*exp(W%*%eta) # Censoring time
A = runif(n,0,15) # administrative censoring time
Z = pmin(T1,T2,A)
d1 = as.numeric(Z==T1)
d2 = as.numeric(Z==T2)
resData = data.frame("Z" = Z,"d1" = d1, "d2" = d2) # should be data frame
colnames(W) <- c("ones","cov1")
colnames(X) <- "cov.surv"
# Fit dependent censoring model
fit <- fitDepCens(resData = resData, X = X, W = W, bootstrap = FALSE)
# parameter estimates
fit$parameterEstimates
# summary fit results
summary(fit)
# plot cumulative hazard vs time
plot(fit$observedTime, fit$cumhazardFunction, type = "l",xlab = "Time",
ylab = "Estimated cumulative hazard function")
# }
Run the code above in your browser using DataLab