coef.lgspline | R Documentation |
Extracts polynomial coefficients for each partition from a fitted lgspline model.
## S3 method for class 'lgspline'
coef(object, ...)
object |
A fitted lgspline model object containing coefficient vectors. |
... |
Not used. |
For each partition, coefficients represent a polynomial expansion of the predictor(s) by column index, for example:
intercept: Constant term
v: Linear term
v_^2: Quadratic term
v^3: Cubic term
_v_x_w_: Interaction between v and w
If column/variable names are present, indices will be replaced with column/variable names.
Coefficients can be accessed either as separate vectors per partition or combined into
a single matrix using Reduce('cbind', coef(model_fit))
.
A list where each element corresponds to a partition and contains a single-column matrix of coefficient values for that partition. Row names indicate the term type. Returns NULL if coefficients are not found in the object.
Matrices containing coefficients for each partition.
lgspline
## Simulate some data and fit using default settings
set.seed(1234)
t <- runif(1000, -10, 10)
y <- 2*sin(t) + -0.06*t^2 + rnorm(length(t))
model_fit <- lgspline(t, y)
## Extract coefficients
coefficients <- coef(model_fit)
## Print coefficients for first partition
print(coefficients[[1]])
## Compare coefficients across all partitions
print(Reduce('cbind', coefficients))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.