Package 'BDEsize'

Title: Efficient Determination of Sample Size in Balanced Design of Experiments
Description: For a balanced design of experiments, this package calculates the sample size required to detect a certain standardized effect size, under a significance level. This package also provides three graphs; detectable standardized effect size vs power, sample size vs detectable standardized effect size, and sample size vs power, which show the mutual relationship between the sample size, power and the detectable standardized effect size. The detailed procedure is described in R. V. Lenth (2006-9) <https://homepage.divms.uiowa.edu/~rlenth/Power/>, Y. B. Lim (1998), M. A. Kastenbaum, D. G. Hoel and K. O. Bowman (1970) <doi:10.2307/2334851>, and Douglas C. Montgomery (2013, ISBN: 0849323312).
Authors: Jong Hee Chung [aut, cre], Yong Bin Lim [aut], Donghoh Kim [ctb]
Maintainer: Jong Hee Chung <[email protected]>
License: GPL (>= 2)
Version: 1.6
Built: 2024-10-31 06:26:47 UTC
Source: CRAN

Help Index


Diagnosis Graphs for Sample Size of Two-level Fractional Factorial Design

Description

This function produces graphs between the sample size, power and the detectable standardized effect size of two-level fractional factorial design.

Usage

plots.2levFr(nfactor, nfraction, interaction = FALSE, delta_type = 1, 
    delta = c(1, 0, 1), deltao = NULL, alpha = 0.05, beta = 0.2, type = 1, 
    maxsize = 1000)

Arguments

nfactor

the number of factor.

nfraction

the number of fraction. For example, when a model is 2(kp)2^(k-p), k is the number of factor and p is the number of fraction. It is called a 1/2p1/2^p fraction of the 2k2^k design.

interaction

specifies whether two-way interaction effects are included in a model with the main effects. When interaction = TRUE, two-way interaction effects are include in a model.

delta_type

specifies the type of standardized effect size: 1 for standard deviation type and 2 for range type.

delta

vector of effect sizes: delta[1] for main effects, delta[2] for two-way interaction effects, and delta[3] for standard deviation of noise. When interaction=FALSE, delta[2] is 0.

deltao

the minimal detectable standardized effect size for power vs the sample size plot when type = 3.

alpha

Type I error.

beta

Type II error.

type

graph type: 1 for Power vs Delta plot, 2 for Delta vs Sample size plot, and 3 for Power vs Sample size plot.

maxsize

tolerance for sample size.

Details

This function produces graph between the sample size, power 1-beta and the detectable standardized effect size delta of two-level fractional factorial design. According to type, it displays plot of Power vs Delta, Delta vs Sample size, or Power vs Sample size.

Value

plot of Power vs Delta, Delta vs Sample size, or Power vs Sample size according to type.

See Also

plots.Full, plots.Split, plots.Block.

Examples

# plot of Power vs Delta for two-level fractional factorial design
# without the interaction effects
plots.2levFr(nfactor=3, nfraction=1, interaction=FALSE,
    delta_type=1, delta=c(1, 0, 1), alpha=0.05, beta=0.2, type=1)
# plot of Power vs Sample size for two-level fractional factorial design
# with the interaction effects
plots.2levFr(nfactor=5, nfraction=1, interaction=TRUE,
    delta_type=1, delta=c(1, 1, 1), deltao=1, alpha=0.05, beta=0.2, type=3)

Diagnosis Graphs for the number of Blocks of Randomized Complete Block Design

Description

This function produces graphs between the sample size, power and the detectable standardized effect size of randomized complete block design.

Usage

plots.Block(factor.lev, interaction = FALSE, delta_type = 1, delta = c(1, 0, 1), 
    deltao = NULL, alpha = 0.05, beta = 0.2, type = 1, maxsize = 1000)

Arguments

factor.lev

vector of the numbers of levels for each factor.

interaction

specifies whether two-way interaction effects are included in a model with the main effects. When interaction = TRUE, two-way interaction effects are include in a model.

delta_type

specifies the type of standardized effect size: 1 for standard deviation type and 2 for range type.

delta

vector of effect sizes: delta[1] for main effects, delta[2] for two-way interaction effects, and delta[3] for standard deviation of noise. When interaction=FALSE, delta[2] is 0.

deltao

the minimal detectable standardized effect size for power vs the number of blocks plot when type = 3.

