weighted_term | R Documentation |
Creates a weighted basis matrix where the entries are weighted with a numeric vector to e.g. create a varying-coefficient.
weighted_term(x, weight)
x |
a term type from the package. |
weight |
a symbol for the weight. Notice that the symbol is first
first used when the |
A list with an element called eval
to evaluate the basis. See VAJointSurv-terms
.
poly_term
, bs_term
, ns_term
, and
stacked_term
.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.