calculateResiduals: Calculate residuals for datasets in 'DataCombined'

View source: R/utilities-data-combined.R

calculateResidualsR Documentation

Calculate residuals for datasets in DataCombined

Description

Calculate residuals for datasets in DataCombined

Usage

calculateResiduals(dataCombined, scaling, xUnit = NULL, yUnit = NULL)

Arguments

dataCombined

A single instance of DataCombined class.

scaling

A character specifying scale: either tlf::Scaling$lin (linear) or tlf::Scaling$log (logarithmic).

xUnit, yUnit

Target units for xValues and yValues, respectively. If not specified (NULL), first of the existing units in the respective columns (xUnit and yUnit) will be selected as the common unit. For available dimensions and units, see ospsuite::ospDimensions and ospsuite::ospUnits, respectively.

Details

To compute residuals, for every simulated dataset in a given group, there should also be a corresponding observed dataset. If this is not the case, the corresponding observed or simulated datasets will be removed.

When multiple (observed and/or simulated) datasets are present in DataCombined, they are likely to have different units. The xUnit and yUnit arguments help you specify a common unit to convert them to.

Value

In the returned tibble data frame, the following columns will always be present:

xValues - xUnit - xDimension - yValuesObserved - yUnit - yDimension - yErrorValues - yErrorType - yErrorUnit - yValuesSimulated - residualValues

See Also

Other data-combined: DataCombined, convertUnits()

Examples

# simulated data
simFilePath <- system.file("extdata", "Aciclovir.pkml", package = "ospsuite")
sim <- loadSimulation(simFilePath)
simResults <- runSimulations(sim)[[1]]
outputPath <- "Organism|PeripheralVenousBlood|Aciclovir|Plasma (Peripheral Venous Blood)"

# observed data
obsData <- lapply(
  c("ObsDataAciclovir_1.pkml", "ObsDataAciclovir_2.pkml", "ObsDataAciclovir_3.pkml"),
  function(x) loadDataSetFromPKML(system.file("extdata", x, package = "ospsuite"))
)
names(obsData) <- lapply(obsData, function(x) x$name)


# Create a new instance of `DataCombined` class
myDataCombined <- DataCombined$new()

# Add simulated results
myDataCombined$addSimulationResults(
  simulationResults = simResults,
  quantitiesOrPaths = outputPath,
  groups = "Aciclovir PVB"
)

# Add observed data set
myDataCombined$addDataSets(obsData$`Vergin 1995.Iv`, groups = "Aciclovir PVB")

calculateResiduals(myDataCombined, scaling = tlf::Scaling$lin)

Open-Systems-Pharmacology/OSPSuite-R documentation built on April 28, 2024, 2:24 a.m.