Api

API

ReplicateBE.RBE

    struct RBE
        model::ModelFrame               #Model frame
        rmodel::ModelFrame              #Random effect model
        design::Design                  #Design description
        factors::Array{Symbol, 1}       #Factor list
        θ0::Array{Float64, 1}           #Initial variance paramethers
        θ::Tuple{Vararg{Float64}}       #Final variance paramethers
        reml::Float64                   #-2REML
        fixed::EffectTable              #Fixed Effect table
        typeiii::ContrastTable          #Type III table
        R::Array{Matrix{Float64},1}     #R matrices for each subject
        V::Array{Matrix{Float64},1}     #V matrices for each subject
        G::Matrix{Float64}              #G matrix
        C::Matrix{Float64}              #C var(β) p×p variance-covariance matrix
        A::Matrix{Float64}              #asymptotic variance-covariance matrix of b θ
        H::Matrix{Float64}              #Hessian matrix
        X::Matrix                       #Matrix for fixed effects
        Z::Matrix                       #Matrix for random effects
        Xv::Array{Matrix{Float64},1}    #X matrices for each subject
        Zv::Array{Matrix{Float64},1}    #Z matrices for each subject
        yv::Array{Array{Float64, 1},1}  #responce vectors for each subject
        detH::Float64                   #Hessian determinant
        preoptim::Union{Optim.MultivariateOptimizationResults, Nothing}         #Pre-optimization result object
        optim::Optim.MultivariateOptimizationResults                            #Optimization result object
    end

Replicate bioequivalence structure.

ReplicateBE.rbe

Main.ReplicateBE.rbeFunction.
rbe(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)

Mixed model fitting function for replicate bioequivalence without data preparation (apply categorical! for each factor and sort! to dataframe).

Mixed model in matrix form:

\[y = X\beta+Zu+\epsilon\]

math

with covariance matrix for each subject:

