make_basis_matrix: Make a matrix for a linear (mixed) model with known basis...

Description Usage Arguments Value Author(s) See Also Examples

View source: R/make_basis_matrix.R

Description

Takes a vector of x-values and a basis type ("tent" and "poly" are current options) and returns a design matrix for fitting a piecewise linear mixed effects model with one group. Basis created uses the so-called "tent-functions". See, e.g., Simon Wood (2017) GAM 2nd edition text, section 4.2, page 164-166.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
make_basis_matrix(
  x,
  basis = c("tent", "poly"),
  break_points = NULL,
  add_column_names = TRUE,
  format_digits = 3,
  degree = 2,
  include_intercept = FALSE,
  use_poly_coefs = FALSE
)

Arguments

x

numeric vector of values to use in forming the basis.

basis

character string specifying which kind of basis to generate.

break_points

numeric vector with the x-locations at which to place break points.

add_column_names

logical whether to add column names to the matrix.

format_digits

how many digits to retain in column names? Used only if add_column_names is TRUE

degree

numeric degree of polynomial basis, if that is selected. Passed straight to stats::poly().

include_intercept

logical whether to append an intercept term to the matrix for a polynomial basis.

use_poly_coefs

logical whether to use "attr( maeve_options('poly_object'), 'coef')" to scale poly basis matrix.

Value

a matrix

Author(s)

Bill Forrest forrest@gene.com

See Also

matrix

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
  ### Need to put in an actual example here.
  simple_tent_basis <-
    maeve:::make_basis_matrix( x = seq( 0, 1, length = 11 ),
                               basis = 'tent',
                               break_points = c( 0, 0.5, 1 )
                              )
  ##
  simple_poly_basis <-
    maeve:::make_basis_matrix( x = seq( 0, 1, length = 11 ),
                               basis = 'poly',
                               degree = 3
                              )
  

wfforrest/maeve documentation built on Jan. 1, 2021, 12:47 p.m.