enumerate_basis | R Documentation |
Generate basis functions for all covariates and interaction terms thereof up to a specified order/degree.
enumerate_basis(
x,
max_degree = NULL,
smoothness_orders = rep(0, ncol(x)),
include_zero_order = FALSE,
include_lower_order = FALSE,
num_knots = NULL
)
x |
An input |
max_degree |
The highest order of interaction terms for which the basis
functions ought to be generated. The default ( |
smoothness_orders |
An integer vector of length |
include_zero_order |
A |
include_lower_order |
A |
num_knots |
A vector of length |
A list
of basis functions generated for all covariates and
interaction thereof up to a pre-specified degree.
gendata <- function(n) {
W1 <- runif(n, -3, 3)
W2 <- rnorm(n)
W3 <- runif(n)
W4 <- rnorm(n)
g0 <- plogis(0.5 * (-0.8 * W1 + 0.39 * W2 + 0.08 * W3 - 0.12 * W4))
A <- rbinom(n, 1, g0)
Q0 <- plogis(0.15 * (2 * A + 2 * A * W1 + 6 * A * W3 * W4 - 3))
Y <- rbinom(n, 1, Q0)
data.frame(A, W1, W2, W3, W4, Y)
}
set.seed(1234)
data <- gendata(100)
covars <- setdiff(names(data), "Y")
X <- as.matrix(data[, covars, drop = FALSE])
basis_list <- enumerate_basis(X)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.