Expand matrix columns into linear, square, and unique product columns.

1 |

`X` |
vector or matrix. If a vector, it will be converted to
a column matrix. If it is desired that the squares
and products of a |

`FUN` |
Binary function which forms the products of the columns.
By default, this is '*', but other |

`...` |
Options for FUN. Not needed if FUN doesn't have options. |

Form a matrix with columns composed of into linear, square, and product columns:

*[X | FUN(X[,i], X[,j])]*

where *i, j* are the unique combinations of *i* and *j*,
including *i=j*.

By default, the function used to form the squares and
products, FUN, is just conventional multiplication = '*', but any
*commuting* binary operator can be used.

This particular expansion is often applied in

General Method of Data Handling (GMDH).

Nonlinear Slow Feature Analysis (SFA). Performing a multivariate polynomial of second degree expansion in all the features, then performing

*linear*SFA on the resulting expanded feature matrix, is a very common approach, and in fact is the default method in`sfa2 {rSFA}`

.

*[X,X^2,unique products of columns of X]*. The unique
products are in row major upper right triangular order.
Thus, for X with columns 1:3, the order is

*X[,1]^2, X[,2]^2, X[,3]^2,
X[,1]*X[,2], X[,1]*X[,3], X[,2]*X[,3]*

1 2 3 | ```
# # Examples
# eQuad(1:5)
# eQuad(matrix(1:12,ncol=3),FUN=`+`)
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.