Skip to contents

This function creates a directory structure for a risk factor and populates it with various XML files containing risk factor data.

Usage

write_risk_factor_dir(
  risk_factor_name,
  transition_matrix_list,
  transition_drift_list,
  relative_risks_death_list,
  prevalences_list,
  prevalences_duration_list,
  relative_risks_disability_list,
  risk_factor_configuration
)

Arguments

risk_factor_name

A character string specifying the name of the risk factor. A directory will be created with this name if it does not already exist.

transition_matrix_list

A list of transition matrices, where each element contains a list with 'data' and 'type' components.

transition_drift_list

A list of transition drifts, where each element contains a list with 'data', 'type', and 'trend' components.

relative_risks_death_list

A list of relative risks for death, where each element contains a list with 'data' and 'type' components.

prevalences_list

A list of prevalences, where each element contains a list with 'data', 'type', and 'distribution' components.

prevalences_duration_list

A list of prevalence durations, where each element contains a list with a `'data'“ component.

relative_risks_disability_list

A list of relative risks for disability, where each element contains a list with 'data' and 'type' components.

risk_factor_configuration

A list of risk factor configurations containing 'data', 'reference', and 'type' components.

Value

A logical value: TRUE if the directory structure was successfully created.

Details

The function creates a directory named after the disease and subdirectories for:

  • Transitions

  • Relative_Risks_For_Disability

  • Relative_Risks_For_Death

  • Prevalences

  • DurationDistributions

  • configuration.xml

For each category, the function generates XML files based on the data provided in the corresponding input list. Each XML file is saved in the appropriate subdirectory.

The transition matrix and drift type can be 'zero' or 'netto'. The risk factor 'type' can be 'continuous', 'categorical', or 'compound'. For prevalences_list, only 'continuous' and 'categorical' are valid types.

Examples

if (FALSE) { # \dontrun{
# A list element corresponds to a population
transition_matrix_list <- list("NL" = list(data = data.frame(...), type = "zero"))
transition_drift_list <- list("NL" = list(data = data.frame(...), type = "zero"))

prevalences_list <- list("NL" = list(data = data.frame(...), type = "continuous", distribution = "normal"))
prevalences_duration_list <- list("NL" = list(data = data.frame(...)))

# A list element corresponds to a risk factor
relative_risks_death_list <- list("continuous" = list(data = data.frame(...), type = "continuous"))
relative_risks_disability_list <- list("continuous" = list(data = data.frame(...), type = "continuous"))

# Configuration for which risk factor element to use
risk_factor_configuration <- list(data = data.frame(...), reference = list(referencevalue = 0.5), type = "continuous")

create_risk_factor_dir(
  "smoking",
  transition_matrix_list = transition_matrix_list,
  transition_drift_list = transition_drift_list,
  relative_risks_death_list = relative_risks_death_list,
  prevalences_list = prevalences_list,
  prevalences_duration_list = prevalences_duration_list,
  relative_risks_disability_list = relative_risks_disability_list,
  risk_factor_configuration_list = risk_factor_configuration
)
} # }