Learn R Programming

FindIt (version 0.2)

maketwoway: Constructing a named matrix of all two-way interactions.

Description

maketwoway takes a set of pre-treatment covariates and returns all sensible two-way interactions.

Usage

maketwoway(X, wts = 1, center = T)

Arguments

X
A matrix of pre-treatment covariates.
wts
An optional set of extrapolation weights.
center
Whether the columns should be centered before interacting. Set to false with a factorial treatment design.

Value

  • XA matrix with all linear terms, squared terms, and two-way interactions from the original matrix.
  • scale.XA vector of weights for reutrning X to its original scale.

Details

Useful for constructing a matrix for FindIt. Takes a matrix and returns a matrix of two-way interactions. A named matrix with an intercept, all two-way interactions and square terms are returned. If center=TRUE, interactions are formed by (1) centering, (2) scaling to sd 1, and (3) interacting. Non-sensible interactions, such as interacting dummy variables for male and female, as well as squared terms for dummy variables, are not returned. A rescaling vector is returned, so that the columns of the standardized matrix can be returned to their original scale.

Examples

Run this code
#See the help page for FindIt() for an example.

Run the code above in your browser using DataLab