coef.GeDS | R Documentation |
Methods for the functions coef
and
coefficients
that allow to extract the estimated
coefficients of a fitted GeDS regression from a GeDS-Class
object.
## S3 method for class 'GeDS'
coef(object, n = 3L, onlySpline = TRUE, ...)
## S3 method for class 'GeDS'
coefficients(object, n = 3L, onlySpline = TRUE, ...)
object |
the |
n |
integer value (2, 3 or 4) specifying the order ( |
onlySpline |
logical variable specifying whether only the coefficients for the GeDS component of a fitted multivariate regression model should be extracted or if, alternatively, also the coefficients of the parametric component should also be extracted. |
... |
potentially further arguments (required by the definition of the generic function). These will be ignored, but with a warning. |
These are simple methods for the functions coef
and
coefficients
.
As GeDS-class
objects contain three different fits (linear,
quadratic and cubic), it is possible to specify the order of the fit for
which GeDS regression coefficients are required via the input argument
n
.
As mentioned in the details of formula
, the
predictor model may be multivariate and it may include a (univariate or
bivariate) GeD spline component whereas the remaining variables may be part
of a parametric component. If the onlySpline
argument is set to
TRUE
(the default value), only the coefficients corresponding to the
GeD spline component of order n
of the multivariate predictor model
are extracted.
A named vector containing the required coefficients of the fitted
univariate or multivariate predictor model. The coefficients corresponding to
the variables that enter the parametric component of the fitted multivariate
predictor model are named as the variables themselves. The coefficients of
the GeDS component are coded as "N
" followed by the index of the
corresponding B-spline.
coef
for the standard definition;
NGeDS
for examples.
# Generate a data sample for the response variable
# and the covariates
set.seed(123)
N <- 500
f_1 <- function(x) (10*x/(1+100*x^2))*4+4
X <- sort(runif(N ,min = -2, max = 2))
Z <- runif(N)
# Specify a model for the mean of the response Y to be a superposition of
# a non-linear component f_1(X), a linear component 2*Z and a
# free term 1, i.e.
means <- f_1(X) + 2*Z + 1
# Add normal noise to the mean of y
Y <- rnorm(N, means, sd = 0.1)
# Fit to this sample a predictor model of the form f(X) + Z, where
# f(X) is the GeDS component and Z is the linear (additive) component
# see ?formula.GeDS for details
(Gmod <- NGeDS(Y ~ f(X) + Z, beta = 0.6, phi = 0.995, Xextr = c(-2,2)))
# Extract the GeD spline regression coefficients
coef(Gmod, n = 3)
# Extract all the coefficients, including the one for the linear component
coef(Gmod, onlySpline = FALSE, n = 3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.