| dsps_predict | R Documentation |
Predicted event time based on DSP method.
dsps_predict(fit, newdata)
fit |
is the return object from function |
newdata |
a dataframe in which to look for time-dependent covariates with which to predict.
The last two columns, in order, are time ( |
a dataframe with predicted event time
## Example 1 - With training data splitting
set.seed(1236)
dat <- sim_data(n=100, er=0.6)
# Split the data by 7/3
subject_list <- unique(dat$Z$subjectid)
train_id <- sample(subject_list, round(length(subject_list)*0.7))
test_id <- subject_list[!subject_list %in% train_id]
# Data for training, keep only at risk data points
dat_train <- dat$Z %>%
filter(at_risk == 1) %>%
filter(subjectid %in% train_id) %>%
select(-at_risk)
fit <- dsp_fit(dat_train,
C=2^2,
kernel="semi_linear")
# Data for testing
newdata <- dat$Z %>%
filter(subjectid %in% test_id) %>%
select(-at_risk, -event)
# Making prediction
predict.dsp <- dsp_predict(fit, newdata = newdata)
## Example 2 - Make event time prediction for large testing data
set.seed(1236)
dat <- sim_data(n=100, er=0.6)
dat_train <- dat$Z %>%
filter(at_risk == 1) %>%
select(-at_risk)
fit <- dsp_fit(dat_train,
C=2^2,
kernel="semi_linear")
dat_test <- sim_data(n=1000, er=1, time_points=fit$train_dat$unq_t_obs)
predict.dsp <- dsp_predict(fit, select(dat_test$Z, -at_risk, -event))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.