lines-GeDS-method: Lines method for GeDS objects. Adds a GeDS curve to an...

Description Usage Arguments Details See Also Examples

Description

Lines method for GeDS objects. Adds a GeDS curve to an existing plot.

Usage

1
2
3
## S4 method for signature 'GeDS'
lines(x, n = 3L, transform = function(x) x,
  onlySpline = TRUE, data = data.frame(), ...)

Arguments

x

a GeDS-Class object from which the GeDS fit should be extracted.

n

integer value (2, 3 or 4) specifying the order (= degree + 1) of the GeDS fit that should be plotted. By default equal to 3L. Non-integer values will be passed to the function as.integer.

transform

a function that can be used to transform the scale of the Y axis. Typically it can be the inverse of the link function if the plot is on the scale of the response variable.

onlySpline

logical variable specifying whether only the spline component of the fitted GeDS predictor model should be plotted or alternatively also the parametric component (see formula) should be plotted.

data

an optional data.frame, list or environment containing values of the independent variables for which the GeDS predicted values should be plotted. If left empty the values are extracted from the object x itself.

...

further arguments to be passed to the default lines function.

Details

This method can be used to add a curve corresponding to a particular GeDS fit to an active plot.

As GeDS objects contain three different fits (linear, quadratic and cubic), it is possible to specify the order of the GeDS regression to be plotted via the input argument n.

See Also

lines for the definition of the generic function; NGeDS and GGeDS for examples.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
# Generate a data sample for the response variable
# Y and the single 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 GeDS regression model using NGeDS
(Gmod <- NGeDS(Y ~ f(X), beta = 0.6, phi = 0.995, Xextr = c(-2,2)))

# Plot the GeDS third order fit (the quadratic one)
# without its corresponding Polygon
plot(Gmod, type = "none")

# Add a curve corresponding to the second order fit (the linear one)
lines(Gmod, n = 2, col = "green", lwd = 2, lty = 3)

GeDS documentation built on May 2, 2019, 12:36 p.m.