Learn R Programming

OptimalDesign (version 0.2)

F.cube: Model matrix on a cube

Description

Creates the matrix of regressors for a model on a d-dimensional rectangular grid of points, i.e., for a factorial model with d quantitative factors.

Usage

F.cube(formula, lower, upper, n.levels)

Arguments

formula

The formula of the model.

lower

The real vector of length d determining the smallest values of factors.

upper

The real vector of length d determining the largest values of factors.

n.levels

The vector of length d consisting of the numbers greater than or equal to 2, determining the numbers of levels of each factor.

Value

The n times m matrix of regressors with the m-dimensional rows corresponding to the regressors of the n design points (n is equal to prod(n.levels)).

Details

The rules for creating the model formula are the same as in the lm function but: 1) the formula must not contain the dependent variable; 2) the d factors (independent variables) must be labeled x1, x2, ...

See Also

F.simplex

Examples

Run this code
# NOT RUN {
# The matrix of regressors for the trigonometric model of the second 
# degree on the "full circle" discretized to 24 equidistant points.
F.cube(~I(cos(x1)) + I(sin(x1)) + I(cos(2*x1)) + I(sin(2*x1)), 
       0, (46 / 24) * pi, 24)

# The matrix of regressors of the cubic model on a discretized 
# interval [-1,1].
F.cube(~x1 + I(x1^2) + I(x1^3), -1, 1, 21)

# The matrix of regressors of the 3-factor model with the intercept, 
# the linear and the second-order interaction terms; 
# the first 2 factors have levels -1, 0, 1, and the third factor has 
# levels -1, 0.5, 0, 0.5, 1.
F.cube(~x1*x2 + x1*x3 + x2*x3, rep(-1, 3), rep(1, 3), c(3, 3, 5))
# }

Run the code above in your browser using DataLab