calccb: Calculation of confidence bands

View source: R/calccb.R

calccbR Documentation

Calculation of confidence bands

Description

The function calculates pointwice confidence bands based on Monte-Carlo simulations in DBSolveOptimum. The lower and upper confidence band calculated as lower and upper quantile for interpolated particular x point.

Usage

calccb(input, x.col, x.seq, y.col, factor.col = c(),
        q.seq = c(0.025, 0.5, 0.975), nos.col = "nos",
        par_calc = FALSE, cpu.cores = 4, silent = FALSE, include.nos = c(), ...)

Arguments

input

data.frame passed from DBSolveOptimum output

x.col

number or name of column in input corresponded to free variable (i.e. time).

x.seq

numerical vector of points to interpolate values in x.col.

y.col

vector of column numbers or names in input corresponded to simulated variables (model output).

factor.col

vector of column numbers or names in input corresponded to condition parameters (model input).

q.seq

sequence of probabilities for calculation of lower and upper quantile. The default vector c(0.025, 0.5, 0.975) corresponds to calculation of median value and 0.95 confidence band.

nos.col

number or name of column in input corresponded to enumeration of random parameter set.

par_calc

logical value to use parallel calculation for acceleration. It requires parallel, foreach, iterators packages.

cpu.cores

the number of CPU cores to use if par_calc=TRUE.

silent

logical value to suppress the messages during calculations.

include.nos

vector of number of samples to analyze the approximation in the chosed number of sample.

...

other arguments passed to quantile

Value

The returned value is data.frame class object. The columns describe:

names(x.col)

free variable values passed from argument x.col.

var_id

names of simulated variables as passed from y.col.

quant_

columns represent calculated quntiles for interpolated points.

names(factor.col)

condition variable values passed from argument factor.col.

group

unique identifier for combination of factor.col.

The value has the additional attributes:

col.def

definition of columns, type of data in columns.

col.title

titles for columns. May be usefull for visualization.

var.title

titles for simulated variables. May be usefull for visualization.

group.title

titles for condition groups. May be usefull for visualization.

approx_nos_

column(or columns) represents interpolated points for chosed number of sample (presented only if include.nos has values in).

See Also

foreach
quantile
approxfun

Examples

### calculation of confidence bands based on example4.slv 
## Not run: example4_parset_bs.cond_res<-read.delim("example4_parset_bs.cond_res.txt") # read from DBSolve output simulated with MC parameters from bootstrapping
example4_cb<-calccb(input=example4_parset_bs.cond_res,
                    x.col="t",
                    x.seq=seq(0,96,by=0.5),
                    y.col=c("C0","C1"),
                    factor.col = c("Dose","T"))
## Not run: write.delim(example4_cb, "example4_cb.txt") # save results

### plot all results with lattice
library(lattice)
xyplot(quant_0.025+quant_0.5+quant_0.975~t|var_id+group,
       data=example4_cb,
       type="l",
       lty=c(2,1,2),
       xlab="Time, h",
       ylab="Concentration of drug, ng/ml",
       main="All CB simulations")
       
###You can also plot all results using ggplot2:
library(ggplot2)
ggplot(example4_cb,aes(t,quant_0.025))+
        geom_line(linetype="dashed", color="blue")+
        geom_line(aes(t,quant_0.5),color="black",linetype="solid")+
        geom_line(aes(t,quant_0.975),color="blue",linetype="dashed")+
        facet_wrap(~var_id+group)+
        ggtitle("All CB simulations")+
        scale_x_continuous(name="Time,h")+
        scale_y_continuous(name="Concentration of drug, ng/ml")


### plot dbsolve output results
example4_cb<-calccb(input=example4_parset.cond_res,
                    x.col="t",
                    x.seq=seq(0,96,by=0.5),
                    y.col=c("C0","C1"),
                    factor.col = c("Dose","T"),
                    par_calc = FALSE)

insysbio/dbs-package documentation built on Aug. 4, 2022, 2:11 p.m.