alpha

Type I error.

beta

Type II error.

type

graph type: 1 for Power vs Delta plot, 2 for Delta vs the Number of Blocks plot, and 3 for Power vs the Number of Blocks plot.

maxsize

tolerance for the number of blocks.

Details

In a randomized complete block design (without replications), the optimal number of blocks need to be determined. This function produces graph between Number of Block, power 1-beta and the detectable standardized effect size delta of randomized complete block design. According to type, it displays plot of Power vs Delta, Delta vs Number of Blocks, or Power vs Number of Blocks.

Value

plot of Power vs Delta, Delta vs Number of Blocks, or Power vs Number of Blocks according to type.

See Also

plots.Full, plots.2levFr, plots.Split.

Examples

# plot of Power vs Delta for randomized complete block design 
# with 2 factors without the interaction effects
plots.Block(factor.lev=c(2, 2), interaction=FALSE,
    delta_type=1, delta=c(1, 0, 1), alpha=0.05, beta=0.2, type=1)
    
# plot of Power vs Number of Blocks for randomized complete block design 
# with 2 factors with the interaction effects
plots.Block(factor.lev=c(2, 3), interaction=TRUE,
    delta_type=1, delta=c(1, 1, 1), deltao=1.5, alpha=0.05, beta=0.2, type=3)

Diagnosis Graphs for Sample Size of Full Factorial Design

Description

This function produces graphs between the sample size, power and the detectable standardized effect size of full factorial design.

Usage

plots.Full(factor.lev, interaction = FALSE, delta_type = 1, delta = c(1, 0, 1),
    deltao = NULL, alpha = 0.05, beta = 0.2, type = 1, maxsize = 1000)

Arguments

factor.lev

vector of the numbers of levels for each factor.

interaction

specifies whether two-way interaction effects are included in a model with the main effects. When interaction = TRUE, two-way interaction effects are include in a model.

delta_type

specifies the type of standardized effect size: 1 for standard deviation type and 2 for range type.

delta

vector of effect sizes: delta[1] for main effects, delta[2] for two-way interaction effects, and delta[3] for standard deviation of noise. When interaction=FALSE, delta[2] is 0.

deltao

the minimal detectable standardized effect size for power vs the sample size plot when type = 3.

alpha

Type I error.

beta

Type II error.

type

graph type: 1 for Power vs Delta plot, 2 for Delta vs Sample size plot, and 3 for Power vs Sample size plot.

maxsize

tolerance for sample size.

Details

This function produces graph between the sample size, power 1-beta and the detectable standardized effect size delta of full factorial design. According to type, it displays plot of Power vs Delta, Delta vs Sample size, or Power vs Sample size.

Value

plot of Power vs Delta, Delta vs Sample size, or Power vs Sample size according to type.

See Also

plots.2levFr, plots.Split, plots.Block.

Examples

# plot of Power vs Delta for full factorial design 
# with 2 factors without the interaction effects
plots.Full(factor.lev=c(2, 3), interaction=FALSE,
    delta_type=1, delta=c(1, 0, 1), alpha=0.05, beta=0.2, type=1)
    
# plot of Power vs Sample size for full factorial design 
# with 2 factors with the interaction effects
plots.Full(factor.lev=c(2, 3), interaction=TRUE,
    delta_type=1, delta=c(1, 1, 1), deltao=1.5, alpha=0.05, beta=0.2, type=3)

Diagnosis Graphs for Sample Size of Split-Plot Design

Description

This function produces graphs between the sample size, power and the detectable standardized effect size of split-plot design.

Usage

plots.Split(whole.factor.lev, split.factor.lev, interaction = FALSE, 
    delta_type = 1, delta = c(1, 0, 1, 1), deltao = NULL, alpha = 0.05, beta = 0.2, 
    type = 1, maxsize = 1000)

Arguments

whole.factor.lev

vector of the numbers of levels for each whole factor.

split.factor.lev

vector of the numbers of levels for each split factor.

interaction

specifies whether two-way interaction effects are included in a model with the main effects. When interaction = TRUE, two-way interaction effects are include in a model.

delta_type

specifies the type of standardized effect size: 1 for standard deviation type and 2 for range type.

delta

vector of effect sizes: delta[1] for main effects, delta[2] for two-way interaction effects, and delta[3] and delta[4] for standard deviation of whole-plot noise and subplot noise, respectively. When interaction=FALSE, delta[2] is 0.

