plot,GeDS-method {GeDS} | R Documentation |
Plot method for GeDS objects.
Description
Plot method for GeDS objects. Plots GeDS fits.
Usage
## S4 method for signature 'GeDS'
plot(
x,
f = NULL,
which,
DEV = FALSE,
ask = FALSE,
main,
legend.pos = "topright",
new.window = FALSE,
wait = 0.5,
n = 3L,
type = c("none", "Polygon", "NCI", "ACI"),
...
)
Arguments
x |
a |
f |
(optional) specifies the underlying function or generating process to which the model was fit. This parameter is useful if the user wishes to plot the specified function/process alongside the model fit and the data |
which |
a numeric vector specifying the iterations of stage A for which
the corresponding GeDS fits should be plotted.
It has to be a subset of |
DEV |
logical variable specifying whether a plot representing the deviance at each iteration of stage A should be produced or not. |
ask |
logical variable specifying whether the user should be prompted before changing the plot page. |
main |
optional character string to be used as a title of the plot. |
legend.pos |
the position of the legend within the panel. See legend for details. |
new.window |
logical variable specifying whether the plot should be shown in a new window or in the active one. |
wait |
time, in seconds, the system should wait before plotting a new
page. Ignored if |
n |
integer value (2, 3 or 4) specifying the order ( |
type |
character string specifying the type of plot required. Should be
set either to " |
... |
further arguments to be passed to the
|
Details
This method is provided in order to allow the user to plot the GeDS fits
contained in the GeDS-Class
objects.
Since in Stage A of the GeDS algorithm the knots of a linear spline fit are
sequentially located, one at a time, the user may wish to visually inspect
this process using the argument which
. The latter specifies a
particular iteration number (or a vector of such numbers) for which the
corresponding linear fit(s) should be plotted. The ask
and wait
arguments can help the user to manage these pages.
By means of ask
the user can determine for how long each page should
appear on the screen. Pages are sequentially replaced by pressing the enter
button.
Note that, in order to ensure stability, if the object was produced by the
function GGeDS
, plotting intermediate fits of stage A is
allowed only if n = 2
, in contrast to objects produced by
NGeDS
for which plotting intermediate results is allowed also
for n =
2 or 3 results.
The confidence intervals obtained by setting type = "NCI"
are
approximate local bands obtained considering the knots as fixed constants.
Hence the columns of the design matrix are seen as covariates and standard
methodology relying on the se.fit
option of predict.lm
or
predict.glm
is applied.
Setting type = "ACI"
, asymptotic confidence intervals are plotted.
This option is applicable only if the canonical link function has been used
in the fitting procedure.
See Also
Examples
###################################################
# Generate a data sample for the response variable
# Y and the single covariate X, assuming Normal noise
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 using NGeDS
(Gmod <- NGeDS(Y ~ f(X), beta = 0.6, phi = 0.995, Xextr = c(-2,2)))
# Plot the final quadratic GeDS fit (red solid line)
# with its control polygon (blue dashed line)
plot(Gmod)
# Plot the quadratic fit obtained from the linear fit at the 10th
# iteration of stage A i.e. after 9 internal knots have been inserted
# by the GeDS procedure
plot(Gmod, which=10)
# Generate plots of all the intermediate fits obtained
# by running the GeDS procedure
## Not run:
plot(Gmod, which=1:16)
## End(Not run)
###################################################
# Generate a data sample for the response variable Y and the covariate
# X assuming Poisson distributed error and a log link function
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 <- exp(f_1(X))
# Generate Poisson distributed Y according to the mean model
Y <- rpois(N,means)
# Fit a Poisson GeDS regression model using GGeDS
(Gmod2 <- GGeDS(Y ~ f(X), beta = 0.2, phi = 0.995, family = poisson(),
Xextr = c(-2,2)))
# similar plots as before, but for the linear fit
plot(Gmod2, n = 2)
plot(Gmod2, which = 10, n = 2)
## Not run:
plot(Gmod2, which = 1:16, n = 2)
plot(Gmod2, which = 1:16, n = 2, ask = T)
## End(Not run)