
Last chance! 50% off unlimited learning
Sale ends in
These are computing engines called by NGeDS
and
GGeDS
, needed for the underlying fitting procedures.
UnivariateFitter(
X,
Y,
Z = NULL,
offset = rep(0, NROW(Y)),
weights = rep(1, length(X)),
beta = 0.5,
phi = 0.5,
min.intknots = 0,
max.intknots = 300,
q = 2,
extr = range(X),
show.iters = FALSE,
tol = as.double(1e-12),
stoptype = c("SR", "RD", "LR"),
higher_order = TRUE,
intknots_init = NULL,
fit_init = NULL,
only_pred = FALSE
)GenUnivariateFitter(
X,
Y,
Z = NULL,
offset = rep(0, NROW(Y)),
weights = rep(1, length(X)),
family = gaussian(),
beta = 0.5,
phi = 0.5,
min.intknots = 0,
max.intknots = 300,
q = 2,
extr = range(X),
show.iters = F,
tol = as.double(1e-12),
stoptype = c("SR", "RD", "LR"),
higher_order = TRUE
)
A GeDS-Class
object, but without the Formula
,
extcall
, terms
and znames
slots.
a numeric vector containing
a vector of size
a design matrix with formula
). If no such covariates are selected, it
is set to NULL
by default.
a vector of size offset
argument is particularly useful when using
GenUnivariateFitter
if the link function used is not the identity.
an optional vector of size NULL
by default.
numeric parameter in the interval NGeDS
or
GGeDS
.
numeric parameter in the interval stoptype
and details in the description of NGeDS
or
GGeDS
.
optional parameter allowing the user to set a minimum number of internal knots required. By default equal to zero.
optional parameter allowing the user to set a maximum
number of internal knots to be added by the GeDS estimation algorithm. By
default equal to the number of internal knots
numeric parameter which allows to fine-tune the stopping rule of
stage A of GeDS, by default equal to 2. See details in the description of
NGeDS
or GGeDS
.
numeric vector of 2 elements representing the left-most and
right-most limits of the interval embedding the sample values of X
. By
default equal correspondingly to the smallest and largest values of X
.
logical variable indicating whether or not to print
information at each step. By default equal to FALSE
.
numeric value indicating the tolerance to be used in the knot placement steps in stage A. By default equal to 1E-12. See details below.
a character string indicating the type of GeDS stopping rule
to be used. It should be either "SR"
, "RD"
or "LR"
,
partial match allowed. See details of NGeDS
or
GGeDS
.
a logical that defines whether to compute the higher
order fits (quadratic and cubic) after stage A is run. Default is
TRUE
.
vector of initial internal knots from which to start the GeDS
Stage A iterations. See Section 3 of Kaishev et al. (2016). Default is NULL
.
A list containing fitted values pred
, along with
corresponding intknots
and coef
, representing the initial fit from
which to begin Stage A GeDS iteration (i.e. departing from step 2).
logical, if TRUE
only predictions are computed.
a description of the error distribution and link function to be
used in the model. This can be a character string naming a family function
(e.g. "gaussian"
), the family function itself (e.g.
gaussian
) or the result of a call to a family function
(e.g. gaussian()
). See family for details on family
functions.
The functions UnivariateFitter
and GenUnivariateFitter
are in
general not intended to be used directly, they should be called through
NGeDS
and GGeDS
. However, in case there is a need
for multiple GeDS fitting (as may be the case e.g. in Monte Carlo simulations)
it may be efficient to use the fitters outside the main functions.
The argument tol
is used in the knot placement procedure of stage A of
the GeDS algorithm in order to check whether the current knot tol
,
See NGeDS
and GGeDS
, Kaishev et al. (2016) and
Dimitrova et al. (2023) for further details.
Kaishev, V.K., Dimitrova, D.S., Haberman, S., & Verrall, R.J. (2016).
Geometrically designed, variable knot regression splines.
Computational Statistics, 31, 1079--1105.
DOI: tools:::Rd_expr_doi("10.1007/s00180-015-0621-7")
Dimitrova, D. S., Kaishev, V. K., Lattuada, A. and Verrall, R. J. (2023).
Geometrically designed variable knot splines in generalized (non-)linear
models.
Applied Mathematics and Computation, 436.
DOI: tools:::Rd_expr_doi("10.1016/j.amc.2022.127493")
NGeDS
and GGeDS
.
# Examples similar to the ones
# presented in NGeDS and in GGeDS
# Generate a data sample for the response variable
# Y and the covariate X
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))
# Specify a model for the mean of Y to include only
# a component non-linear in X, defined by the function f_1
means <- f_1(X)
# Add (Normal) noise to the mean of Y
Y <- rnorm(N, means, sd = 0.1)
# Fit a Normal GeDS regression model using the fitter function
(Gmod <- UnivariateFitter(X, Y, beta = 0.6, phi = 0.995,
extr = c(-2,2)))
##############################################################
# second: very similar example, but based on Poisson data
set.seed(123)
X <- sort(runif(N , min = -2, max = 2))
means <- exp(f_1(X))
Y <- rpois(N,means)
(Gmod2 <- GenUnivariateFitter(X, Y, beta = 0.2,
phi = 0.995, family = poisson(), extr = c(-2,2)))
# a plot showing quadratic and cubic fits,
# in the predictor scale
plot(X,log(Y), xlab = "x", ylab = expression(f[1](x)))
lines(Gmod2, n = 3, col = "red")
lines(Gmod2, n = 4, col = "blue", lty = 2)
legend("topleft", c("Quadratic", "Cubic"),
col = c("red", "blue"),
lty = c(1,2))
Run the code above in your browser using DataLab