Skip to main content
Skip table of contents

plotResidualsScatterPlot

Plot the scatter plots of the residuals.

Usage

R
plotResidualsScatterPlot(
  obsName = NULL,
  residuals = c("indiv"),
  xaxis = c("time", "prediction"),
  settings = list(),
  preferences = list(),
  stratify = list()
)

Arguments

obsName

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

residuals

(character) List of residuals to display: population residuals ("pop"), individual residuals ("indiv"), normalized prediction distribution error ("npde") (default c("indiv")).

xaxis

(character) List of x-axis to display: time ("time"), prediction ("prediction") (default c("time", "prediction") for continuous data, c("time") for discrete data).

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"). For continuous data only

  • level (integer) level for prediction intervals computation (default 90).

  • higherPercentile (integer) Higher percentile for empirical and predicted percentiles computation (default 90).

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

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

  • binsSettings a list of settings for bins:

    • criteria (character) Bining criteria, one of 'equalwidth', 'equalsize', or 'leastsquare' methods. (default leastsquare).

    • is.fixedNbBins (logical) If TRUE define a fixed number of bins, else define a range for automatic selection (default TRUE).

    • nbBins (integer) Define a fixed number of bins (default 10).

    • binRange (vector(integer, integer)) Define a range for the number of bins (default c(5, 100)).

    • nbBinData (vector(integer, integer)) Define a range for the number of data points per bin (default c(10, 200)).

  • residuals (logical) - If TRUE display residuals (default TRUE).

  • cens (logical) - If TRUE display censored data (default TUE).

  • empPercentiles (logical) - If TRUE display empirical percentiles (default FALSE).

  • predPercentiles (logical) - If TRUE display predicted percentiles (default FALSE).

  • predInterval (logical) - If TRUE, Prediction interval is displayed (default FALSE).

  • outlierDots (logical) - If TRUE Add red dots indicating empirical percentiles that are outside prediction intervals (default TRUE).

  • outlierAreas (logical) - If TRUE Add red areas indicating empirical percentiles that are outside prediction intervals (default TRUE).

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

  • binLimits (logical) - If TRUE Add bins limits as vertical lines (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).

  • 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").

preferences

(optional) preferences for plot display, run getPlotPreferences("plotResidualsScatterPlot") 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").

Value

  • A ggplot object if one prediction type,

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

Details

Note that 'prediction interval' setting is not available in 2021 version for this connector.

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()

  plotResidualsScatterPlot()
R

#> TableGrob (1 x 1) "arrange": 1 grobs
#>   z     cells    name            grob
#> 1 1 (1-1,1-1) arrange gtable[arrange]
  plotResidualsScatterPlot(residuals = "indiv", settings = list(indivEstimate = "simulated"))
R

#> TableGrob (1 x 1) "arrange": 1 grobs
#>   z     cells    name            grob
#> 1 1 (1-1,1-1) arrange gtable[arrange]
  plotResidualsScatterPlot(residuals = "indiv", settings = list(indivEstimate = "mode"))
R

#> TableGrob (1 x 1) "arrange": 1 grobs
#>   z     cells    name            grob
#> 1 1 (1-1,1-1) arrange gtable[arrange]
  plotResidualsScatterPlot(xaxis = "prediction", residuals = "pop")
R

  plotResidualsScatterPlot(xaxis = "time", residuals = "pop")
R

  plotResidualsScatterPlot(residuals = "npde")
R

#> TableGrob (1 x 1) "arrange": 1 grobs
#>   z     cells    name            grob
#> 1 1 (1-1,1-1) arrange gtable[arrange]
  plotResidualsScatterPlot(settings = list(spline = T))
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's linetype values.
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's linetype values.
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's linetype values.
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's linetype values.
R

#> TableGrob (1 x 1) "arrange": 1 grobs
#>   z     cells    name            grob
#> 1 1 (1-1,1-1) arrange gtable[arrange]
  plotResidualsScatterPlot(settings = list(empPercentiles = T, level = 90,
                                           binsSettings = list(is.fixedNbBins = T, nbBins = 5),
                                           binLimits = T))
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's linetype values.
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's linetype values.
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's linetype values.
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's linetype values.
R

#> TableGrob (1 x 1) "arrange": 1 grobs
#>   z     cells    name            grob
#> 1 1 (1-1,1-1) arrange gtable[arrange]
  plotResidualsScatterPlot(residuals = c("indiv", "pop"),
                           settings = list(indivEstimate = "simulated"))
R

#> TableGrob (1 x 1) "arrange": 1 grobs
#>   z     cells    name            grob
#> 1 1 (1-1,1-1) arrange gtable[arrange]
  plotResidualsScatterPlot(residuals = "indiv", xaxis = c("prediction"),
                           settings = list(indivEstimate = "mode"))
R

  plotResidualsScatterPlot(xaxis = c("prediction"), residuals = c("indiv", "pop"))
R

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

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

  # Stratification
  plotResidualsScatterPlot(stratify = list(filter = list("SEX", "F")))
R

#> TableGrob (1 x 1) "arrange": 1 grobs
#>   z     cells    name            grob
#> 1 1 (1-1,1-1) arrange gtable[arrange]
  plotResidualsScatterPlot(stratify = list(split = "WEIGHT",
                                           groups = list(name = "WEIGHT", definition = c(75))))
R

#> TableGrob (1 x 1) "arrange": 1 grobs
#>   z     cells    name            grob
#> 1 1 (1-1,1-1) arrange gtable[arrange]
  plotResidualsScatterPlot(stratify = list(color = "WEIGHT",
                                           groups = list(name = "WEIGHT", definition = c(75))))
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.