expand_as_numeric: Numeric model matrix for continuous convolution

Description Usage Arguments Value Examples

View source: R/expansions.R

Description

Turns ordered variables into integers and expands factors as binary dummy codes. cont_conv() additionally adds noise to discrete variables, but this is only useful for estimation. [cc_prepare()] can be used to evaluate an already fitted estimate.

Usage

1

Arguments

x

a vector or data frame with numeric, ordered, or factor columns.

Value

A numeric matrix containing the expanded variables. It has additional type expanded_as_numeric and attr(, "i_disc") cntains the indices of discrete variables.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# dummy data with discrete variables
dat <- data.frame(
    F1 = factor(rbinom(100, 4, 0.1), 0:4),
    Z1 = as.ordered(rbinom(100, 5, 0.5)),
    Z2 = as.ordered(rpois(100, 1)),
    X1 = rnorm(100),
    X2 = rexp(100)
)

pairs(dat)
pairs(expand_as_numeric(dat))  # expanded variables without noise
pairs(cont_conv(dat))          # continuously convoluted data

cctools documentation built on May 2, 2019, 8:51 a.m.