weighted_term {VAJointSurv}R Documentation

Term for a Basis Matrix for Weighted Term

Description

Creates a weighted basis matrix where the entries are weighted with a numeric vector to e.g. create a varying-coefficient.

Usage

weighted_term(x, weight)

Arguments

x

a term type from the package.

weight

a symbol for the weight. Notice that the symbol is first first used when the eval function on the returned object is called.

Value

A list with an element called eval to evaluate the basis. See VAJointSurv-terms.

See Also

poly_term, bs_term, ns_term, and stacked_term.

Examples

vals <- c(0.41, 0.29, 0.44, 0.1, 0.18, 0.65, 0.29, 0.85, 0.36, 0.47)

spline_basis <- ns_term(vals, df = 3)
ws <- c(4,5)
# create a weighted term
w_term <- weighted_term(spline_basis, weights)

# evaluate weighted basis at 0.5 and 0.7 with weights 4 and 5
w_term$eval(c(0.5,0.7), newdata = data.frame(weights = ws))
# evaluate the first derivative of weighted basis at 0.5 and 0.7
# with weights 4 and 5
w_term$eval(c(0.5,0.7), newdata = data.frame(weights = ws), der = 1)

[Package VAJointSurv version 0.1.0 Index]