# ffFullMatrix: Full model matrix from a design matrix In BHH2: Useful Functions for Box, Hunter and Hunter II

## Description

The function builds the full matrix with the constant term, main effects and interactions from a design matrix.

## Usage

 `1` ``` ffFullMatrix(X, x, maxInt, blk = NULL) ```

## Arguments

 `X` numeric matrix. Design matrix. `x` numeric vector. Design matrix entries to use to construct the full model matrix. `maxInt` numeric. Highest interaction order. `blk` numeric matrix. Each column correspond to a blocking factor.

## Details

Columns `x` of matrix `X` are used for main effects. All the 2, ... , `maxInt` order interaction are constructed. The first columns of the final matrix correspond to the constant term (1's) and block factors.

## Value

The function returns list with the following components:

 `Xa` matrix

. Augmented matrix with columns for the constant terms, blocking factors, main effects, second order interactions, ..., etc.

 `x` numeric vector. Design matrix `X` factor (column) numbers used to build the complete model matrix. `maxInt` numeric. The highest interaction order. `nTerms` numeric vector. Contains the number of blocking factors, main effects, 2nd order interaction effects, ... , etc.

## Author(s)

Ernesto Barrios

`ffDesMatrix`

## Examples

 ```1 2 3``` ```print(X <- ffDesMatrix(5,gen=list(c(5,1,2,3,4)))) ffFullMatrix(X[,1:4],x=c(1,2,3,4),maxInt=2,blk=X[,5]) ffFullMatrix(X[,1:5],x=c(1,3,5),maxInt=3) ```

### Example output

```      [,1] [,2] [,3] [,4] [,5]
[1,]   -1   -1   -1   -1    1
[2,]    1   -1   -1   -1   -1
[3,]   -1    1   -1   -1   -1
[4,]    1    1   -1   -1    1
[5,]   -1   -1    1   -1   -1
[6,]    1   -1    1   -1    1
[7,]   -1    1    1   -1    1
[8,]    1    1    1   -1   -1
[9,]   -1   -1   -1    1   -1
[10,]    1   -1   -1    1    1
[11,]   -1    1   -1    1    1
[12,]    1    1   -1    1   -1
[13,]   -1   -1    1    1    1
[14,]    1   -1    1    1   -1
[15,]   -1    1    1    1   -1
[16,]    1    1    1    1    1
\$Xa
one bk1 x1 x2 x3 x4 x1*x2 x1*x3 x1*x4 x2*x3 x2*x4 x3*x4
[1,]   1   1 -1 -1 -1 -1     1     1     1     1     1     1
[2,]   1  -1  1 -1 -1 -1    -1    -1    -1     1     1     1
[3,]   1  -1 -1  1 -1 -1    -1     1     1    -1    -1     1
[4,]   1   1  1  1 -1 -1     1    -1    -1    -1    -1     1
[5,]   1  -1 -1 -1  1 -1     1    -1     1    -1     1    -1
[6,]   1   1  1 -1  1 -1    -1     1    -1    -1     1    -1
[7,]   1   1 -1  1  1 -1    -1    -1     1     1    -1    -1
[8,]   1  -1  1  1  1 -1     1     1    -1     1    -1    -1
[9,]   1  -1 -1 -1 -1  1     1     1    -1     1    -1    -1
[10,]   1   1  1 -1 -1  1    -1    -1     1     1    -1    -1
[11,]   1   1 -1  1 -1  1    -1     1    -1    -1     1    -1
[12,]   1  -1  1  1 -1  1     1    -1     1    -1     1    -1
[13,]   1   1 -1 -1  1  1     1    -1    -1    -1    -1     1
[14,]   1  -1  1 -1  1  1    -1     1     1    -1    -1     1
[15,]   1  -1 -1  1  1  1    -1    -1    -1     1     1     1
[16,]   1   1  1  1  1  1     1     1     1     1     1     1

\$x
[1] 1 2 3 4

\$maxInt
[1] 2

\$nTerms
blk  main int.2
1     4     6

\$Xa
one x1 x3 x5 x1*x3 x1*x5 x3*x5 x1*x3*x5
[1,]   1 -1 -1  1     1    -1    -1        1
[2,]   1  1 -1 -1    -1    -1     1        1
[3,]   1 -1 -1 -1     1     1     1       -1
[4,]   1  1 -1  1    -1     1    -1       -1
[5,]   1 -1  1 -1    -1     1    -1        1
[6,]   1  1  1  1     1     1     1        1
[7,]   1 -1  1  1    -1    -1     1       -1
[8,]   1  1  1 -1     1    -1    -1       -1
[9,]   1 -1 -1 -1     1     1     1       -1
[10,]   1  1 -1  1    -1     1    -1       -1
[11,]   1 -1 -1  1     1    -1    -1        1
[12,]   1  1 -1 -1    -1    -1     1        1
[13,]   1 -1  1  1    -1    -1     1       -1
[14,]   1  1  1 -1     1    -1    -1       -1
[15,]   1 -1  1 -1    -1     1    -1        1
[16,]   1  1  1  1     1     1     1        1

\$x
[1] 1 3 5

\$maxInt
[1] 3

\$nTerms
blk  main int.2 int.3
0     3     3     1
```

BHH2 documentation built on May 1, 2019, 6:27 p.m.