design.experiment: Design an experiment

View source: R/design.experiment.r

design.experimentR Documentation

Design an experiment

Description

Design an experiment

Usage

design.experiment(
  list.IV,
  type.IV,
  formula,
  calculate.coef.num = F,
  seed = NA,
  beta.min = 0,
  beta.max = 20,
  betas = NA,
  theta.min = 0,
  theta.max = 8,
  thetas = NA,
  thetas.orthogonal = T,
  s.min = 0,
  s.max = 20,
  s = NA
)

Arguments

list.IV

a list of the independent variables with their relative values

type.IV

a vector specifying whether each IV is within ("w") or between ("b")

formula

a string describing the linear model to be simulated, of the type ~ F1 + (F2*F3)

calculate.coef.num

logical, if TRUE the function just calculates the number of coefficients corresponding to the variables listed

seed

optional, a seed to apply to the simulation (for reproducibility)

beta.min

lower boundary of the uniform distribution from which the values/means of the betas are extracted (if betas = NA)

beta.max

upper boundary of the uniform distribution from which the values/means of the betas are extracted (if betas = NA)

betas

this parameters allows to assign a specific mean/value to each parameter of the model. The length of betas must be equal to the amount of coefficients in the model specified by the formula.

theta.min

lower boundary of the uniform distribution from which the standard deviation of the betas are extracted (if thetas = NA)

theta.max

upper boundary of the uniform distribution from which the standard deviation of the betas are extracted (if thetas = NA)

thetas

this parameters allows to assign a specific standard deviation to each parameter of the model. The length of thetas must be equal to the amount of coefficients in the model specified by the formula.

thetas.orthogonal

logical, are the parameters orthogonal?

s.min

lower boundary of the uniform distribution from which the standard deviation of the model's residuals is extracted (if s = NA)

s.max

upper boundary of the uniform distribution from which the standard deviation of the model's residuals is extracted (if s = NA)

s

this parameters allows to assign a specific standard deviation to the model's residuals

Value

An object of the class mu.exp.design to be used with the function sample.experiment with the following values

seed the seed that will be used for simulation

ncoef the number of coefficients of the model

beta.matrix coefficients matrix

theta.matrix random components matrix

corr.matrix random components correlation matrix

sigma the model residuals standard deviation

IV list of the parameters of the model (basically returns list.IV)

type_IV returns type.IV

formula returns the formula

Examples

libraries()

# set a seed
trial.seed <- 9000

# initialize the factors list
lIV <- list(
  Var1 = factor(1:2, labels = c("a","b"))
  ,
  Var2 = factor(1:2)
)

tIV <- c("w","b")

# describe the model
exp.formula <- ~ Var1*Var2

# initialize the coefficients
cus.beta <- c(1, 4, 5, 1)*3 # means of the fixed effects
cus.theta <- c(1, 4, 5, 1) # standard errors of the random components
cus.sigma <- 3 # sigma of the model

# few examples
(r1 <- design.experiment(lIV, tIV, exp.formula, seed=trial.seed))
(r2 <- design.experiment(lIV, tIV, exp.formula, seed=trial.seed, thetas.orthogonal=F))
(r3 <- design.experiment(lIV, tIV, exp.formula, seed=trial.seed, beta.min=-5, beta.max=10, theta.min=0, theta.max=10, s.min=5, s.max=12))
(r4 <- design.experiment(lIV, tIV, exp.formula, seed=trial.seed, betas=cus.beta, thetas=cus.theta, s=cus.sigma, thetas.orthogonal=F))


ccamp83/mu documentation built on Sept. 10, 2023, 4:22 p.m.