\[V_{i} = Z_{i}GZ_i'+R_{i}\]

StatsBase.coef

StatsBase.coefFunction.
coef(obj::StatisticalModel)

Return the coefficients of the model.

coef(rbe::RBE)

Return model coefficients.

$\beta = {(\sum_{i=1}^n X_{i}'V_i^{-1}X_{i})}^{-1}(\sum_{i=1}^n X_{i}'V_i^{-1}y_{i})$

coef(rbe::RBE)

Return model coefficients.

$\beta = {(\sum_{i=1}^n X_{i}'V_i^{-1}X_{i})}^{-1}(\sum_{i=1}^n X_{i}'V_i^{-1}y_{i})$

coef(rbe::RBE)

Return model coefficients.

$\beta = {(\sum_{i=1}^n X_{i}'V_i^{-1}X_{i})}^{-1}(\sum_{i=1}^n X_{i}'V_i^{-1}y_{i})$

coef(rbe::RBE)

Return model coefficients.

$\beta = {(\sum_{i=1}^n X_{i}'V_i^{-1}X_{i})}^{-1}(\sum_{i=1}^n X_{i}'V_i^{-1}y_{i})$

coef(rbe::RBE)

Return model coefficients.

$\beta = {(\sum_{i=1}^n X_{i}'V_i^{-1}X_{i})}^{-1}(\sum_{i=1}^n X_{i}'V_i^{-1}y_{i})$

coef(rbe::RBE)

Return model coefficients.

\[\beta = {(\sum_{i=1}^n X_{i}'V_i^{-1}X_{i})}^{-1}(\sum_{i=1}^n X_{i}'V_i^{-1}y_{i})\]

StatsBase.confint

StatsBase.confintFunction.
confint(obj::StatisticalModel; level::Real=0.95)

Compute confidence intervals for coefficients, with confidence level level (by default 95%).

confint(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%).

expci = true: return exponented CI.

inv = true: return -estimate ± t*se

df = :sat: use Satterthwaite DF approximation.

df = :df3 or df = :cont: DF (contain) = N - rank(ZX).

confint(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%).

expci = true: return exponented CI.

inv = true: return -estimate ± t*se

df = :sat: use Satterthwaite DF approximation.

df = :df3 or df = :cont: DF (contain) = N - rank(ZX).

confint(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%).

expci = true: return exponented CI.

inv = true: return -estimate ± t*se

df = :sat: use Satterthwaite DF approximation.

df = :df3 or df = :cont: DF (contain) = N - rank(ZX).

confint(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%).

expci = true: return exponented CI.

inv = true: return -estimate ± t*se

df = :sat: use Satterthwaite DF approximation.

df = :df3 or df = :cont: DF (contain) = N - rank(ZX).

confint(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%).

expci = true: return exponented CI.

inv = true: return -estimate ± t*se

df = :sat: use Satterthwaite DF approximation.

df = :df3 or df = :cont: DF (contain) = N - rank(ZX).

confint(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*se

df = :sat: use Satterthwaite DF approximation.

df = :df3 or df = :cont: DF (contain) = N - rank(ZX).

\[CI = stimate ± t(alpha, df)*se\]

StatsBase.dof

StatsBase.dofFunction.
dof(obj::StatisticalModel)

Return the number of degrees of freedom consumed in the model, including when applicable the intercept and the distribution's dispersion parameter.

dof(d::UnivariateDistribution)

Get the degrees of freedom.

dof(rbe::RBE)

Return the number of degrees of freedom for the coefficients of the model.

dof(rbe::RBE)

Return the number of degrees of freedom for the coefficients of the model.

dof(rbe::RBE)

Return the number of degrees of freedom for the coefficients of the model.

dof(rbe::RBE)

Return the number of degrees of freedom for the coefficients of the model.

dof(rbe::RBE)

Return the number of degrees of freedom for the coefficients of the model.

dof(rbe::RBE)

Return the number of degrees of freedom for the coefficients of the model.

StatsBase.stderror

StatsBase.stderrorFunction.
stderror(obj::StatisticalModel)

Return the standard errors for the coefficients of the model.

StatsBase.stderror(rbe::RBE)

Return the standard errors for the coefficients of the model.

$se = \sqrt{LCL'}$

StatsBase.stderror(rbe::RBE)

Return the standard errors for the coefficients of the model.

$se = \sqrt{LCL'}$

StatsBase.stderror(rbe::RBE)

Return the standard errors for the coefficients of the model.

$se = \sqrt{LCL'}$

StatsBase.stderror(rbe::RBE)

Return the standard errors for the coefficients of the model.

$se = \sqrt{LCL'}$

StatsBase.stderror(rbe::RBE)

Return the standard errors for the coefficients of the model.

$se = \sqrt{LCL'}$

StatsBase.stderror(rbe::RBE)

Return the standard errors for the coefficients of the model.

\[se = \sqrt{LCL'}\]

ReplicateBE.coefnum

coefnum(rbe::RBE)

Return number of coefficients (length β).

ReplicateBE.contrast

contrast(rbe::RBE, L::Matrix; numdf = 1, name = "Contrast", memopt = true)::ContrastTable

Return contrast table for L matrix.

\[F = \frac{\beta'L'(LCL')^{-1}L\beta}{rank(LCL')}\]

DF for one-dimetion case:

\[df = \frac{2(LCL')^{2}}{g'Ag}\]

where $A = 2H$

where $g = \triangledown _{\theta}(LC^{-1}L')$

DF for multi-dimention case:

ReplicateBE.design

design(rbe::RBE)::Design

Return design information object, where:

    struct Design
        obs::Int          # Number of observations
        subj::Int         # Number of statistica independent subjects
        sqn::Int          # Number of sequences
        pn::Int           # Number of periods
        fn::Int           # Number of formulations
        sbf::Vector{Int}  # Subjects in each formulation level
        rankx::Int        # Rank of fixed effect matrix
        rankxz::Int       # Rank of XZ (fixed+random) effect matrix
        df2::Int          # subj - sqn         (Robust DF)
        df3::Int          # obs  - rankxz      (Contain DF for sequence and period)
        df4::Int          # obs  - rankxz + p
    end

ReplicateBE.estimate

estimate(rbe::RBE, L::Matrix; df = :sat, name = "Estimate", memopt = true, alpha = 0.05)

Return estimate table for L 1xp matrix.

\[estimate = L\beta\]
\[se = \sqrt{LCL'}\]
\[t = estimate/se\]

For df = :sat:

\[df = \frac{2(LCL')^{2}}{g'Ag}\]

where $A = 2H$

where $g = \triangledown _{\theta}(LC^{-1}L')$

For df = :cont (contain):

\[df = N - rank(ZX)\]

CI estimate is:

\[CI = stimate ± t(alpha, df)*se \]

ReplicateBE.fixed

fixed(rbe::RBE)

Return fixed effect table (β).

ReplicateBE.randrbeds

    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],
        dropsubj = 0.0, dropobs::Int = 0, seed::Int = 0)

Random dataset generation for bioequivalence.

Parameters

* n: number of subjects
* sequence: distribution in sequences [1,1] means 1:1, [1,3] - 1:4 etc.
* design: desin matrix, each line is a sequence, each column - periods, cell - formulation id
* inter: inter-subject variance vector for G matrix (length 3)
* intra: intra-subject variance vector for R matrix (length 2)
* intercept: intercept effect value
* seqcoef: coefficients of sequences (length(sequence) == length(seqcoef) == size(design, 1))
* periodcoef: coefficients of periods (length(periodcoef) == size(design, 2))
* formcoef: coeficients of formulations
* dropobs: number of randomly dropped subjects
* seed: seed for random

Multivariate normal disribution:

\[f(\mathbf{x}; \boldsymbol{\mu}, \boldsymbol{V}) = \frac{1}{(2 \pi)^{d/2} |\boldsymbol{V}|^{1/2}} \exp \left( - \frac{1}{2} (\mathbf{x} - \boldsymbol{\mu})^T V^{-1} (\mathbf{x} - \boldsymbol{\mu}) \right)\]

Where V:

\[V_{i} = Z_{i}GZ_i'+R_{i}\]
    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)

Simple interface.

ReplicateBE.reml2

reml2(rbe::RBE, θ::Array{Float64, 1})

Returm -2REML for rbe model

reml2(rbe::RBE)

Returm -2logREML for rbe model

\[ logREML(\theta,\beta) = -\frac{N-p}{2} - \frac{1}{2}\sum_{i=1}^nlog|V_{i}|- -\frac{1}{2}log|\sum_{i=1}^nX_i'V_i^{-1}X_i|-\frac{1}{2}\sum_{i=1}^n(y_i - X_{i}\beta)'V_i^{-1}(y_i - X_{i}\beta)\]

ReplicateBE.typeiii

typeiii(rbe::RBE)

Return TYPE III table.

see contrast