deltao

the minimal detectable standardized effect size for power vs the sample size plot when type = 3.

alpha

Type I error.

beta

Type II error.

type

graph type: 1 for Power vs Delta plot, 2 for Delta vs Sample size plot, and 3 for Power vs Sample size plot.

maxsize

tolerance for sample size.

Details

This function produces graph between the sample size, power 1-beta and the detectable standardized effect size delta of split-plot design. According to type, it displays plot of Power vs Delta, Delta vs Sample size, or Power vs Sample size. The number of whole-plot factors and split plot factors are up to 2 in the current package version.

Value

plot of Power vs Delta, Delta vs Sample size, or Power vs Sample size according to type.

See Also

plots.Full, plots.2levFr, plots.Block.

Examples

# plot of Power vs Delta for split-plot design 
# without the interaction effects
plots.Split(whole.factor.lev=2, split.factor.lev=2, interaction=FALSE,
    delta_type=1, delta=c(1, 0, 1, 1), alpha=0.05, beta=0.2, type=1)
  
# plot of Power vs Sample size for split-plot design 
# with the interaction effects
plots.Split(whole.factor.lev=2, split.factor.lev=2, interaction=TRUE,
    delta_type=1, delta=c(1, 1, 1, 1), deltao=1, alpha=0.05, beta=0.2, type=3)

Sample Size Calculator for Two-level Fractional Factorial Design

Description

This function computes sample size for two-level fractional factorial design to detect a certain standardized effect size with power at the significance level. The model for fractional factorial design contains only main effects in resolution III and IV.

Usage

Size.2levFr(nfactor, nfraction, interaction = FALSE, delta_type = 1, 
    delta = c(1, 0, 1), alpha = 0.05, beta = 0.2, maxsize = 1000)

Arguments

nfactor

the number of factor.

nfraction

the number of fraction. For example, when a model is 2(kp)2^(k-p), k is the number of factor and p is the number of fraction. It is called a 1/2p1/2^p fraction of the 2k2^k design.

interaction

specifies whether two-way interaction effects are included in a model with the main effects. When interaction = TRUE, two-way interaction effects are include in a model.

delta_type

specifies the type of standardized effect size: 1 for standard deviation type and 2 for range type.

delta

vector of effect sizes: delta[1] for main effects, delta[2] for two-way interaction effects, and delta[3] for standard deviation of noise. When interaction=FALSE, delta[2] is 0.

alpha

Type I error.

beta

Type II error.

maxsize

tolerance for sample size.

Details

This function computes sample size in two-level fractional factorial design to detect a certain standardized effect size delta with power 1-beta at the significance level alpha.

Value

model

a character vector expressing a model. The main effects are expressed by the upper-case letters of the Roman alphabet, and two-way interaction effects are denoted by * operator for pairs of the main effects.

n

optimal sample size.

Delta

a vector of minimal detectable standardized effect sizes.

References

R. V. Lenth (2006-9). Java Applets for Power and Sample Size[Computer software]. Retrieved March 27, 2018 from https://homepage.divms.uiowa.edu/~rlenth/Power/.

Y. B. Lim (1998). Study on the Size of Minimal Standardized Detectable Difference in Balanced Design of Experiments. Journal of the Korean society for Quality Management, 26(4), 239–249.

M. A. Kastenbaum, D. G. Hoel and K. O. Bowman (1970) Sample size requirements : one-way analysis of variance, Biometrika, 57(2), 421–430.

D. C. Montgomery (2013) Design and analysis of experiments. John Wiley & Sons.

See Also

Size.Full, Size.Split, Size.Block.

Examples

# only main effects
model1 <- Size.2levFr(nfactor=3, nfraction=1, interaction=FALSE,
    delta_type=1, delta=c(1, 0, 1), alpha=0.05, beta=0.2)
model1$model
model1$n
model1$Delta

# including two-way interaction effects
model2 <- Size.2levFr(nfactor=5, nfraction=1, interaction=TRUE,
    delta_type=1, delta=c(1, 1, 1), alpha=0.05, beta=0.2)

The number of Blocks Calculator for Randomized Complete Block Design

Description

This function computes the number of blocks for randomized complete block design to detect a certain standardized effect size with power at the significance level.

Usage

