indiv_plot: Generate Individual Plots

View source: R/gof.R

indiv_plotR Documentation

Generate Individual Plots

Description

Observations (DV), individual predictions (IPRED), and population predictions (PRED) plotted against the independent variable for each individual.

Usage

indiv_plot(
  data,
  x,
  y,
  ipred,
  pred,
  labels = gof_labels(),
  ip_ncol = 4,
  ip_nrow = 4,
  scale_facet = "fixed",
  labelfacet = "label_value",
  strati1 = id,
  strati2 = NULL,
  color_color = c(dv = ggcertara::certara_pal()[1], outliers =
    ggcertara::certara_pal()[2], ipred = ggcertara::certara_pal()[4], pred =
    ggcertara::certara_pal()[7]),
  fill_fill = c(ipred = ggcertara::certara_pal()[4]),
  alpha_fill = 0.5,
  line_linetype = c(dv = "blank", outliers = "blank", ipred = "solid", pred = "dashed"),
  line_size = 1,
  shape_shape = c(dv = 16, outliers = 10, ipred = NA, pred = NA),
  shape_size = 1,
  cwres.outliers = FALSE,
  limit.outliers = 5,
  uncertainty = FALSE,
  uncert.ci = 0.95,
  ...
)

Arguments

data

A data.frame containing the dataset.

x

The name of the independent variable column. Default value is "time".

y

The name of the dependent variable column. Default value is "dv".

ipred

The name of the individual prediction variable column. Default value is "ipred".

pred

The name of the population prediction variable column. Default value is "pred".

labels

A named list of labels for plot annotations. Default values are provided by gof_labels().

ip_ncol

Number of columns per plot. Default is 4. Adjust if encountering issues with incomplete first rows on the last page due to ggforce::facet_wrap_paginate.

ip_nrow

Number of rows per plot. Default is 4. Adjust similarly to ip_ncol for pagination issues.

strati1

The variable used to stratify the plots. Default is "id".

strati2

An optional variable for an additional layer of stratification. Default is NULL.

color_color

A named vector specifying colors for different elements (dv, ipred, pred, outliers). Should be a vector of 4 colors.

fill_fill

A named vector specifying fill colors for elements when uncertainty is plotted. Specifically for 'ipred' when uncertainty is TRUE.

alpha_fill

Transparency level for the filled area representing the confidence interval, when uncertainty is TRUE.

line_linetype

A named vector specifying line types for different elements (dv, outliers, ipred, pred).

line_size

Line width for the line layer. Default is 1.

shape_shape

A named vector specifying shapes for different elements. When not specified, defaults are used.

shape_size

Size for the shape layer. Default is 1.

cwres.outliers

If TRUE, only profiles of individuals with outlier observations are displayed. Default is FALSE.

limit.outliers

Threshold for CWRES to identify outliers. Default is 5.

uncertainty

If TRUE, plots a confidence interval around individual predictions. Default is FALSE.

uncert.ci

Confidence interval level when uncertainty is TRUE. Default is 0.95.

...

Additional arguments passed to lower-level functions.

Examples

## Not run: 
indiv_plot(data = dat,
           x = "time",
           y = "dv",
           ipred = "ipred",
           pred = "pred",
           strati1 = "id",
           ip_ncol = 3,
           ip_nrow = 4,
           uncertainty = FALSE)

## End(Not run)

# Example with individuals with high cwres values
## Not run: 
indiv_plot(data = dat,
           x = "time",
           y = "dv",
           ipred = "ipred",
           pred = "pred",
           strati1 = "id",
           cwres.outliers = TRUE,
           limit.outliers = 5,
           ip_ncol = 3,
           ip_nrow = 4,
           uncertainty = FALSE)

## End(Not run)

# Example to apply layers with the ampersand sign & (example to change legend.position)
## Not run: 
indiv_plot(data = dat,
           x = "time",
           y = "dv",
           ipred = "ipred",
           pred = "pred",
           strati1 = "id") &
theme(legend.position = "bottom")

## End(Not run)

certara/ggcertara documentation built on Feb. 28, 2024, 5:01 a.m.