removeSplines: Separating splines from MTR formulas

Description Usage Arguments Value Examples

View source: R/mtr.R

Description

This function separates out the function calls uSpline() and uSplines() potentially embedded in the MTR formulas from the rest of the formula. The terms involving splines are treated separately from the terms that do not involve splines when creating the gamma moments.

Usage

1

Arguments

formula

the formula that is to be parsed.

env

environment in which to formulas. This is necessary as splines may be declared using objects, e.g. knots = x, where x = c(0.3, 0.64, 0.9).

Value

a list containing two objects. One object is formula but with the spline components removed. The second object is a list. The name of each element is the uSpline()/uSplines() command, and the elements are a vector of the names of covariates that were interacted with the uSpline()/uSplines() command.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Declare and MTR with a sline component.
m0 = ~ x1 + x1 : uSpline(degree = 2,
                          knots = c(0.2, 0.4)) +
            x2 : uSpline(degree = 2,
                          knots = c(0.2, 0.4)) +
            x1 : x2 : uSpline(degree = 2,
                               knots = c(0.2, 0.4)) +
            uSpline(degree = 3,
                     knots = c(0.2, 0.4),
                     intercept = FALSE)

## Now separate the spline component from the non-spline component
removeSplines(m0)

ivmte documentation built on Sept. 17, 2021, 5:06 p.m.