View source: R/model_matrix_functions.R
| make_matrices_old | R Documentation |
Build the design and the penalty matrix for models involving penalised splines based on a formula and a data set
make_matrices_old(formula, data, knots = NULL)
formula |
right side of a formula as used in |
data |
data frame containing the variables in the formula |
knots |
optional list containing user specified knot values to be used for basis construction For most bases the user simply supplies the |
a list containing the design matrix Z, a (potentially nested) list of penalty matrices S, the formula, the data, the knots, and the original mod object returned by mgcv.
Note that for tensorproduct smooths, the corresponding list entry is itself a list, containing the d marginal penalty matrices if d is the dimension of the tensor product.
data = data.frame(x = runif(100),
y = runif(100),
g = factor(rep(1:10, each = 10)))
# unvariate thin plate regression spline
modmat = make_matrices(~ s(x), data)
# univariate P-spline
modmat = make_matrices(~ s(x, bs = "ps"), data)
# adding random intercept
modmat = make_matrices(~ s(g, bs = "re") + s(x, bs = "ps"), data)
# tensorproduct of x and y
modmat = make_matrices(~ s(x) + s(y) + ti(x,y), data)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.