Size.Block(factor.lev, interaction = FALSE, delta_type = 1, delta = c(1, 0, 1), 
    alpha = 0.05, beta = 0.2, maxsize = 1000)

Arguments

factor.lev

vector of the numbers of levels for each factor.

interaction

specifies whether two-way interaction effects are included in a model with the main effects. When interaction = TRUE, two-way interaction effects are include in a model.

delta_type

specifies the type of standardized effect size: 1 for standard deviation type and 2 for range type.

delta

vector of effect sizes: delta[1] for main effects, delta[2] for two-way interaction effects, and delta[3] for standard deviation of noise. When interaction=FALSE, delta[2] is 0.

alpha

Type I error.

beta

Type II error.

maxsize

tolerance for the number of blocks.

Details

In a randomized complete block design (without replications), the optimal number of blocks need to be determined. This function computes the number of blocks for randomized complete block design to detect a certain standardized effect size delta with power 1-beta at the significance level alpha.

Value

model

a character vector expressing a model. The main effects are expressed by the upper-case letters of the Roman alphabet, and two-way interaction effects are denoted by * operator for pairs of the main effects. The block factor is denoted by Block.

n

optimal the number of blocks.

Delta

a vector of minimal detectable standardized effect sizes.

References

R. V. Lenth (2006-9). Java Applets for Power and Sample Size[Computer software]. Retrieved March 27, 2018 from https://homepage.divms.uiowa.edu/~rlenth/Power/.

Y. B. Lim (1998). Study on the Size of Minimal Standardized Detectable Difference in Balanced Design of Experiments. Journal of the Korean society for Quality Management, 26(4), 239–249.

M. A. Kastenbaum, D. G. Hoel and K. O. Bowman (1970) Sample size requirements : one-way analysis of variance, Biometrika, 57(2), 421–430.

D. C. Montgomery (2013) Design and analysis of experiments. John Wiley & Sons.

See Also

Size.Full, Size.2levFr, Size.Split.

Examples

# only main effects
model1 <- Size.Block(factor.lev=c(2, 2), interaction=FALSE,
   delta_type=1, delta=c(1, 0, 1), alpha=0.05, beta=0.2)
model1$model
model1$n
model1$Delta

# including two-way interaction effects
model2 <- Size.Block(factor.lev=c(2, 2), interaction=TRUE,
    delta_type=1, delta=c(1, 1, 1), alpha=0.05, beta=0.2)
model2

Sample Size Calculator for Full Factorial Design

Description

This function computes sample size for full factorial design to detect a certain standardized effect size with power at the significance level.

Usage

Size.Full(factor.lev, interaction = FALSE, delta_type = 1, delta = c(1, 0, 1), 
    alpha = 0.05, beta = 0.2, maxsize = 1000)

Arguments

factor.lev

vector of the numbers of levels for each factor.

interaction

specifies whether two-way interaction effects are included in a model with the main effects. When interaction = TRUE, two-way interaction effects are include in a model.

delta_type

specifies the type of standardized effect size: 1 for standard deviation type and 2 for range type.

delta

vector of effect sizes: delta[1] for main effects, delta[2] for two-way interaction effects, and delta[3] for standard deviation of noise. When interaction=FALSE, delta[2] is 0.

alpha

Type I error.

beta

Type II error.

maxsize

tolerance for sample size.

Details

This function computes sample size in full factorial design to detect a certain standardized effect size delta with power 1-beta at the significance level alpha.

Value

model

a character vector expressing a model. The main effects are expressed by the upper-case letters of the Roman alphabet, and two-way interaction effects are denoted by * operator for pairs of the main effects.

n

optimal sample size.

Delta

a vector of minimal detectable standardized effect sizes.

References

R. V. Lenth (2006-9). Java Applets for Power and Sample Size[Computer software]. Retrieved March 27, 2018 from https://homepage.divms.uiowa.edu/~rlenth/Power/.

Y. B. Lim (1998). Study on the Size of Minimal Standardized Detectable Difference in Balanced Design of Experiments. Journal of the Korean society for Quality Management, 26(4), 239–249.

M. A. Kastenbaum, D. G. Hoel and K. O. Bowman (1970) Sample size requirements : one-way analysis of variance, Biometrika, 57(2), 421–430.

D. C. Montgomery (2013) Design and analysis of experiments. John Wiley & Sons.

See Also

