MonolixSuite in R
Auto Light Dark
Auto Light Dark

plotIndividualFits

[Monolix] Plot Monolix Individual Fits

Plot the individual fits.

Usage

R
plotIndividualFits(
  obsName = NULL,
  settings = list(),
  preferences = list(),
  stratify = list()
)

Arguments

obsName

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

settings

List with the following settings

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

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

  • obsLines (logical) - If TRUE individual observations are displayed as lines (default FALSE).

  • cens (logical) - If TRUE censored intervals are displayed (default TRUE).

  • indivFits (logical) - If TRUE individual fits are displayed (default TRUE).

  • popFits (logical) - If TRUE population fits (typical individual) are displayed (default FALSE).

  • popCov (logical) - If TRUE population fits (individual covariates) are displayed (default FALSE).

  • predMedian (logical) - If TRUE median of individual fits computed based on multiple simulations (default FALSE).

  • predInterval (logical) - If TRUE 90 % prediction interval of individual fits computed based on multiple simulations (default FALSE).

  • splitOccasions (logical) - If TRUE occasions are displayed on separate plots (default TRUE).

  • dosingTimes (logical) - Add dosing times 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).

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

  • xlab (character) label on x axis (default "Time").

  • ylab (character) label on y axis (default obsName).

  • 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("plotIndividualFits") 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:

    name

    character

    covariate 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")))

  • 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

Details

Only available for Continuous data.

See also

getChartsData getPlotPreferences

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

  plotIndividualFits()
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's fill values.
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's linetype values.

Default plotIndividualFits output for the theophylline demo. A 3 by 4 grid of panels, id 1 to id 12, shows CONC versus time from 0 to 25. Each panel has the observed concentrations as blue dots and the individual fit as a purple curve that rises quickly to a peak of about 6 to 10 and then declines. The fits follow the data closely.
R


  plotIndividualFits(settings=list(popFits = T))
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's fill values.
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's linetype values.

plotIndividualFits output with population fits added. In each of the 12 panels, id 1 to id 12, CONC versus time shows observed blue dots, the purple individual fit and a green dashed population fit. The population fit departs from the data more than the individual fit, for example lower than the data for id 1 and higher for id 7.
R

  plotIndividualFits(settings=list(obsLines = T, obsDots = F, predInterval = T))
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's linetype values.

plotIndividualFits output with observations shown as lines instead of dots and the prediction interval displayed. Each of the 12 panels, id 1 to id 12, shows CONC versus time with a blue line joining the observations, the purple individual fit and a light blue shaded prediction interval around it.
R

  plotIndividualFits(settings=list(dosingTimes = T))
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's fill values.
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's linetype values.

plotIndividualFits output with dosing times displayed. The 12 panels of CONC versus time, id 1 to id 12, show observed blue dots and the purple individual fit, plus a vertical black dashed line at time 0 marking the dose in each panel.
R


  # stratification options
  plotIndividualFits(stratify = list(individualSelection = list(ids = c(1, 2, 3, 4))))
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's fill values.
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's linetype values.

plotIndividualFits output with individuals selected by id 1, 2, 3 and 4. Four side by side panels show CONC versus time, with observed blue dots and the purple individual fit rising to a peak of about 8 to 10 within the first few hours and then declining.
R

  plotIndividualFits(stratify = list(individualSelection = list(indices = c(1, 4), isRange = TRUE)))
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's fill values.
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's linetype values.

plotIndividualFits output with a range of indices from 1 to 4, giving the same four panels as the selection by id, id 1 to id 4. Each panel shows CONC versus time with observed blue dots and the purple individual fit.
R

  plotIndividualFits(stratify = list(filter = list("WEIGHT", 2),
                                     groups = list(name = "WEIGHT", definition = c(60, 75))))
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's fill values.
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's linetype values.

plotIndividualFits output filtered to the second WEIGHT group, defined by breaks at 60 and 75. Seven panels remain, id 2, 3, 4, 7, 8, 11 and 12, each showing CONC versus time with observed blue dots and the purple individual fit.
R

  plotIndividualFits(stratify = list(filter = list("SEX", "F")))
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's fill values.
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's linetype values.

plotIndividualFits output filtered to SEX F. Five panels remain, id 5, 7, 10, 11 and 12, each showing CONC versus time with observed blue dots and the purple individual fit.
R

  plotIndividualFits(stratify = list(color = "SEX",
                                     colors=c("#5DC088", "#DBA92B")))
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's fill values.

plotIndividualFits output with observations colored by SEX using custom colors. In the 12 panels of CONC versus time, the dots are green for id 5, 7, 10, 11 and 12 and gold for the other individuals, with the purple individual fit in each panel. No legend is shown.
R

  plotIndividualFits(settings = list(legend = T),
                     stratify = list(color = c("SEX", "WEIGHT"),
                                     groups = list(name = "WEIGHT", definition = 70)))
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's fill values.

plotIndividualFits output colored by SEX and WEIGHT groups, break at 70, with the legend shown. The 12 panels of CONC versus time have purple dots for SEX M, WEIGHT 70-86.4 and olive dots for SEX F, WEIGHT 54.6-70, plus the purple Individual fits curve. The legend is titled Observed data.
R


  # settings and preferences options
  plotIndividualFits(settings = list(ylog = T, ylim = c(0.8, 11)))
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's fill values.
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's linetype values.

plotIndividualFits output with a log scale on the y axis and y limits from 0.8 to 11. The 12 panels, id 1 to id 12, show CONC with ticks at 1, 3 and 10 versus time. After the peak the purple individual fit decreases as a straight line through the blue observed dots, showing log-linear elimination.
R

  preferences <- list(popFits = list(lineType = "solid", legend = "Population fits"))
  plotIndividualFits(settings = list(popFits = T), preferences = preferences)
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's fill values.
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's linetype values.

plotIndividualFits output with population fits and a preference changing their line type to solid. The 12 panels of CONC versus time show observed blue dots, the purple individual fit and the population fit as a solid green curve.
R

Last updated: