API
ReplicateBE.rbe
ReplicateBE.rbe
— Functionrbe(df; dvar::Symbol,
subject::Symbol,
formulation::Symbol,
period::Symbol,
sequence::Symbol,
g_tol::Float64 = 1e-8, x_tol::Float64 = 0.0, f_tol::Float64 = 0.0,
iterations::Int = 100,
store_trace = false, extended_trace = false, show_trace = false,
memopt = true,
init = [],
postopt = false, maxopttry = 100)
Mixed model fitting function for replicate bioequivalence without data preparation (apply categorical! for each factor and sort! to dataframe).
Mixed model in matrix form:
with covariance matrix for each subject:
Arguments
- df - DataFrame with data;
Keywords:
- dvar - dependent variable;
- subject - subject factor;
- formulation - formulation factor;
- period - period factor;
- sequence - sequence factor;
- g_tol = 1e-8
- x_tol = 0.0
- f_tol = 0.0
- iterations = 100 - maximum iteration for optimization
- store_trace = false
- extended_trace = false
- show_trace = false
- memopt = true - memory optimization (function cache)
- init = [] - initial variance paremeters
- postopt = false - post optimization
ReplicateBE.rbe!
ReplicateBE.rbe!
— FunctionThis function can convert non-categorical to categorical and sort dataframe.
It can takes more time, but can help to avoid some errors like: "ERROR: type ContinuousTerm has no field contrasts".
StatsBase.coef
StatsBase.coef
— Functioncoef(rbe::RBE)
Return model coefficients.
StatsBase.confint
StatsBase.confint
— Functionconfint(obj::RBE; level::Real=0.95, expci::Bool = false, inv::Bool = false, df = :sat)
Compute confidence intervals for coefficients, with confidence level level
(by default 95%).
Arguments
expci = true
: return exponented CI.inv = true
: return-estimate ± t(alpha, df)*SE
df = :sat
: use Satterthwaite DF approximation.df = :df3
ordf = :cont
: DF (contain) = N - rank(ZX).
StatsBase.dof
StatsBase.dof
— Functiondof(rbe::RBE)
Return the number of degrees of freedom for the coefficients of the model.
StatsBase.stderror
StatsBase.stderror
— FunctionStatsBase.stderror(rbe::RBE)
Return the standard errors for the coefficients of the model.
where
ReplicateBE.coefnum
ReplicateBE.coefnum
— Functioncoefnum(rbe::RBE)
Return number of coefficients (length β).
ReplicateBE.contrast
ReplicateBE.contrast
— Functioncontrast(rbe::RBE, L::Matrix; name = "Contrast", memopt = true)::ContrastTable
Return contrast table for L matrix. Table include:
- F
- NumDF
- DF
- P|f|
where
DF for one-dimetion case:
where $A = 2H^{-1}$
where $g = \triangledown _{\theta}(LC_{\theta}L')$
DF for multi-dimention case see Schaalje et al 2002.
p value calculated with:
pval = ccdf(FDist(numdf, df), F)
ReplicateBE.design
ReplicateBE.design
— Functiondesign(rbe::RBE)::Design
Return design information object.
ReplicateBE.estimate
ReplicateBE.estimate
— Functionestimate(rbe::RBE, L::Matrix; df = :sat, name = "Estimate", memopt = true, alpha = 0.05)
Return estimate table for L 1xp matrix. Table include:
- estimate value
- SE
- DF
- t
- P|t|
- CI Upper
- CI Lower
For df = :sat
:
where
where $A = 2H^{-1}$
where $g = \triangledown _{\theta}(LC_{\theta}L')$
For df = :cont
(contain):
CI estimate is:
Example of L matrix if length of fixed effect vector is 6, estimate for 4-th value:
L = [0 0 0 1 0 0]
ReplicateBE.fixed
ReplicateBE.fixed
— Functionfixed(rbe::RBE)
Return fixed effect table (β).
ReplicateBE.optstat
ReplicateBE.optstat
— Functionoptstat(rbe::RBE)
Return optimization status.
- true - converged
- false - not converged
ReplicateBE.randrbeds
ReplicateBE.randrbeds
— Function randrbeds(;n=24, sequence=[1,1],
design = ["T" "R" "T" "R"; "R" "T" "R" "T"],
inter=[0.5, 0.4, 0.9], intra=[0.1, 0.2],
intercept = 0, seqcoef = [0.0, 0.0], periodcoef = [0.0, 0.0, 0.0, 0.0],
formcoef = [0.0, 0.0],
dropobs::Int = 0, seed::Int = 0)
Random dataset generation for bioequivalence.
Keywords
- $n=24$ - number of subjects;
- $sequence = [1,1]$ - distribution in sequences [1,1] means 1:1, [1,3] - 1:4 etc.;
- $design = ["T" "R" "T" "R"; "R" "T" "R" "T"]$ - desin matrix, each line is a sequence, each column - periods, cell - formulation id;
- $inter=[0.5, 0.4, 0.9]$ - inter-subject variance vector for G matrix (length 3): [σ₁, σ₂, ρ], where σ₁, σ₂ - formulation inter-subject variance, ρ - covariance coefficient;
- $intra=[0.1, 0.2]$ - intra-subject variance vector for R matrix (length 2): [σ₁, σ₂], where σ₁, σ₂ - formulation intra-subject variance for each formulation;
- $intercept = 0$ - intercept effect value;
- $seqcoef = [0.0, 0.0]$ - coefficients of sequences, additive (length(sequence) == length(seqcoef) == size(design, 1));
- $periodcoef = [0.0, 0.0, 0.0, 0.0]$ - coefficients of periods, additive (length(periodcoef) == size(design, 2));
- $formcoef = [0.0, 0.0]$ - coefficients of formulations, additive ;
- $dropobs = 0$ number of randomly dropped observations;
- $seed = 0$ - seed for random number generator (0 - random seed).
Multivariate normal disribution:
Where V:
Another way to use:
randrbeds(n::Int, sequence::Vector,
design::Matrix,
θinter::Vector, θintra::Vector,
intercept::Real, seqcoef::Vector, periodcoef::Vector, formcoef::Vector,
dropsubj::Float64, dropobs::Int, seed::Int)
Using with RandRBEDS object:
randrbeds(task::RandRBEDS)
ReplicateBE.randrbetask
ReplicateBE.randrbetask
— Functionrandrbetask(;n=24, sequence=[1,1],
design = ["T" "R" "T" "R"; "R" "T" "R" "T"],
inter=[0.5, 0.4, 0.9], intra=[0.1, 0.2],
intercept = 0, seqcoef = [0.0, 0.0], periodcoef = [0.0, 0.0, 0.0, 0.0], formcoef = [0.0, 0.0],
dropsubj = 0, dropobs::Int = 0, seed = 0)::RandRBEDS
Make task for random dataset generation.
ReplicateBE.reml2
ReplicateBE.reml2
— Functionreml2(rbe::RBE, θ::Vector{T}) where T <: AbstractFloat
Returm -2logREML for rbe model with θ variance vector.
reml2(rbe::RBE)
Returm -2logREML for rbe model
-2 REML function for ForwardDiff
ReplicateBE.simulation
ReplicateBE.simulation
— Functionsimulation(task::RandRBEDS; io = stdout, verbose = false, num = 100,
l = log(0.8), u = log(1.25), seed = 0)
Count successful BE outcomes.
Parameters
- task - RandRBEDS object
Keywords
- $io = stdout$ - text output
- $verbose = false$ - print messages to io
- $num = 100$ - number of simulations
- $l = log(0.8)$ - lower bound
- $u = log(1.25)$ - upper bound
- $seed = 0$ - seed for random number generator (0 - random seed)
ReplicateBE.theta
ReplicateBE.theta
— Functiontheta(rbe::RBE)
Return theta (θ) vector (vector of variation parameters from optimization procedure).
ReplicateBE.typeiii
ReplicateBE.typeiii
— Functiontypeiii(rbe::RBE)
Return TYPE III table.
(see contrast)