Size.2levFr, Size.Split, Size.Block.

Examples

# only main effects
model1 <- Size.Full(factor.lev=c(2, 2), interaction=FALSE,
   delta_type=1, delta=c(1, 0, 1), alpha=0.05, beta=0.2)
model1$model
model1$n
model1$Delta

# including two-way interaction effects
model2 <- Size.Full(factor.lev=c(2, 2), interaction=TRUE,
    delta_type=1, delta=c(1, 1, 1), alpha=0.05, beta=0.2)
model2

Sample Size Calculator for Split-Plot Design

Description

This function computes sample size for split-plot design to detect a certain standardized effect size with power at the significance level.

Usage

Size.Split(whole.factor.lev, split.factor.lev, interaction = FALSE, 
    delta_type = 1, delta = c(1, 0, 1, 1), alpha = 0.05, beta = 0.2, 
    maxsize = 1000)

Arguments

whole.factor.lev

vector of the numbers of levels for each whole factor.

split.factor.lev

vector of the numbers of levels for each split factor.

interaction

specifies whether two-way interaction effects are included in a model with the main effects. When interaction = TRUE, two-way interaction effects are include in a model.

delta_type

specifies the type of standardized effect size: 1 for standard deviation type and 2 for range type.

delta

vector of effect sizes: delta[1] for main effects, delta[2] for two-way interaction effects, and delta[3] and delta[4] for standard deviation of whole-plot noise and subplot noise, respectively. When interaction=FALSE, delta[2] is 0.

alpha

Type I error.

beta

Type II error.

maxsize

tolerance for sample size.

Details

This function computes sample size in split-plot design to detect a certain standardized effect size delta with power 1-beta at the significance level alpha. The number of whole-plot factors and split plot factors are up to 2 in the current package version. The linear model for the split-plot design is

yijklm=μ+τi+βj+γk+(βτ)ik+θijk+δl+λm+(δλ)im+(βδ)jl+(βλ)jm+(γδ)kl+(δλ)lm+ϵijklmy_{ijklm} = \mu + \tau_i + \beta_j + \gamma_k + (\beta\tau)_{ik} + \theta_{ijk} + \delta_l + \lambda_m + (\delta\lambda)_{im} + (\beta\delta)_{jl} + (\beta\lambda)_{jm} + (\gamma\delta)_{kl} + (\delta\lambda)_{lm} + \epsilon_{ijklm}

where τi\tau_i is the replicate effect, βj,γk\beta_j, \gamma_k is the whole-plot main effects, θijk\theta_{ijk} is the whole-plot error, δl,λm\delta_l, \lambda_m is the subplot main effects, and ϵijklm\epsilon_{ijklm} is the subplot error.

Value

model

a character vector expressing a model. The whole factor effects and the split factor effects are expressed by the lower-case letters and sequential upper-case letters of the Roman alphabet, and two-way interaction effects are denoted by * operator for pairs of the those effects.

n

optimal sample size.

Delta

a vector of minimal detectable standardized effect sizes.

References

R. V. Lenth (2006-9). Java Applets for Power and Sample Size[Computer software]. Retrieved March 27, 2018 from https://homepage.divms.uiowa.edu/~rlenth/Power/.

Y. B. Lim (1998). Study on the Size of Minimal Standardized Detectable Difference in Balanced Design of Experiments. Journal of the Korean society for Quality Management, 26(4), 239–249.

M. A. Kastenbaum, D. G. Hoel and K. O. Bowman (1970) Sample size requirements : one-way analysis of variance, Biometrika, 57(2), 421–430.

D. C. Montgomery (2013) Design and analysis of experiments. John Wiley & Sons.

See Also

Size.Full, Size.2levFr, Size.Block.

Examples

# only main effects
splitmodel1 <- Size.Split(whole.factor.lev=c(2, 2), split.factor.lev=c(2, 2), interaction=FALSE,
    delta_type=1, delta=c(1, 0, 1, 1), alpha=0.05, beta=0.2)
splitmodel1$model
splitmodel1$n
splitmodel1$Delta

# including two-way interaction effects
splitmodel2 <- Size.Split(whole.factor.lev=c(2, 2), split.factor.lev=c(2, 2), interaction=TRUE,
    delta_type=1, delta=c(1, 1, 1, 1), alpha=0.05, beta=0.2)
splitmodel2