Skip to main content
Skip table of contents

defineOccasionElement

Define the occasion structure of the project.

Usage

R
defineOccasionElement(element)

Arguments

element

(character or dataFrame or list) Element definition from external file path or data frame with time and occasion levels as columns, or list to select the sheet of an excel file:

  • file (character) Path to the occasion file.

  • sheet (character) Name of the sheet in xlsx/xls file.

Details

The occasion structure of a project is defined and used for simulation as in Simulx GUI. The occasion element impacts the definition of other elements and the simulation. As for other elements, the occasion element can be defined or imported, and it is saved with the Simulx project if calling saveProject.

If can be defined as an external file (csv, xlsx, xlsx, sas7bdat, xpt or txt) or as a data.frame.

In any case, it should contain a column time and one column per occasion level. The header names for these occasion levels are free and used by Simulx.

A data frame can be used only to define a common structure of occasions applied to all simulated subjects.

An external file can be used in all cases (common or subject-specific structure). It can contain a column id (optional) in addition to other columns. When the id column is not present, the occasion structure is considered common.

After defining a subject-specific occasion structure, other elements (parameters, covariates, treatments, outputs and regressors) must be either common over all subjects and all occasions, or can be defined with subject-specific occasion-wise values as an external table, with the same occasion structure.

Examples

R
if (FALSE) {
defineOccasionElement(element = "file/path")
defineOccasionElement(element = list(file = "file/path", sheet = "sheet_name"))
defineOccasionElement(element = data.frame(time = c(0, 0.5, 2), occ1 = c(1, 1, 2), occ2 = c(1, 2, 3)))
}

  # Example: define subject-specific occasions through external file
  initializeLixoftConnectors("simulx")
  project_name <- file.path(getDemoPath(), "5.simulation", "replicates.smlx")
  loadProject(project_name)
  occasions <- data.frame(id = c(1, 1, 2, 2), time = c(0, 24, 0, 36), occ = c(1, 2, 1, 2))
  file_name <- tempfile("cov", fileext = ".csv")
  write.csv(occasions, file_name, row.names = FALSE)
  defineOccasionElement(element = file_name)

  # Example: define common occasions through data.frame
  initializeLixoftConnectors("simulx")
  project_name <- file.path(getDemoPath(), "5.simulation", "replicates.smlx")
  loadProject(project_name)
  defineOccasionElement(element = data.frame(time = c(0, 0.5, 2), occ1 = c(1, 1, 2), occ2 = c(1, 2, 3)))
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.