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"))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"))
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.
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 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 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.
A GeDS-Class
object, but without the Formula
,
extcall
, terms
and znames
slots.
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. (2017) 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: doi.org/10.1007/s00180-015-0621-7
Dimitrova, D.S., Kaishev, V.K., Lattuada A. and Verrall, R.J. (2017). Geometrically designed, variable knot splines in Generalized (Non-)Linear Models. Available at openaccess.city.ac.uk
# NOT RUN {
# 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