The following additional binning methods from classInt
have been made available in tidyvpc
.
see ?classIntervals
‘style’ descriptions for applicable
arguments for each selected binning method.
## tidyvpc is part of Certara.R!
## Follow the link below to learn more about PMx R package development at Certara.
## https://certara.github.io/R-Certara/
obs_data <- obs_data[MDV == 0]
sim_data <- sim_data[MDV == 0]
headtails
observed(obs_data, x = TIME, y = DV) |>
simulated(sim_data, y = DV) |>
binning(bin = "headtails") |>
plot()
Including additional thr
argument.
observed(obs_data, x = TIME, y = DV) |>
simulated(sim_data, y = DV) |>
binning(bin = "headtails", thr = 0.55) |>
plot()
maximum
observed(obs_data, x = TIME, y = DV) |>
simulated(sim_data, y = DV) |>
binning(bin = "maximum") |>
plot()
## Warning in RColorBrewer::brewer.pal(n, pal): n too large, allowed maximum for palette Set1 is 9
## Returning the palette you asked for with that many colors
## Warning: Removed 2 rows containing missing values (geom_point).
Including additional nbins
argument.
observed(obs_data, x = TIME, y = DV) |>
simulated(sim_data, y = DV) |>
binning(bin = "maximum", nbins = 7) |>
plot()
box
observed(obs_data, x = TIME, y = DV) |>
simulated(sim_data, y = DV) |>
binning(bin = "box") |>
plot()
Including additional iqr_mult
and type
argument.
observed(obs_data, x = TIME, y = DV) |>
simulated(sim_data, y = DV) |>
binning(bin = "box", iqr_mult = 4) |>
plot()
# additional (quantile) type arg
observed(obs_data, x = TIME, y = DV) |>
simulated(sim_data, y = DV) |>
binning(bin = "box", type = 3) |>
plot()
Users may now execute predcorrect()
either before, or
after calling binless(loess.ypc=TRUE)
. Previously, you were
required to execute predcorrect()
before
binless(loess.ypc=TRUE)
, otherwise you’d receive an
error.
The following code below produces equivalent output:
observed(obs_data, x = TIME, y = DV ) |>
simulated(sim_data, y = DV) |>
stratify(~ GENDER) |>
predcorrect(pred=PRED) |> #before binless()
binless(loess.ypc=TRUE) |>
vpcstats() |>
plot()
observed(obs_data, x = TIME, y = DV ) |>
simulated(sim_data, y = DV) |>
stratify(~ GENDER) |>
binless(loess.ypc=TRUE) |>
predcorrect(pred=PRED) |> #after binless()
vpcstats() |>
plot()
An overview of updates to plot()
function in
tidyvpc v1.3.0
Set plot output dimensions:
knitr::opts_chunk$set(fig.width=12, fig.height=8, dpi = 300)
library(tidyvpc)
library(magrittr)
obs_data <- obs_data[MDV == 0]
sim_data <- sim_data[MDV == 0]
vpc <- observed(obs_data, x=TIME, y=DV) %>%
simulated(sim_data, y=DV) %>%
stratify(~ GENDER) %>%
binless() %>%
vpcstats()
plot(vpc)
vpc <- observed(obs_data, x=TIME, y=DV) %>%
simulated(sim_data, y=DV) %>%
stratify(~ GENDER + STUDY) %>%
binning(bin = "jenks", nbins = 8) %>%
vpcstats()
plot(vpc)
vpc <- observed(obs_data, x=TIME, y=DV) %>%
simulated(sim_data, y=DV) %>%
stratify(GENDER ~ STUDY) %>%
binning(bin = "kmeans", nbins = 6) %>%
vpcstats()
plot(vpc)
We can use facet = TRUE argument to facet continuous VPC by quantile or facet categorical VPC by predicted probability.
vpc <- observed(obs_data, x=TIME, y=DV) %>%
simulated(sim_data, y=DV) %>%
binless() %>%
vpcstats()
plot(vpc, facet = TRUE, point.alpha = 0.1, point.size = 1, ribbon.alpha = 0.2)
vpc <- observed(obs_cat_data, x = agemonths, yobs = zlencat) %>%
simulated(sim_cat_data, ysim = DV) %>%
binless() %>%
vpcstats(vpc.type = "categorical")
plot(vpc, facet = TRUE, legend.position = "bottom")
Setup categorical VPC.
vpc <- observed(obs_cat_data, x = agemonths, yobs = zlencat) %>%
simulated(sim_cat_data, ysim = DV) %>%
binning(bin = round(agemonths, 0)) %>%
vpcstats(vpc.type = "categorical")
Adjust point size.
plot(vpc, point.size = 4)
Setup continuous VPC.
plot(vpc, point.size = 1.5, point.stroke = 2.5, point.alpha = 0.1, ribbon.alpha = 0.05)
plot(vpc, point.size = 5, point.stroke = 0.3, point.shape = "triangle")
plot(vpc, point.size = 7, point.shape = "square-fill", point.alpha = 0.1, ribbon.alpha = 0.5)