Description Usage Arguments Details See Also Examples
Plot method for GeDS objects. Plots GeDS fits.
1 2 3 4 |
x |
a |
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 (= degree + 1) of the GeDS fit that should be plotted.
By default equal to |
type |
character string specifying the type of plot required.
Should be set either to " |
... |
further arguments to be passed to the |
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | ###################################################
# 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.