Commit fe733620 authored by Kevin's avatar Kevin

changed definition of locf

parent 2350ad89
......@@ -18,11 +18,11 @@ df <- readRDS(inputfile) %>%
)
)
impute_locf <- function(t, GOSE, tolerance, t_pred) {
impute_locf <- function(t, GOSE, t_pred) {
res <- numeric(length(t_pred))
res[] <- NA_integer_
for (i in 1:length(t_pred)) {
res[i] <- GOSE[t < t_pred[i] + tolerance] %>%
res[i] <- GOSE[t < t_pred[i] & t > 76] %>%
tail(1) %>% # use last if multiple available
ifelse(length(.) == 0, NA, .)
}
......@@ -34,7 +34,11 @@ df_posteriors <- df %>%
arrange(gupi, Outcomes.DerivedCompositeGOSE) %>%
do(
t = config$t_out,
GOSE_predicted = impute_locf(.$Outcomes.DerivedCompositeGOSEDaysPostInjury, .$Outcomes.DerivedCompositeGOSE %>% as.character %>% as.integer, config$t_buffer, config$t_out)
GOSE_predicted = impute_locf(
.$Outcomes.DerivedCompositeGOSEDaysPostInjury,
.$Outcomes.DerivedCompositeGOSE %>% as.character %>% as.integer,
config$t_out
)
) %>%
unnest %>%
mutate(
......
......@@ -41,8 +41,8 @@ imputations.
```{r, fig.height=7, fig.width=7}
caret::confusionMatrix(
df_imputations$Subject.DerivedImputed180DaysGOSE %>% factor,
df_imputations$Subject.GOSE6monthEndpointDerived %>% factor
df_imputations$Subject.DerivedImputed180DaysGOSE %>% factor(levels = 1:8),
df_imputations$Subject.GOSE6monthEndpointDerived %>% factor(levels = 1:8)
) %>%
as.matrix %>% as_tibble %>%
mutate(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment