Calculate residuals for datasets in DataCombined
Source: R/utilities-data-combined.R
calculateResiduals.Rd
Calculate residuals for datasets in DataCombined
Arguments
- dataCombined
A single instance of
DataCombined
class.- scaling
A character specifying scale: either
tlf::Scaling$lin
(linear) ortlf::Scaling$log
(logarithmic).- xUnit, yUnit
Target units for
xValues
andyValues
, respectively. If not specified (NULL
), first of the existing units in the respective columns (xUnit
andyUnit
) will be selected as the common unit. For available dimensions and units, seeospsuite::ospDimensions
andospsuite::ospUnits
, respectively.
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
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.
See also
Other data-combined:
DataCombined
,
convertUnits()
Examples
# simulated data
simFilePath <- system.file("extdata", "Aciclovir.pkml", package = "ospsuite")
sim <- loadSimulation(simFilePath)
simResults <- runSimulation(sim)
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)
#> # A tibble: 13 x 14
#> group name xValues xUnit xDime~1 yValu~2 yUnit yDime~3 yErro~4 yErro~5
#> <chr> <chr> <dbl> <chr> <chr> <dbl> <chr> <chr> <dbl> <chr>
#> 1 Aciclovir ~ Verg~ 13.4 min Time 35.0 µmol~ Concen~ 6.64 Arithm~
#> 2 Aciclovir ~ Verg~ 29.1 min Time 20.0 µmol~ Concen~ 3.81 Arithm~
#> 3 Aciclovir ~ Verg~ 44.7 min Time 14.1 µmol~ Concen~ 2.83 Arithm~
#> 4 Aciclovir ~ Verg~ 58.1 min Time 11.0 µmol~ Concen~ 2.29 Arithm~
#> 5 Aciclovir ~ Verg~ 87.2 min Time 7.51 µmol~ Concen~ 1.74 Arithm~
#> 6 Aciclovir ~ Verg~ 119. min Time 5.88 µmol~ Concen~ 1.20 Arithm~
#> 7 Aciclovir ~ Verg~ 179. min Time 4.03 µmol~ Concen~ 0.979 Arithm~
#> 8 Aciclovir ~ Verg~ 239. min Time 3.05 µmol~ Concen~ 0.653 Arithm~
#> 9 Aciclovir ~ Verg~ 360 min Time 1.63 µmol~ Concen~ 0.435 Arithm~
#> 10 Aciclovir ~ Verg~ 541. min Time 0.871 µmol~ Concen~ 0.218 Arithm~
#> 11 Aciclovir ~ Verg~ 720 min Time 0.544 µmol~ Concen~ 0.326 Arithm~
#> 12 Aciclovir ~ Verg~ 901. min Time 0.435 µmol~ Concen~ 0.326 Arithm~
#> 13 Aciclovir ~ Verg~ 1440 min Time 0.326 µmol~ Concen~ 0.326 Arithm~
#> # ... with 4 more variables: yErrorUnit <chr>, lloq <dbl>,
#> # yValuesSimulated <dbl>, residualValues <dbl>, and abbreviated variable
#> # names 1: xDimension, 2: yValuesObserved, 3: yDimension, 4: yErrorValues,
#> # 5: yErrorType