Skip to main content
Skip table of contents

plotObservationsVsPredictions

Plot the observation vs the predictions.

Usage

R
plotObservationsVsPredictions(
  obsName = NULL,
  predictions = c("indiv"),
  settings = list(),
  preferences = list(),
  stratify = list()
)

Arguments

obsName

(character) Name of the observation (in dataset header). By default the first observation is considered.

predictions

(character) LIst of predictions to display: population prediction ("pop"), individual prediction ("indiv") (default c("indiv")).

settings

List with the following settings

  • indivEstimate (character) Calculation of individual estimates: conditional mean ("mean"), conditional mode with EBE's ("mode"), conditional distribution ("simulated") (default "mode").

  • useCensored (logical) Choose to use BLQ data (TRUE) or to ignore it (FALSE) to compute the statistics (default TRUE).

  • censoring (character) BLQ data can be simulated ('simulated'), or can be equal to the limit of quantification ('loq') (default 'simulated').

  • obs (logical) - If TRUE observations are displayed as dots (default TRUE).

  • cens (logical) - If TRUE censoring data are displayed as red dots (default TRUE).

  • spline (logical) - If TRUE add spline (default FALSE).

  • identityLine (logical) - If TRUE add identity line (default TRUE).

  • predInterval (logical) - If TRUE add 90% prediction interval (default FALSE).

  • legend (logical) add (TRUE) / remove (FALSE) plot legend (default FALSE).

  • grid (logical) add (TRUE) / remove (FALSE) plot grid (default TRUE).

  • xlog (logical) add (TRUE) / remove (FALSE) log scaling on x axis (default FALSE).

  • ylog (logical) add (TRUE) / remove (FALSE) log scaling on y axis (default FALSE).

  • ncol (integer) number of columns when facet = TRUE (default 4).

  • xlim (c(double, double)) limits of the x axis.

  • ylim (c(double, double)) limits of the y axis.

  • fontsize (integer) Plot text font size.

  • scales (character) Should scales be fixed ("fixed"), free ("free", the default), or free in one dimension ("free_x", "free_y") (default "free").

  • ylab (character) label on y axis (default "Observations").

preferences

(optional) preferences for plot display, run getPlotPreferences("plotObservationsVsPredictions") to check available displays.

stratify

List with the stratification arguments:

  • groups - Definition of stratification groups. By default, stratification groups are already defined as one group for each category for categorical covariates, and two groups of equal number of individuals for continuous covariates. To redefine groups, for each covariate to redefine, specify a list with:

    namecharactercovariate name (e.g "AGE")
    definition(vector(continuous) || list>(categorical))For continuous covariates, vector of break values (e.g c(35, 65)). For categorical covariates, groups of categories as a list of vectors(e.g list(c("study101"), c("study201","study202")))
  • split (vector) - Vector of covariates used to split (i.e facet) the plot (by default no split is applied). For instance c("FORM","AGE").

  • filter (list< list> >) - List of pairs containing a covariate name and the vector of indexes or categories (for categorical covariates) of the groups to keep (by default no filtering is applied). For instance, list("AGE",c(1,3)) to keep the individuals belonging to the first and third age group, according to the definition in groups. For instance, list("FORM","ref") using the category name for categorical covariates.

  • color (vector) - Vector of covariates used for coloring (by default no coloring is applied). For instance c("FORM","AGE").

  • colors - Vector of colors to use when color argument is used. Takes precedence over colors defined in preferences. For instance c("#ebecf0","#cdced1","#97989c").

  • individualSelection - Ids to display (by default the 12 first ids are displayed) defined as:

    • indices (vector) - Indices of the individuals to display (by default, the 12 first individuals are selected). If occasions are present, all occasions of the selected individuals will be displayed. Takes precedence over ids. For instance c(5,6,10,11).

    • isRange (logical) - If TRUE, all individuals whose index is inside [min(indices), max[indices]] are selected (FALSE by default). Forced to FALSE if ids is defined.

    • ids (vector) - Names of the individuals to display. If occasions are present, all occasions of the selected individuals will be displayed. For instance c("101-01","101-02","101-03"). If ids are integers, can also be c(1,3,6). Ignored if indices is defined.

Value

  • A ggplot object if one prediction type,

  • A TableGrob object if multiple plots (output of grid.arrange)

Examples

R
  initializeLixoftConnectors(software = "monolix")
  project <- file.path(getDemoPath(), "1.creating_and_using_models",
                       "1.1.libraries_of_models", "theophylline_project.mlxtran")
  loadProject(project)

  runPopulationParameterEstimation()
  runConditionalDistributionSampling()
  runConditionalModeEstimation()

  plotObservationsVsPredictions()
R

  plotObservationsVsPredictions(predictions = "pop")
R

  plotObservationsVsPredictions(prediction = "indiv", settings = list(indivEstimate = "simulated"))
R

  plotObservationsVsPredictions(settings = list(indivEstimate = "mean", spline = TRUE))
R

  plotObservationsVsPredictions(settings = list(indivEstimate = "mode", predInterval = TRUE))
R

  plotObservationsVsPredictions(settings = list(ylog = TRUE, xlog = TRUE))
R


  # stratification
  plotObservationsVsPredictions(stratify = list(filter = list("SEX", "F")))
R

  plotObservationsVsPredictions(stratify = list(split = "WEIGHT",
                                                groups = list(name = "WEIGHT", definition = 75)))
R

  plotObservationsVsPredictions(stratify = list(color = "WEIGHT",
                                                groups = list(name = "WEIGHT", definition = 75)))
R

  plotObservationsVsPredictions(settings = list(legend = T),
                                stratify = list(color = c("SEX", "WEIGHT"),
                                                groups = list(name = "WEIGHT", definition = 70)))
R


  # display multiple predictions
  plotObservationsVsPredictions(predictions = c("pop", "indiv"))
R

#> TableGrob (1 x 1) "arrange": 1 grobs
#>   z     cells    name            grob
#> 1 1 (1-1,1-1) arrange gtable[arrange]

JavaScript errors detected

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

If this problem persists, please contact our support.