dtest <- test_relations(param = c("KA", "K", "V"),
cov = c("LIN1", "LIN2", "LIN3", "RND1", "RND2", "RND3"),
state = c("linear", "power"),
continuous = TRUE) %>%
test_relations(param = c("KA", "K", "V"),
cov = "BN1",
state = "linear",
continuous = FALSE)
# create example object m1 from package demo files
exdir <- system.file("extdata", "examples", "theopp", package = "NMproject")
m1 <- new_nm(run_id = "m1",
based_on = file.path(exdir, "Models", "ADVAN2.mod"),
data_path = file.path(exdir, "SourceData", "THEOPP.csv"))
temp_data_file <- paste0(tempfile(), ".csv")
## dataset has missing WTs so create a new one and assign this to the run
input_data(m1) %>%
dplyr::group_by(ID) %>%
dplyr::mutate(WT = na.omit(WT)) %>%
write_derived_data(temp_data_file)
m1 <- m1 %>% data_path(temp_data_file)
dtest <- test_relations(param = c("K", "V"),
cov = c("WT"),
state = c("linear", "power"),
continuous = TRUE)
## requires NONMEM to be installed
if (FALSE) {
## create tibble of covariate step with model objects as column m
dsm1 <- m1 %>% covariate_step_tibble(run_id = "m1_f1",
dtest = dtest,
direction = "forward")
## run all models greedily
dsm1$m <- dsm1$m %>% run_nm()
## extract results and put into tibble
dsm1 <- dsm1 %>% bind_covariate_results()
## sort by BIC (for example) and view
dsm1 <- dsm1 %>% arrange(BIC)
dsm1
## check condition number, covariance,...
## run any diagnostics here
## when happy with selection, select run for subsequent step
m1_f1 <- dsm1$m[1] ## select most signifcant BIC
# alternative select by relationship
m1_f1 <- dsm1 %>%
filter(param = "CL", cov = "BWT", state = "power") %$%
m
## do next forward step
dsm2 <- m1_f1 %>% covariate_step_tibble(run_id = "m1_f2",
dtest = dtest,
direction = "forward")
## continue ...
}
Run the code above in your browser using DataLab