f: Defining the covariates for the spline component in a GeDS...

Description Usage Arguments Note See Also Examples

View source: R/read.formula.R

Description

In general the GeDS predictor model may include a GeD spline regression component with respect to part of the independent variables and a parametric component in which the remaining covariates may enter as additive terms.

The function f is to be used in the formula argument of NGeDS or GGeDS in order to specify which independent variables (covariates) should be included in the GeD spline regression component of the predictor model.

Usage

1
f(x, xx = NULL, ...)

Arguments

x

numeric vector containing N sample values of the covariate chosen to enter the spline regression component of the predictor model.

xx

numeric vector containing N sample values for the second covariate (in case NGeDS is run for two dimensions). It has to be either NULL (the default) or a vector of size N, same as x.

...

further arguments. As GeDS currently allows for up to two covariates, specification of further arguments will return an error.

Note

This function is intended to be used only as part of the formula in a GeDS regression via NGeDS or GGeDS and not to be called in other cases by the user.

See Also

NGeDS; GGeDS.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Generate a data sample for the response variable Y and
# the covariates X, reg1, reg2 and off
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))
reg1 <- runif(500, min = -0.1, max = 0.1)
reg2 <- runif(500, min = -0.2, max = 0.2)
off <- runif(500, min = -1, max = 1)
# Specify a model for the mean of Y to include a component non linear
# in X defined by the function f_1 and a linear one in the other covariates
means <- f_1(X) + 2*reg1 + 0.5*reg2 + off
# Add Normal noise to the mean of Y
Y <- rnorm(N, means, sd = 0.1)

# Specify a formula that will be used to model Y as a
# function of X, reg1, reg2 and off.
# The covariate X is for the spline component modeled as GeDS,
# reg1 and reg2 enter linearly, off is an offset, i.e. no coefficient
# will be estimated for it
formula <- Y ~ f(X) + reg1 + reg2 + offset(off)

# Fit a GeDS model specified in formula using NGeDS
(Gmod <- NGeDS(formula, beta = 0.6, phi = 0.995, Xextr = c(-2,2)))

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