| add_remove_covs | R Documentation | 
Follows PsN coding conventions to add covariates into a model.  The advantage
is no need to create a .scm file, just directly modify the NONMEM control
file contents. This function is used by covariate_step_tibble() for
stepwise covariate model development.
add_cov(
  ctl,
  param,
  cov,
  state = 2,
  continuous = TRUE,
  time_varying,
  additional_state_text = list(),
  id_var = "ID",
  force = FALSE,
  force_TV_var = FALSE,
  init,
  lower,
  upper
)
remove_cov(
  ctl,
  param,
  cov,
  state = 2,
  continuous = TRUE,
  time_varying,
  id_var = "ID"
)
| ctl | An nm object or an object coercible to  | 
| param | Character. Name of parameter. | 
| cov | Character. Name of covariate. | 
| state | Numeric or character. Number or name of state (see details). | 
| continuous | Logical (default =  | 
| time_varying | Optional logical. is the covariate time varying? | 
| additional_state_text | Optional character (default = empty). Custom
state variable to be passed to  | 
| id_var | Character (default =  | 
| force | Logical (default = 'FALSEā). Force covariate in even if missing values found. | 
| force_TV_var | Logical (default =  | 
| init | Optional numeric/character vector. Initial estimate of additional parameters. | 
| lower | Optional numeric/character vector. lower bound of additional parameters. | 
| upper | Optional numeric/character vector. Upper bound of additional parameters. | 
Available states:
PARCOV= ( 1 + THETA(1)*(COV -median))
IF(COV.LE.median) PARCOV = ( 1 + THETA(1)*(COV - median)) IF(COV.GT.median) PARCOV = ( 1 + THETA(2)*(COV - median))
PARCOV= EXP(THETA(1)*(COV - median))
PARCOV= ((COV/median)**THETA(1))
PARCOV= ((COV/median))
PARCOV= ((COV/median)**0.75)
PARCOV= ( 1 + THETA(1)*(LOG(COV) - log(median)))
remove_cov only works with covariates added with add_cov.
An nm object with modified ctl_contents field.
covariate_step_tibble(), test_relations()
# 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)
 
m1WT <- m1 %>% child("m1WT") %>%
  add_cov(param = "V", cov = "WT", state = "power")
m1 %>% dollar("PK")
m1WT %>% dollar("PK")  ## notice SCM style code added
nm_diff(m1WT)
## Not run: 
run_nm(c(m1, m1WT))
rr(c(m1, m1WT))
summary_wide(c(m1, m1WT)) 
## End(Not run)
unlink(temp_data_file)
# 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)
 
m1WT <- m1 %>% child("m1WT") %>%
  add_cov(param = "V", cov = "WT", state = "power")
m1 %>% dollar("PK")
m1WT %>% dollar("PK")  ## notice SCM style code added
## reverse this by removing WT
m1noWT <- m1WT %>% child("m1noWT") %>%
  remove_cov(param = "V", cov = "WT") 
  
m1noWT %>% dollar("PK")
m1noWT %>% dollar("THETA")
unlink(temp_data_file)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.