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 <- 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)
#> # A tibble: 13 × 14
#> group name xValues xUnit xDimension yValuesObserved yUnit yDimension
#> <chr> <chr> <dbl> <chr> <chr> <dbl> <chr> <chr>
#> 1 Aciclovir PVB Verg… 13.4 min Time 35.0 µmol… Concentra…
#> 2 Aciclovir PVB Verg… 29.1 min Time 20.0 µmol… Concentra…
#> 3 Aciclovir PVB Verg… 44.7 min Time 14.1 µmol… Concentra…
#> 4 Aciclovir PVB Verg… 58.1 min Time 11.0 µmol… Concentra…
#> 5 Aciclovir PVB Verg… 87.2 min Time 7.51 µmol… Concentra…
#> 6 Aciclovir PVB Verg… 119. min Time 5.88 µmol… Concentra…
#> 7 Aciclovir PVB Verg… 179. min Time 4.03 µmol… Concentra…
#> 8 Aciclovir PVB Verg… 239. min Time 3.05 µmol… Concentra…
#> 9 Aciclovir PVB Verg… 360 min Time 1.63 µmol… Concentra…
#> 10 Aciclovir PVB Verg… 541. min Time 0.871 µmol… Concentra…
#> 11 Aciclovir PVB Verg… 720 min Time 0.544 µmol… Concentra…
#> 12 Aciclovir PVB Verg… 901. min Time 0.435 µmol… Concentra…
#> 13 Aciclovir PVB Verg… 1440 min Time 0.326 µmol… Concentra…
#> # ℹ 6 more variables: yErrorValues <dbl>, yErrorType <chr>, yErrorUnit <chr>,
#> # lloq <dbl>, yValuesSimulated <dbl>, residualValues <dbl>