Description Usage Arguments Value Author(s) See Also Examples
View source: R/construct_design_matrix_from_basis.R
Takes a data frame with a grouping factor and a vector of time 'x'-values and a user choice of basis function type (currently 'tent' or 'poly') and returns a design matrix for fitting a piecewise linear mixed effects model. Tent basis vectors are created from the so-called "tent-functions". See, e.g., Simon Wood (2017) GAM 2nd edition text, section 4.2, page 164-166. Polynomial basis vectors (not to be confused with the gam spline approach) use the stats::poly() function. This is intended to be used in fitting linear mixed effects models to three (maybe four?) time points. It can in principal be used for more than that, but in that circumstance the spline approach will typically be better and is recommended.
1 2 3 4 5 6 7 8 9 10 11 | construct_design_matrix_from_basis(
study_data_frame,
basis_choice = c("tent", "poly"),
format_digits = 3,
use_poly_coefs = FALSE,
group_name = maeve_options("group_name"),
x_name = maeve_options("x_name"),
break_points = maeve_options("break_points"),
number_break_points = maeve_options("number_break_points"),
poly_degree = maeve_options("poly_degree")
)
|
study_data_frame |
data.frame with time ('x') vector and grouping vector |
basis_choice |
character describing which basis function type to use in making a design matrix. |
format_digits |
how many digits to retain in column names? |
use_poly_coefs |
logical whether to use "attr( maeve_options('poly_object'), 'coef')" to scale poly basis matrix. |
group_name |
character. See ?maeve_options(). |
x_name |
character. See ?maeve_options(). |
break_points |
numeric vector. See ?maeve_options(). |
number_break_points |
numeric. See ?maeve_options(). |
poly_degree |
numeric. See ?maeve_options(). |
a design matrix, including intercept(s), that can be used with lme4::lmer().
Bill Forrest forrest@gene.com
1 2 3 4 5 6 7 8 | ### Make a basis for piecewise linear regression over 21 days from the vismodegib data:
require( magrittr ) # want pipe operator "%>%"
vismo_pwl_basis <-
vismodegib %>%
dplyr::filter( DAY_OF_STUDY <= 21 ) %>%
maeve:::construct_design_matrix_from_basis( basis_choice = 'tent',
break_points = c( 0, 7, 14, 21 )
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.