API Documentation
Documentation for ExperimentalDesign.jl
's API.
Contents
Index
ExperimentalDesign.AbstractDesign
ExperimentalDesign.AbstractFactorialDesign
ExperimentalDesign.AbstractOptimalDesign
ExperimentalDesign.AbstractScreeningDesign
ExperimentalDesign.BoxBehnken
ExperimentalDesign.BoxBehnken
ExperimentalDesign.BoxBehnken
ExperimentalDesign.CategoricalFactor
ExperimentalDesign.CategoricalFactor
ExperimentalDesign.CentralComposite
ExperimentalDesign.CentralComposite
ExperimentalDesign.CentralComposite
ExperimentalDesign.DesignDistribution
ExperimentalDesign.DesignDistribution
ExperimentalDesign.DesignDistribution
ExperimentalDesign.DesignDistribution
ExperimentalDesign.DesignDistribution
ExperimentalDesign.FractionalFactorial2Level
ExperimentalDesign.FractionalFactorial2Level
ExperimentalDesign.FullFactorial
ExperimentalDesign.FullFactorial
ExperimentalDesign.FullFactorial
ExperimentalDesign.FullFactorial
ExperimentalDesign.FullFactorial
ExperimentalDesign.OptimLHCDesign
ExperimentalDesign.OptimLHCDesign
ExperimentalDesign.OptimLHCDesign
ExperimentalDesign.OptimalDesign
ExperimentalDesign.OptimalDesign
ExperimentalDesign.PlackettBurman
ExperimentalDesign.PlackettBurman
ExperimentalDesign.PlackettBurman
ExperimentalDesign.RandomLHCDesign
ExperimentalDesign.RandomLHCDesign
ExperimentalDesign.RandomLHCDesign
Base.rand
Base.rand
ExperimentalDesign.boxbehnken
ExperimentalDesign.boxbehnken
ExperimentalDesign.ccdesign
ExperimentalDesign.d_criterion
ExperimentalDesign.explicit_fullfactorial
ExperimentalDesign.explicit_fullfactorial
ExperimentalDesign.fold!
ExperimentalDesign.fold!
ExperimentalDesign.fullfactorial
ExperimentalDesign.isplackettburman
ExperimentalDesign.kl_exchange
ExperimentalDesign.next_offset_divisible_prime
ExperimentalDesign.paley
ExperimentalDesign.plackettburman
ExperimentalDesign.random_design!
API
ExperimentalDesign.AbstractDesign
— Typeabstract type AbstractDesign
ExperimentalDesign.AbstractFactorialDesign
— Typeabstract type AbstractFactorialDesign <: AbstractDesign
ExperimentalDesign.AbstractOptimalDesign
— Typeabstract type AbstractOptimalDesign <: AbstractDesign
ExperimentalDesign.AbstractScreeningDesign
— Typeabstract type AbstractScreeningDesign <: AbstractDesign
ExperimentalDesign.BoxBehnken
— Typestruct BoxBehnken <: ExperimentalDesign.AbstractResponseSurfaceDesign
Box-Behnken design for response surface methodology.
matrix::DataFrame
factors::Tuple
formula::FormulaTerm
ExperimentalDesign.BoxBehnken
— MethodBoxBehnken(formula::FormulaTerm; center) -> BoxBehnken
julia> BoxBehnken(@formula( y ~ -1 + factor1 & factor1 + factor2 & factor2 + factor3 & factor3 + factor1 & factor2 + factor1 & factor3 + factor2 & factor3 + factor1 + factor2 + factor3), center=3)
BoxBehnken
Dimension: (15, 3)
Factors: (:factor1, :factor2, :factor3)
Formula: y ~ -1 + factor1 + factor2 + factor3 + factor1 & factor1 + factor2 & factor2 + factor3 & factor3 + factor1 & factor2 + factor1 & factor3 + factor2 & factor3
Design Matrix:
15×3 DataFrame
Row │ factor1 factor2 factor3
│ Float64 Float64 Float64
─────┼───────────────────────────
1 │ -1.0 -1.0 0.0
2 │ 1.0 -1.0 0.0
3 │ -1.0 1.0 0.0
4 │ 1.0 1.0 0.0
5 │ -1.0 0.0 -1.0
6 │ 1.0 0.0 -1.0
7 │ -1.0 0.0 1.0
8 │ 1.0 0.0 1.0
9 │ 0.0 -1.0 -1.0
10 │ 0.0 1.0 -1.0
11 │ 0.0 -1.0 1.0
12 │ 0.0 1.0 1.0
13 │ 0.0 0.0 0.0
14 │ 0.0 0.0 0.0
15 │ 0.0 0.0 0.0
ExperimentalDesign.BoxBehnken
— MethodBoxBehnken(factors::Int64; center) -> BoxBehnken
julia> BoxBehnken(3, center=3)
BoxBehnken
Dimension: (15, 3)
Factors: (:factor1, :factor2, :factor3)
Formula: y ~ -1 + factor1 & factor1 + factor2 & factor2 + factor3 & factor3 + factor1 & factor2 + factor1 & factor3 + factor2 & factor3 + factor1 + factor2 + factor3
Design Matrix:
15×3 DataFrame
Row │ factor1 factor2 factor3
│ Float64 Float64 Float64
─────┼───────────────────────────
1 │ -1.0 -1.0 0.0
2 │ 1.0 -1.0 0.0
3 │ -1.0 1.0 0.0
4 │ 1.0 1.0 0.0
5 │ -1.0 0.0 -1.0
6 │ 1.0 0.0 -1.0
7 │ -1.0 0.0 1.0
8 │ 1.0 0.0 1.0
9 │ 0.0 -1.0 -1.0
10 │ 0.0 1.0 -1.0
11 │ 0.0 -1.0 1.0
12 │ 0.0 1.0 1.0
13 │ 0.0 0.0 0.0
14 │ 0.0 0.0 0.0
15 │ 0.0 0.0 0.0
ExperimentalDesign.CategoricalFactor
— Typestruct CategoricalFactor <: Distribution{Univariate, Discrete}
values::Vector{N} where N
distribution::DiscreteUniform
A simple wrapper for a DiscreteUniform
distribution over non-numerical arrays.
ExperimentalDesign.CategoricalFactor
— MethodCategoricalFactor(values::Array{N, 1}) -> CategoricalFactor
julia> a = CategoricalFactor([:a, :b, 2, 1.0])
CategoricalFactor(
values: Any[:a, :b, 2, 1.0]
distribution: DiscreteUniform(a=1, b=4)
)
ExperimentalDesign.CentralComposite
— Typestruct CentralComposite <: ExperimentalDesign.AbstractResponseSurfaceDesign
Encapsulates a central composite design.
matrix::DataFrame
factors::Tuple
formula::FormulaTerm
alpha::Symbol
face::Symbol
ExperimentalDesign.CentralComposite
— MethodCentralComposite(formula::FormulaTerm; center, alpha, face) -> CentralComposite
julia> CentralComposite(@formula(y ~ -1 + factor1 & factor1 + factor2 & factor2 + factor3 & factor3 + factor1 & factor2 + factor1 & factor3 + factor2 & factor3 + factor1 + factor2 + factor3))
CentralComposite
Dimension: (22, 3)
Factors: (:factor1, :factor2, :factor3)
Formula: y ~ -1 + factor1 + factor2 + factor3 + factor1 & factor1 + factor2 & factor2 + factor3 & factor3 + factor1 & factor2 + factor1 & factor3 + factor2 & factor3
Alpha: orthogonal
Face: circumscribed
Design Matrix:
22×3 DataFrame
Row │ factor1 factor2 factor3
│ Float64 Float64 Float64
─────┼──────────────────────────────
1 │ -1.0 -1.0 -1.0
2 │ 1.0 -1.0 -1.0
3 │ -1.0 1.0 -1.0
4 │ 1.0 1.0 -1.0
5 │ -1.0 -1.0 1.0
6 │ 1.0 -1.0 1.0
7 │ -1.0 1.0 1.0
8 │ 1.0 1.0 1.0
⋮ │ ⋮ ⋮ ⋮
16 │ 0.0 1.82574 0.0
17 │ 0.0 0.0 -1.82574
18 │ 0.0 0.0 1.82574
19 │ 0.0 0.0 0.0
20 │ 0.0 0.0 0.0
21 │ 0.0 0.0 0.0
22 │ 0.0 0.0 0.0
7 rows omitted
ExperimentalDesign.CentralComposite
— MethodCentralComposite(factors::Int64; center, alpha, face) -> CentralComposite
julia> CentralComposite(3)
CentralComposite
Dimension: (22, 3)
Factors: (:factor1, :factor2, :factor3)
Formula: y ~ -1 + factor1 & factor1 + factor2 & factor2 + factor3 & factor3 + factor1 & factor2 + factor1 & factor3 + factor2 & factor3 + factor1 + factor2 + factor3
Alpha: orthogonal
Face: circumscribed
Design Matrix:
22×3 DataFrame
Row │ factor1 factor2 factor3
│ Float64 Float64 Float64
─────┼──────────────────────────────
1 │ -1.0 -1.0 -1.0
2 │ 1.0 -1.0 -1.0
3 │ -1.0 1.0 -1.0
4 │ 1.0 1.0 -1.0
5 │ -1.0 -1.0 1.0
6 │ 1.0 -1.0 1.0
7 │ -1.0 1.0 1.0
8 │ 1.0 1.0 1.0
⋮ │ ⋮ ⋮ ⋮
16 │ 0.0 1.82574 0.0
17 │ 0.0 0.0 -1.82574
18 │ 0.0 0.0 1.82574
19 │ 0.0 0.0 0.0
20 │ 0.0 0.0 0.0
21 │ 0.0 0.0 0.0
22 │ 0.0 0.0 0.0
7 rows omitted
ExperimentalDesign.DesignDistribution
— Typestruct DesignDistribution
factors::NamedTuple
formula::FormulaTerm
Encapsulates one or more Distribution
s, generating random designs. Receives a NamedTuple
of factor names associated with Distribution
s from the the Distributions package. After instantiating a DesignDistribution
, you must request samples from it using rand
, which generates a RandomDesign
ExperimentalDesign.DesignDistribution
— MethodDesignDistribution(factors::Array) -> DesignDistribution
julia> DesignDistribution([Uniform(2, 3), DiscreteUniform(-1, 5), Uniform(5, 10)])
DesignDistribution
Formula: 0 ~ factor1 + factor2 + factor3
Factor Distributions:
factor1: Uniform{Float64}(a=2.0, b=3.0)
factor2: DiscreteUniform(a=-1, b=5)
factor3: Uniform{Float64}(a=5.0, b=10.0)
ExperimentalDesign.DesignDistribution
— MethodDesignDistribution(factors::NamedTuple) -> DesignDistribution
julia> DesignDistribution((f1 = Uniform(2, 3), f2 = DiscreteUniform(-1, 5), f3 = Uniform(5, 10)))
DesignDistribution
Formula: 0 ~ f1 + f2 + f3
Factor Distributions:
f1: Uniform{Float64}(a=2.0, b=3.0)
f2: DiscreteUniform(a=-1, b=5)
f3: Uniform{Float64}(a=5.0, b=10.0)
ExperimentalDesign.DesignDistribution
— MethodDesignDistribution(factors::Tuple) -> DesignDistribution
julia> DesignDistribution((Uniform(2, 3), DiscreteUniform(-1, 5), Uniform(5, 10)))
DesignDistribution
Formula: 0 ~ factor1 + factor2 + factor3
Factor Distributions:
factor1: Uniform{Float64}(a=2.0, b=3.0)
factor2: DiscreteUniform(a=-1, b=5)
factor3: Uniform{Float64}(a=5.0, b=10.0)
ExperimentalDesign.DesignDistribution
— MethodDesignDistribution(distribution::Distribution, n::Int64) -> DesignDistribution
julia> DesignDistribution(DiscreteNonParametric([-1, 1], [0.5, 0.5]), 6)
DesignDistribution
Formula: 0 ~ factor1 + factor2 + factor3 + factor4 + factor5 + factor6
Factor Distributions:
factor1: DiscreteNonParametric{Int64, Float64, Vector{Int64}, Vector{Float64}}(support=[-1, 1], p=[0.5, 0.5])
factor2: DiscreteNonParametric{Int64, Float64, Vector{Int64}, Vector{Float64}}(support=[-1, 1], p=[0.5, 0.5])
factor3: DiscreteNonParametric{Int64, Float64, Vector{Int64}, Vector{Float64}}(support=[-1, 1], p=[0.5, 0.5])
factor4: DiscreteNonParametric{Int64, Float64, Vector{Int64}, Vector{Float64}}(support=[-1, 1], p=[0.5, 0.5])
factor5: DiscreteNonParametric{Int64, Float64, Vector{Int64}, Vector{Float64}}(support=[-1, 1], p=[0.5, 0.5])
factor6: DiscreteNonParametric{Int64, Float64, Vector{Int64}, Vector{Float64}}(support=[-1, 1], p=[0.5, 0.5])
ExperimentalDesign.FractionalFactorial2Level
— Typestruct FractionalFactorial2Level <: AbstractFactorialDesign
matrix::DataFrame
factors::NamedTuple
formula::FormulaTerm
ExperimentalDesign.FractionalFactorial2Level
— MethodFractionalFactorial2Level(formula::FormulaTerm) -> FractionalFactorial2Level
julia> FractionalFactorial2Level(@formula(y ~ a + b + a&b + c + a&c+ b&c + a&b&c))
FractionalFactorial2Level
Dimension: (8, 7)
Factors: (a = [-1, 1], b = [-1, 1], c = [-1, 1])
Formula: y ~ a + b + c + a & b + a & c + b & c + a & b & c
Design Matrix:
8×7 DataFrame
Row │ a b c a_b a_c b_c a_b_c
│ Int64 Int64 Int64 Int64 Int64 Int64 Int64
─────┼─────────────────────────────────────────────────
1 │ -1 -1 -1 1 1 1 -1
2 │ 1 -1 -1 -1 -1 1 1
3 │ -1 1 -1 -1 1 -1 1
4 │ 1 1 -1 1 -1 -1 -1
5 │ -1 -1 1 1 -1 -1 1
6 │ 1 -1 1 -1 1 -1 -1
7 │ -1 1 1 -1 -1 1 -1
8 │ 1 1 1 1 1 1 1
ExperimentalDesign.FullFactorial
— Typestruct FullFactorial <: AbstractFactorialDesign
Encapsulates an explicit full factorial design, where all experiments are completely computed and stored. Use IterableFullFactorial
to obtain an implicit factorial design with arbitrary access to the elements of a full factorial design.
matrix::DataFrame
factors::NamedTuple
formula::FormulaTerm
ExperimentalDesign.FullFactorial
— MethodFullFactorial(factors::Array) -> FullFactorial
julia> FullFactorial(fill([-1, 1], 3))
FullFactorial
Dimension: (8, 3)
Factors: (factor1 = [-1, 1], factor2 = [-1, 1], factor3 = [-1, 1])
Formula: 0 ~ factor1 + factor2 + factor3
Design Matrix:
8×3 DataFrame
Row │ factor1 factor2 factor3
│ Int64 Int64 Int64
─────┼───────────────────────────
1 │ -1 -1 -1
2 │ 1 -1 -1
3 │ -1 1 -1
4 │ 1 1 -1
5 │ -1 -1 1
6 │ 1 -1 1
7 │ -1 1 1
8 │ 1 1 1
ExperimentalDesign.FullFactorial
— MethodFullFactorial(factors::NamedTuple, formula::FormulaTerm) -> FullFactorial
julia> FullFactorial((A = [1, 2, 4], B = [:a, :b], C = [1.0, -1.0]), @formula(y ~ A + B +C))
FullFactorial
Dimension: (12, 3)
Factors: (A = [1, 2, 4], B = [:a, :b], C = [1.0, -1.0])
Formula: y ~ A + B + C
Design Matrix:
12×3 DataFrame
Row │ A B C
│ Any Any Any
─────┼────────────────
1 │ 1 a 1.0
2 │ 2 a 1.0
3 │ 4 a 1.0
4 │ 1 b 1.0
5 │ 2 b 1.0
6 │ 4 b 1.0
7 │ 1 a -1.0
8 │ 2 a -1.0
9 │ 4 a -1.0
10 │ 1 b -1.0
11 │ 2 b -1.0
12 │ 4 b -1.0
ExperimentalDesign.FullFactorial
— MethodFullFactorial(factors::NamedTuple) -> FullFactorial
julia> FullFactorial((A = [1, 2, 4], B = [:a, :b], C = [1.0, -1.0]))
FullFactorial
Dimension: (12, 3)
Factors: (A = [1, 2, 4], B = [:a, :b], C = [1.0, -1.0])
Formula: 0 ~ A + B + C
Design Matrix:
12×3 DataFrame
Row │ A B C
│ Any Any Any
─────┼────────────────
1 │ 1 a 1.0
2 │ 2 a 1.0
3 │ 4 a 1.0
4 │ 1 b 1.0
5 │ 2 b 1.0
6 │ 4 b 1.0
7 │ 1 a -1.0
8 │ 2 a -1.0
9 │ 4 a -1.0
10 │ 1 b -1.0
11 │ 2 b -1.0
12 │ 4 b -1.0
ExperimentalDesign.FullFactorial
— MethodFullFactorial(factors::Tuple) -> FullFactorial
julia> FullFactorial(([1, 2, 4], [:a, :b], [1.0, -1.0]))
FullFactorial
Dimension: (12, 3)
Factors: (factor1 = [1, 2, 4], factor2 = [:a, :b], factor3 = [1.0, -1.0])
Formula: 0 ~ factor1 + factor2 + factor3
Design Matrix:
12×3 DataFrame
Row │ factor1 factor2 factor3
│ Any Any Any
─────┼───────────────────────────
1 │ 1 a 1.0
2 │ 2 a 1.0
3 │ 4 a 1.0
4 │ 1 b 1.0
5 │ 2 b 1.0
6 │ 4 b 1.0
7 │ 1 a -1.0
8 │ 2 a -1.0
9 │ 4 a -1.0
10 │ 1 b -1.0
11 │ 2 b -1.0
12 │ 4 b -1.0
ExperimentalDesign.OptimLHCDesign
— Typestruct OptimLHCDesign <: ExperimentalDesign.AbstractRandomDesign
matrix::DataFrame
factors::Tuple
fitness::Vector{Float64}
ExperimentalDesign.OptimLHCDesign
— MethodOptimLHCDesign(n::Int64, d::Int64, gens) -> OptimLHCDesign
julia> OptimLHCDesign(5,3,4)
OptimLHCDesign
Dimension: (5, 3)
Factors: (:factor1, :factor2, :factor3)
Fitness: [1.3760238272524201, 1.3760238272524201, 1.3760238272524201, 1.3760238272524201, 1.3760238272524201]
Design Matrix:
5×3 DataFrame
Row │ factor1 factor2 factor3
│ Int64 Int64 Int64
─────┼───────────────────────────
1 │ 3 5 2
2 │ 5 1 3
3 │ 4 4 5
4 │ 2 2 1
5 │ 1 3 4
ExperimentalDesign.OptimLHCDesign
— MethodOptimLHCDesign(n::Int64, factors::Tuple, gens) -> OptimLHCDesign
julia> OptimLHCDesign(5,Tuple((:A,:B,:C)),4)
OptimLHCDesign
Dimension: (5, 3)
Factors: (:A, :B, :C)
Fitness: [1.3760238272524201, 1.3760238272524201, 1.3760238272524201, 1.3760238272524201, 1.3760238272524201]
Design Matrix:
5×3 DataFrame
Row │ A B C
│ Int64 Int64 Int64
─────┼─────────────────────
1 │ 3 5 2
2 │ 5 1 3
3 │ 4 4 5
4 │ 2 2 1
5 │ 1 3 4
ExperimentalDesign.OptimalDesign
— Typestruct OptimalDesign <: AbstractOptimalDesign
matrix::DataFrame
factors::NamedTuple
formula::FormulaTerm
selected_experiments::Array{Int64, N} where N
criteria::Dict{Symbol, Float64}
Contains a set of candidate experiments, a target optimality criterion, and a model prior formula. A set of experiments that maximizes a given optimality criterion can selected from a candidate set using the kl_exchange
algorithm.
ExperimentalDesign.OptimalDesign
— MethodOptimalDesign(candidates::AbstractDesign, formula::FormulaTerm, experiments::Int64; tolerance, seed_design_size, max_iterations, design_k, candidates_l) -> OptimalDesign
julia> design_distribution = DesignDistribution((f1 = Uniform(2, 3), f2 = DiscreteUniform(-1, 5), f3 = Uniform(5, 10)))
DesignDistribution
Formula: 0 ~ f1 + f2 + f3
Factor Distributions:
f1: Uniform{Float64}(a=2.0, b=3.0)
f2: DiscreteUniform(a=-1, b=5)
f3: Uniform{Float64}(a=5.0, b=10.0)
julia> design = rand(design_distribution, 400);
julia> f = @formula 0 ~ f1 + f2 + f3 + f2 ^ 2;
julia> OptimalDesign(design, f, 10)
OptimalDesign
Dimension: (10, 3)
Factors: (f1 = Uniform{Float64}(a=2.0, b=3.0), f2 = DiscreteUniform(a=-1, b=5), f3 = Uniform{Float64}(a=5.0, b=10.0))
Formula: 0 ~ f1 + f2 + f3 + :(f2 ^ 2)
Selected Candidate Rows: [244, 49, 375, 43, 369, 44, 16, 346, 175, 205]
Optimality Criteria: Dict(:D => 2.3940431912232483)
Design Matrix:
10×3 DataFrame
Row │ f1 f2 f3
│ Float64 Float64 Float64
─────┼───────────────────────────
1 │ 2.99329 1.0 5.09246
2 │ 2.96899 5.0 9.39802
3 │ 2.96274 -1.0 5.31426
4 │ 2.00285 2.0 5.40398
5 │ 2.8491 1.0 9.90621
6 │ 2.00309 -1.0 9.49394
7 │ 2.20051 2.0 9.75605
8 │ 2.06422 5.0 5.1759
9 │ 2.037 -1.0 9.13114
10 │ 2.82612 5.0 9.66349
ExperimentalDesign.PlackettBurman
— Typestruct PlackettBurman <: AbstractScreeningDesign
Encapsulates a Plackett-Burman screening design constructed using Paley's method. Factor levels are encoded as :high
and :low
symbols, and extra dummy variables, possibly aliasing interactions between factors, will be added to pad a design.
matrix::DataFrame
factors::Tuple
dummy_factors::Tuple
formula::FormulaTerm
ExperimentalDesign.PlackettBurman
— MethodPlackettBurman(formula::FormulaTerm; symbol_encoding) -> PlackettBurman
julia> PlackettBurman(@formula(y ~ x1 + x2 + x3 + x4))
PlackettBurman
Dimension: (8, 7)
Factors: (:x1, :x2, :x3, :x4)
Dummy Factors: (:dummy1, :dummy2, :dummy3)
Formula: y ~ -1 + x1 + x2 + x3 + x4 + dummy1 + dummy2 + dummy3
Design Matrix:
8×7 DataFrame
Row │ x1 x2 x3 x4 dummy1 dummy2 dummy3
│ Int64 Int64 Int64 Int64 Int64 Int64 Int64
─────┼────────────────────────────────────────────────────
1 │ 1 1 1 1 1 1 1
2 │ -1 1 -1 1 1 -1 -1
3 │ 1 -1 1 1 -1 -1 -1
4 │ -1 1 1 -1 -1 -1 1
5 │ 1 1 -1 -1 -1 1 -1
6 │ 1 -1 -1 -1 1 -1 1
7 │ -1 -1 -1 1 -1 1 1
8 │ -1 -1 1 -1 1 1 -1
ExperimentalDesign.PlackettBurman
— MethodPlackettBurman(factors::Int64) -> PlackettBurman
julia> PlackettBurman(4)
PlackettBurman
Dimension: (8, 7)
Factors: (:factor1, :factor2, :factor3, :factor4)
Dummy Factors: (:dummy1, :dummy2, :dummy3)
Formula: 0 ~ -1 + factor1 + factor2 + factor3 + factor4 + dummy1 + dummy2 + dummy3
Design Matrix:
8×7 DataFrame
Row │ factor1 factor2 factor3 factor4 dummy1 dummy2 dummy3
│ Int64 Int64 Int64 Int64 Int64 Int64 Int64
─────┼────────────────────────────────────────────────────────────
1 │ 1 1 1 1 1 1 1
2 │ -1 1 -1 1 1 -1 -1
3 │ 1 -1 1 1 -1 -1 -1
4 │ -1 1 1 -1 -1 -1 1
5 │ 1 1 -1 -1 -1 1 -1
6 │ 1 -1 -1 -1 1 -1 1
7 │ -1 -1 -1 1 -1 1 1
8 │ -1 -1 1 -1 1 1 -1
ExperimentalDesign.RandomLHCDesign
— Typestruct RandomLHCDesign <: ExperimentalDesign.AbstractRandomDesign
matrix::DataFrame
factors::Tuple
ExperimentalDesign.RandomLHCDesign
— MethodRandomLHCDesign(n::Int64, d::Int64) -> RandomLHCDesign
julia> RandomLHCDesign(4,3)
RandomLHCDesign
Dimension: (4, 3)
Factors: (:factor1, :factor2, :factor3)
Design Matrix:
4×3 DataFrame
Row │ factor1 factor2 factor3
│ Int64 Int64 Int64
─────┼───────────────────────────
1 │ 1 4 4
2 │ 2 1 2
3 │ 3 3 3
4 │ 4 2 1
ExperimentalDesign.RandomLHCDesign
— MethodRandomLHCDesign(n::Int64, factors::Tuple) -> RandomLHCDesign
julia> RandomLHCDesign(4,Tuple((:A,:B,:C)))
RandomLHCDesign
Dimension: (4, 3)
Factors: (:A, :B, :C)
Design Matrix:
4×3 DataFrame
Row │ A B C
│ Int64 Int64 Int64
─────┼─────────────────────
1 │ 1 4 4
2 │ 2 1 2
3 │ 3 3 3
4 │ 4 2 1
Base.rand
— Functionrand(distribution::DesignDistribution) -> ExperimentalDesign.RandomDesign
rand(distribution::DesignDistribution, n::Int64) -> ExperimentalDesign.RandomDesign
julia> rand(DesignDistribution((f1 = Uniform(2, 3), f2 = DiscreteUniform(-1, 5), f3 = Uniform(5, 10))), 12)
ExperimentalDesign.RandomDesign
Dimension: (12, 3)
Factors: (f1 = Uniform{Float64}(a=2.0, b=3.0), f2 = DiscreteUniform(a=-1, b=5), f3 = Uniform{Float64}(a=5.0, b=10.0))
Formula: 0 ~ f1 + f2 + f3
Design Matrix:
12×3 DataFrame
Row │ f1 f2 f3
│ Float64 Float64 Float64
─────┼───────────────────────────
1 │ 2.04922 -1.0 9.62061
2 │ 2.59117 3.0 5.79254
3 │ 2.77148 -1.0 6.22902
4 │ 2.25659 4.0 6.00256
5 │ 2.64968 2.0 9.21818
6 │ 2.31523 5.0 8.80749
7 │ 2.86526 2.0 8.47297
8 │ 2.44753 0.0 6.11722
9 │ 2.08284 -1.0 6.34626
10 │ 2.81201 -1.0 6.44508
11 │ 2.64232 3.0 5.57183
12 │ 2.08189 1.0 8.72759
Base.rand
— Functionrand(distribution::CategoricalFactor) -> Vector{_A} where _A
rand(distribution::CategoricalFactor, n::Int64) -> Vector{_A} where _A
julia> rand(CategoricalFactor([:a, :b, 2, 1.0]), 6)
6-element Vector{Any}:
2
1.0
:b
2
2
1.0
ExperimentalDesign.boxbehnken
— Methodboxbehnken(matrix_size::Int64, center::Int64) -> Any
Constructs a Box-Behnken design with size matrix_size
with specified number of center points.
julia> boxbehnken(4,0)
24×4 transpose(::Matrix{Float64}) with eltype Float64:
-1.0 -1.0 0.0 0.0
1.0 -1.0 0.0 0.0
-1.0 1.0 0.0 0.0
1.0 1.0 0.0 0.0
-1.0 0.0 -1.0 0.0
1.0 0.0 -1.0 0.0
-1.0 0.0 1.0 0.0
1.0 0.0 1.0 0.0
-1.0 0.0 0.0 -1.0
1.0 0.0 0.0 -1.0
⋮
0.0 1.0 1.0 0.0
0.0 -1.0 0.0 -1.0
0.0 1.0 0.0 -1.0
0.0 -1.0 0.0 1.0
0.0 1.0 0.0 1.0
0.0 0.0 -1.0 -1.0
0.0 0.0 1.0 -1.0
0.0 0.0 -1.0 1.0
0.0 0.0 1.0 1.0
ExperimentalDesign.boxbehnken
— Methodboxbehnken(matrix_size::Int64) -> Any
Constructs a Box-Behnken design with size matrix_size
.
julia> boxbehnken(4)
27×4 transpose(::Matrix{Float64}) with eltype Float64:
-1.0 -1.0 0.0 0.0
1.0 -1.0 0.0 0.0
-1.0 1.0 0.0 0.0
1.0 1.0 0.0 0.0
-1.0 0.0 -1.0 0.0
1.0 0.0 -1.0 0.0
-1.0 0.0 1.0 0.0
1.0 0.0 1.0 0.0
-1.0 0.0 0.0 -1.0
1.0 0.0 0.0 -1.0
⋮
0.0 -1.0 0.0 1.0
0.0 1.0 0.0 1.0
0.0 0.0 -1.0 -1.0
0.0 0.0 1.0 -1.0
0.0 0.0 -1.0 1.0
0.0 0.0 1.0 1.0
0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0
ExperimentalDesign.ccdesign
— Functionccdesign(n::Int64) -> Any
ccdesign(n::Int64, center::Array{Int64, N} where N) -> Any
ccdesign(n::Int64, center::Array{Int64, N} where N, alpha::Symbol) -> Any
ccdesign(n::Int64, center::Array{Int64, N} where N, alpha::Symbol, face::Symbol) -> Any
Constructs a central composite design.
julia> ccdesign(3)
22×3 Matrix{Float64}:
-1.0 -1.0 -1.0
1.0 -1.0 -1.0
-1.0 1.0 -1.0
1.0 1.0 -1.0
-1.0 -1.0 1.0
1.0 -1.0 1.0
-1.0 1.0 1.0
1.0 1.0 1.0
0.0 0.0 0.0
0.0 0.0 0.0
⋮
1.82574 0.0 0.0
0.0 -1.82574 0.0
0.0 1.82574 0.0
0.0 0.0 -1.82574
0.0 0.0 1.82574
0.0 0.0 0.0
0.0 0.0 0.0
0.0 0.0 0.0
0.0 0.0 0.0
ExperimentalDesign.d_criterion
— Methodd_criterion(model_matrix; tolerance) -> Any
Criterion of D-optimality, which seeks to minimize $|(X^T · X) − I*tol| / N^{1/b}$, or equivalently maximize the determinant of the information matrix $X^T · X$ of the design. This criterion results in maximizing the differential Shannon information content of the parameter estimates.
ExperimentalDesign.explicit_fullfactorial
— Methodexplicit_fullfactorial(iterator::Base.Iterators.ProductIterator) -> Any
Receives a Base.Iterators.ProductIterator
and computes an explicit full factorial design. The generated array is exponentially large.
julia> explicit_fullfactorial(fullfactorial(([-1, 1], [:a, :b, :c])))
6×2 Matrix{Any}:
-1 :a
1 :a
-1 :b
1 :b
-1 :c
1 :c
ExperimentalDesign.explicit_fullfactorial
— Methodexplicit_fullfactorial(factors::Tuple) -> Any
Receives a tuple of arrays representing categorical factor levels, and computes an explicit full factorial design. The generated array is exponentially large.
julia> explicit_fullfactorial(([-1, 1], [:a, :b, :c], [1, 2]))
12×3 Matrix{Any}:
-1 :a 1
1 :a 1
-1 :b 1
1 :b 1
-1 :c 1
1 :c 1
-1 :a 2
1 :a 2
-1 :b 2
1 :b 2
-1 :c 2
1 :c 2
ExperimentalDesign.fold!
— Methodfold!(design::FractionalFactorial2Level) -> DataFrame
julia> fold!(FractionalFactorial2Level(@formula(y ~ a + b + a&b + c + a&c+ b&c + a&b&c)))
16×7 DataFrame
Row │ a b c a_b a_c b_c a_b_c
│ Int64 Int64 Int64 Int64 Int64 Int64 Int64
─────┼─────────────────────────────────────────────────
1 │ -1 -1 -1 1 1 1 -1
2 │ 1 -1 -1 -1 -1 1 1
3 │ -1 1 -1 -1 1 -1 1
4 │ 1 1 -1 1 -1 -1 -1
5 │ -1 -1 1 1 -1 -1 1
6 │ 1 -1 1 -1 1 -1 -1
7 │ -1 1 1 -1 -1 1 -1
8 │ 1 1 1 1 1 1 1
9 │ 1 1 1 -1 -1 -1 1
10 │ -1 1 1 1 1 -1 -1
11 │ 1 -1 1 1 -1 1 -1
12 │ -1 -1 1 -1 1 1 1
13 │ 1 1 -1 -1 1 1 -1
14 │ -1 1 -1 1 -1 1 1
15 │ 1 -1 -1 1 1 -1 1
16 │ -1 -1 -1 -1 -1 -1 -1
ExperimentalDesign.fold!
— Methodfold!(design::PlackettBurman) -> DataFrame
julia> fold!(PlackettBurman(2))
8×3 DataFrame
Row │ factor1 factor2 dummy1
│ Int64 Int64 Int64
─────┼──────────────────────────
1 │ 1 1 1
2 │ 1 -1 -1
3 │ -1 -1 1
4 │ -1 1 -1
5 │ -1 -1 -1
6 │ -1 1 1
7 │ 1 1 -1
8 │ 1 -1 1
ExperimentalDesign.fullfactorial
— Methodfullfactorial(factors::Tuple) -> Base.Iterators.ProductIterator
Receives a tuple of arrays representing categorical factor levels, and returns a Base.Iterators.ProductIterator
. This allows full factorial designs to be arbitrarily large and only be computed as needed. To compute an explicit full factorial design, use explicit_fullfactorial
.
julia> fullfactorial(Tuple([-1, 1] for i = 1:10))
Base.Iterators.ProductIterator{NTuple{10, Vector{Int64}}}(([-1, 1], [-1, 1], [-1, 1], [-1, 1], [-1, 1], [-1, 1], [-1, 1], [-1, 1], [-1, 1], [-1, 1]))
ExperimentalDesign.isplackettburman
— Methodisplackettburman(d::Matrix{Int64}) -> Bool
To check if a given design is a Plackett-Burman design, we must check for the following properties, obtained in the original Plackett-Burman paper:
Each component is replicated at each of its values the same number of times, that is, the sum of elements in each column is zero
Each pair of components occur together at every combination of values the same number of times, that is, the sum of each pair of columns will produce a column with the same number of occurrences of $2$ and $-2$, and twice that number of occurrences of $0$
Plackett, R.L. and Burman, J.P., 1946. The design of optimum multifactorial experiments. Biometrika, 33(4), pp.305-325.
julia> isplackettburman(plackettburman(2))
true
julia> isplackettburman(plackettburman(4))
true
julia> isplackettburman(plackettburman(16))
true
julia> isplackettburman(rand(Int, 4,4))
false
ExperimentalDesign.kl_exchange
— Methodkl_exchange(formula::FormulaTerm, candidate_set::DataFrame; tolerance, seed_design_size, max_iterations, experiments, design_k, candidates_l)
Builds optimum designs using the KL exchange algorithm, as described by Atkinson et al.. The ideia is to iteratively swap $K$ design elements with $L$ candidate elements, in order to maximize an optimality criterion. Although any criteria based on information matrices could be used here, the KL exchange algorithm leverages determinant properties to optimize the d_criterion
.
Atkinson, A., Donev, A., & Tobias, R. (2007). Optimum experimental designs, with SAS (Vol. 34). Oxford University Press, Chapter 12.
julia> candidates = FullFactorial(fill([-1, 0, 1], 5));
julia> candidates_formula = ConstantTerm(0) ~ sum(Term.(Symbol.(names(candidates.matrix))));
julia> candidates_formula = FormulaTerm(candidates_formula.lhs,
candidates_formula.rhs +
(@formula 0 ~ factor3 ^ 2).rhs);
julia> selected_rows = kl_exchange(candidates_formula,
candidates.matrix,
seed_design_size = 2,
experiments = 11,
design_k = 11,
candidates_l = size(candidates.matrix, 1) - 11);
julia> d_criterion(selected_rows)
0.730476820204009
julia> candidates.matrix[selected_rows.indices[1], :]
11×5 DataFrames.DataFrame
│ Row │ factor1 │ factor2 │ factor3 │ factor4 │ factor5 │
│ │ Int64 │ Int64 │ Int64 │ Int64 │ Int64 │
├─────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│ 1 │ -1 │ 1 │ -1 │ 1 │ 1 │
│ 2 │ 1 │ -1 │ 1 │ 1 │ 1 │
│ 3 │ 1 │ 1 │ 0 │ -1 │ 1 │
│ 4 │ -1 │ 1 │ 1 │ -1 │ 1 │
│ 5 │ -1 │ -1 │ 0 │ 1 │ 1 │
│ 6 │ 1 │ 1 │ 1 │ 1 │ -1 │
│ 7 │ -1 │ -1 │ 1 │ -1 │ -1 │
│ 8 │ 1 │ -1 │ 0 │ 1 │ -1 │
│ 9 │ -1 │ 1 │ -1 │ 1 │ -1 │
│ 10 │ -1 │ 1 │ 0 │ -1 │ -1 │
│ 11 │ 1 │ -1 │ -1 │ -1 │ -1 │
julia> n_candidates = 3000;
julia> n_factors = 30;
julia> design_generator = DesignDistribution(Uniform(0, 1), n_factors);
julia> candidates = rand(design_generator, n_candidates);
julia> selected_rows = kl_exchange(candidates.formula,
candidates.matrix,
experiments = n_factors + 2,
design_k = n_factors,
candidates_l = round(Int, (n_candidates - n_factors) / 2));
julia> d_criterion(selected_rows)
0.07904918814259465
julia> candidates.matrix[selected_rows.indices[1], :]
32×30 DataFrame. Omitted printing of 24 columns
│ Row │ factor1 │ factor2 │ factor3 │ factor4 │ factor5 │ factor6 │
│ │ Float64 │ Float64 │ Float64 │ Float64 │ Float64 │ Float64 │
├─────┼────────────┼───────────┼───────────┼───────────┼───────────┼───────────┤
│ 1 │ 0.832487 │ 0.875035 │ 0.433788 │ 0.805738 │ 0.481517 │ 0.382364 │
│ 2 │ 0.761498 │ 0.0398811 │ 0.998741 │ 0.632286 │ 0.29121 │ 0.55497 │
│ 3 │ 0.639793 │ 0.49432 │ 0.678795 │ 0.685274 │ 0.269203 │ 0.896397 │
│ 4 │ 0.00370418 │ 0.5139 │ 0.0630861 │ 0.175531 │ 0.570244 │ 0.60512 │
│ 5 │ 0.698514 │ 0.207593 │ 0.766977 │ 0.0719112 │ 0.665055 │ 0.499193 │
│ 6 │ 0.412744 │ 0.785263 │ 0.432861 │ 0.909976 │ 0.642545 │ 0.832013 │
│ 7 │ 0.353518 │ 0.116685 │ 0.140352 │ 0.929095 │ 0.0484366 │ 0.838524 │
⋮
│ 25 │ 0.577343 │ 0.790529 │ 0.763994 │ 0.548131 │ 0.402066 │ 0.293336 │
│ 26 │ 0.0941214 │ 0.52891 │ 0.293733 │ 0.92224 │ 0.982713 │ 0.929744 │
│ 27 │ 0.0256128 │ 0.723072 │ 0.23927 │ 0.993221 │ 0.521335 │ 0.407319 │
│ 28 │ 0.221631 │ 0.375189 │ 0.67251 │ 0.658613 │ 0.272448 │ 0.230501 │
│ 29 │ 0.843885 │ 0.375497 │ 0.116069 │ 0.989937 │ 0.935444 │ 0.0466424 │
│ 30 │ 0.181611 │ 0.956062 │ 0.98997 │ 0.80352 │ 0.994557 │ 0.203797 │
│ 31 │ 0.738407 │ 0.25753 │ 0.929704 │ 0.407498 │ 0.0934688 │ 0.99359 │
│ 32 │ 0.228975 │ 0.81272 │ 0.803107 │ 0.931826 │ 0.598371 │ 0.588823 │
ExperimentalDesign.next_offset_divisible_prime
— Methodnext_offset_divisible_prime(n::Int64, offset::Int64, divisor::Int64, tries::Int64) -> Int64
Gets the next prime p
, starting from n
, for which (p + offset) % divisor == 0
holds.
julia> next_offset_divisible_prime(3, 1, 4, 1000)
3
julia> next_offset_divisible_prime(5, 1, 4, 1000)
7
julia> next_offset_divisible_prime(4, 1, 4, 1000)
7
ExperimentalDesign.paley
— Methodpaley(matrix::Matrix{Int64}) -> Matrix{Int64}
The Paley construction is a method for constructing Hadamard matrices using finite fields.
julia> paley(Matrix{Int}(undef, 8, 8))
8×8 Matrix{Int64}:
-1 1 1 -1 1 1 1 -1
1 1 -1 1 1 1 -1 -1
1 -1 1 1 1 -1 -1 1
-1 1 1 1 -1 -1 1 1
1 1 1 -1 -1 1 1 -1
1 1 -1 -1 1 1 -1 1
1 -1 -1 1 1 -1 1 1
-1 -1 1 1 -1 1 1 1
ExperimentalDesign.plackettburman
— Methodplackettburman(matrix_size::Int64) -> Matrix{Int64}
Constructs a Plackett-Burman design with size matrix_size
if possible, or to the closest, largest, number for which it is possible.
julia> plackettburman(4)
8×7 Matrix{Int64}:
1 1 1 1 1 1 1
-1 1 -1 1 1 -1 -1
1 -1 1 1 -1 -1 -1
-1 1 1 -1 -1 -1 1
1 1 -1 -1 -1 1 -1
1 -1 -1 -1 1 -1 1
-1 -1 -1 1 -1 1 1
-1 -1 1 -1 1 1 -1
ExperimentalDesign.random_design!
— Methodrandom_design!(distributions::Tuple, n::Int64) -> Any
julia> random_design!((Uniform(2, 3), DiscreteUniform(-1, 5), Uniform(5, 10)), 10)
10×3 Matrix{Float64}:
2.04922 -1.0 8.21161
2.59117 3.0 5.40944
2.77148 -1.0 9.62061
2.25659 4.0 5.79254
2.64968 2.0 6.22902
2.31523 5.0 6.00256
2.86526 2.0 9.21818
2.44753 0.0 8.80749
2.08284 -1.0 8.47297
2.81201 -1.0 6.11722